Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvements to Instructor Tools #2266

Merged
merged 25 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
35cf980
imporvements to Instructor Tools
Alex-Jordan Nov 28, 2023
03dfdeb
Implement suggestions made in my review of openwebwork/webwork2#2266
drgrice1 Nov 29, 2023
011bf55
Merge pull request #20 from drgrice1/instructor-tools-suggestions
Alex-Jordan Nov 29, 2023
3a3f9e8
Add more tools to Instructor Tools
Alex-Jordan Nov 30, 2023
5ce2f55
change 370px to 28em for Instructor Tools column width
Alex-Jordan Nov 30, 2023
f6d70e7
Change Instructor Tool form to pills navigation
Alex-Jordan Nov 30, 2023
b2ff4c2
some cleanup
Alex-Jordan Nov 30, 2023
299dd0b
adjust some wording
Alex-Jordan Dec 1, 2023
96f7d25
Style tweaks for the new tabbed layout of the instructor tools input …
drgrice1 Dec 1, 2023
b9c3656
Merge pull request #21 from drgrice1/instructor-tools-tweaks
Alex-Jordan Dec 1, 2023
48726ac
filter users by permission level or role
Alex-Jordan Dec 1, 2023
3aef0da
Efficiency tweak (a significant improvement for large classes).
drgrice1 Dec 1, 2023
32da067
Merge pull request #22 from drgrice1/instructor-tools-efficiency-tweak
Alex-Jordan Dec 1, 2023
90891a4
feedback from PR#2266
Alex-Jordan Dec 1, 2023
237df81
perltidy
Alex-Jordan Dec 1, 2023
cdcbe3a
ability to intersect or union filters
Alex-Jordan Dec 1, 2023
eb4a690
tweak filter radio buttons
Alex-Jordan Dec 1, 2023
9aabb31
More suggestions.
drgrice1 Dec 1, 2023
1d342f4
Merge pull request #23 from drgrice1/instructor-tools-more-tweaks
Alex-Jordan Dec 1, 2023
550ddd7
Between the `md` and `lg` breakpoint, drop out of the horizontal layout
drgrice1 Dec 1, 2023
6cf9147
Add `font-sm` to the union/intersect checkbox labels.
drgrice1 Dec 1, 2023
b7768a2
Also add a small tweak to make the selects on the Answer Log page closer
drgrice1 Dec 1, 2023
b7b296d
Merge pull request #24 from drgrice1/instructor-tools-perhaps
Alex-Jordan Dec 2, 2023
54e3587
update helpfiles where scrolling record list is used
Alex-Jordan Dec 2, 2023
07b04fd
fix indentation in some template files
Alex-Jordan Dec 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion htdocs/js/SendMail/sendmail.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(() => {
const previewUserNameSpan = document.getElementById('preview-user');
const classListSelect = document.getElementById('classList');
const classListSelect = document.getElementById('selected_users');
if (previewUserNameSpan && classListSelect) {
const setPreviewUser = () => {
if (classListSelect.selectedIndex !== -1)
Expand Down
15 changes: 15 additions & 0 deletions htdocs/themes/math4/math4.scss
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,21 @@ ul.courses-list {
}
}

/* Instructor Tools page */
#instructor-tools-nav {
input[name="number_of_students"] {
max-width: 7em;
}

#pills-tabContent input.btn {
min-width: 7em;
}

span.input-group-text {
white-space: pre;
}
}

/* past answers page */
.past-answer-table {
td {
Expand Down
36 changes: 20 additions & 16 deletions lib/WeBWorK/ContentGenerator/Instructor/Index.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pages

=cut

use WeBWorK::Utils qw(x format_set_name_internal);
use WeBWorK::Utils qw(x format_set_name_internal jitar_id_to_seq prob_id_sort);

use constant E_MAX_ONE_SET => x('Please select at most one set.');
use constant E_ONE_USER => x('Please select exactly one user.');
Expand Down Expand Up @@ -83,13 +83,6 @@ sub pre_header_initialize ($c) {
} else {
push @error, E_ONE_SET;
}
} elsif (defined $c->param('edit_sets')) {
if ($nsets == 1) {
$route = 'instructor_set_detail';
$args{setID} = $firstSetID;
} else {
push @error, E_ONE_SET;
}
} elsif (defined $c->param('prob_lib')) {
if ($nsets == 1) {
$route = 'instructor_set_maker';
Expand Down Expand Up @@ -153,11 +146,25 @@ sub pre_header_initialize ($c) {
$route = 'instructor_set_detail';
$args{setID} = $firstSetID;
$params{editForUser} = \@selectedUserIDs;
} elsif ($nsets == 1) {
$route = 'instructor_set_detail';
$args{setID} = $firstSetID;
} else {
push @error, E_MIN_ONE_USER unless $nusers >= 1;
push @error, E_ONE_SET unless $nsets == 1;

push @error, E_ONE_SET unless $nsets == 1;
}
} elsif (defined $c->param('show_answers')) {
my %all_problems;
for my $setID (@selectedSetIDs) {
my @problems = $db->listGlobalProblems($setID);
if ($db->getGlobalSet($setID)->assignment_type && $db->getGlobalSet($setID)->assignment_type eq 'jitar') {
@problems = map { join('.', jitar_id_to_seq($_)) } @problems;
}
@all_problems{@problems} = (1) x @problems;
}
$route = 'answer_log';
$params{selected_users} = \@selectedUserIDs;
$params{selected_sets} = \@selectedSetIDs;
$params{selected_problems} = [ prob_id_sort keys %all_problems ];
} elsif (defined $c->param('create_set')) {
my $setname = format_set_name_internal($c->param('new_set_name') // '');
if ($setname) {
Expand All @@ -174,16 +181,13 @@ sub pre_header_initialize ($c) {
}
} elsif (defined $c->param('add_users')) {
$route = 'instructor_add_users';
} elsif (defined $c->param('email_users')) {
$route = 'instructor_mail_merge';
} elsif (defined $c->param('transfer_files')) {
$route = 'instructor_file_manager';
$params{number_of_students} = $c->param('number_of_students') // 1;
}

push @error, x('You are not allowed to act as a student.')
if (defined $c->param('act_as_user') && !$authz->hasPermissions($userID, 'become_student'));
push @error, x('You are not allowed to modify homework sets.')
if ((defined $c->param('edit_sets') || defined $c->param('edit_set_for_users'))
if (defined $c->param('edit_set_for_users')
&& !$authz->hasPermissions($userID, 'modify_problem_sets'));
push @error, x('You are not allowed to assign homework sets.')
if ((defined $c->param('sets_assigned_to_user') || defined $c->param('users_assigned_to_set'))
Expand Down
4 changes: 4 additions & 0 deletions lib/WeBWorK/ContentGenerator/Instructor/ProblemSetDetail.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ specific user/set information as well as problem information

=cut

use Exporter qw(import);

use WeBWorK::Utils qw(cryptPassword jitar_id_to_seq seq_to_jitar_id x format_set_name_internal format_set_name_display);
use WeBWorK::Utils::Instructor qw(assignProblemToAllSetUsers addProblemToSet);

our @EXPORT_OK = qw(FIELD_PROPERTIES);

# These constants determine which fields belong to what type of record.
use constant SET_FIELDS => [
qw(set_header hardcopy_header open_date reduced_scoring_date due_date answer_date visible description
Expand Down
4 changes: 2 additions & 2 deletions lib/WeBWorK/ContentGenerator/Instructor/SendMail.pm
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ sub initialize ($c) {
$c->{defaultSubject} = $c->stash('courseID') . ' notice';
$c->{merge_file} = $mergefile // '';

my @classList = $c->param('classList') // ($user);
my @classList = $c->param('selected_users') // ($user);
$c->{preview_user} = $c->db->getUser($classList[0] || $user);

# Gather database data
Expand Down Expand Up @@ -129,7 +129,7 @@ sub initialize ($c) {
if ($recipients eq 'all_students') {
@send_to = map { $_->user_id } @Users;
} elsif ($recipients eq 'studentID') {
@send_to = $c->param('classList');
@send_to = $c->param('selected_users');
}

$c->{ra_send_to} = \@send_to;
Expand Down
42 changes: 2 additions & 40 deletions lib/WeBWorK/ContentGenerator/Instructor/ShowAnswers.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ WeBWorK::ContentGenerator::Instructor::ShowAnswers.pm -- display past answers o
use Text::CSV;
use Mojo::File;

use WeBWorK::Utils qw(sortByName jitar_id_to_seq);
use WeBWorK::Utils qw(sortByName jitar_id_to_seq prob_id_sort);
use WeBWorK::Utils::Rendering qw(renderPG);

use constant PAST_ANSWERS_FILENAME => 'past_answers';
Expand Down Expand Up @@ -312,47 +312,9 @@ sub getInstructorData ($c) {
return (
users => \@users,
expandedGlobalSetIDs => \@expandedGlobalSetIDs,
globalProblemIDs => [ sort prob_id_sort keys %all_problems ],
globalProblemIDs => [ prob_id_sort keys %all_problems ],
filename => PAST_ANSWERS_FILENAME . '.csv'
);
}

sub byData {
my ($A, $B) = ($a, $b);
$A =~ s/\|[01]*\t([^\t]+)\t.*/|$1/; # remove answers and correct/incorrect status
$B =~ s/\|[01]*\t([^\t]+)\t.*/|$1/;
return $A cmp $B;
}

# Sorts problem ID's so that all just-in-time like ids are at the bottom
# of the list in order and other problems
sub prob_id_sort {

my @seqa = split(/\./, $a);
my @seqb = split(/\./, $b);

# go through problem number sequence
for (my $i = 0; $i <= $#seqa; $i++) {
# if at some point two numbers are different return the comparison.
# e.g. 2.1.3 vs 1.2.6
if ($seqa[$i] != $seqb[$i]) {
return $seqa[$i] <=> $seqb[$i];
}

# if all of the values are equal but b is shorter then it comes first
# i.e. 2.1.3 vs 2.1
if ($i == $#seqb) {
return 1;
}
}

# if all of the values are equal and a and b are the same length then equal
# otherwise a was shorter than b so a comes first.
if ($#seqa == $#seqb) {
return 0;
} else {
return -1;
}
}

1;
13 changes: 11 additions & 2 deletions lib/WeBWorK/HTML/ScrollingRecordList.pm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ sub scrollingRecordList ($options, @records) {

$sorts = getSortsForClass($class, $options{default_sort});
$formats = getFormatsForClass($class, $options{default_format});
$filters = getFiltersForClass(@records);
# Remove sorts that are irrelevant for our formats
my @format_keywords;
for my $format (@$formats) {
push(@format_keywords, (split /\W+/, $format->[0]));
}
my $format_keywords = join('|', @format_keywords);
@$sorts = grep { $_->[0] =~ /$format_keywords/ } @$sorts;

$filters = getFiltersForClass($c, @records);

my @selected_filters;
if (defined $c->param("$name!filter")) {
Expand All @@ -67,10 +75,11 @@ sub scrollingRecordList ($options, @records) {
}

$formattedRecords = formatRecords(
$c,
$c->param("$name!format") || $options{default_format},
sortRecords(
$c->param("$name!sort") || $options{default_sort} || (@$sorts ? $sorts->[0][1] : ''),
filterRecords(\@selected_filters, @records)
filterRecords($c, $c->param("$name!filter_combine") // 0, \@selected_filters, @records)
)
);
}
Expand Down
37 changes: 37 additions & 0 deletions lib/WeBWorK/Utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ our @EXPORT_OK = qw(
is_jitar_problem_closed
jitar_problem_adjusted_status
jitar_problem_finished
prob_id_sort
role_and_above
fetchEmailRecipients
processEmailMessage
Expand Down Expand Up @@ -1849,6 +1850,42 @@ ID: foreach my $id (@problemIDs) {
return 1;
}

# Sorts problem ID's so that all just-in-time like ids are at the bottom
# of the list in order and other problems

sub prob_id_sort_comparator {

my @seqa = split(/\./, $a);
my @seqb = split(/\./, $b);

# go through problem number sequence
for (my $i = 0; $i <= $#seqa; $i++) {
# if at some point two numbers are different return the comparison.
# e.g. 2.1.3 vs 1.2.6
if ($seqa[$i] != $seqb[$i]) {
return $seqa[$i] <=> $seqb[$i];
}

# if all of the values are equal but b is shorter then it comes first
# i.e. 2.1.3 vs 2.1
if ($i == $#seqb) {
return 1;
}
}

# if all of the values are equal and a and b are the same length then equal
# otherwise a was shorter than b so a comes first.
if ($#seqa == $#seqb) {
return 0;
} else {
return -1;
}
}

sub prob_id_sort {
return sort prob_id_sort_comparator @_;
}

# Get the array of all permission levels at or above a given level
sub role_and_above {
my ($userRoles, $role) = @_;
Expand Down
Loading