Skip to content

Commit

Permalink
Add all/selected action scope back to sets manager.
Browse files Browse the repository at this point in the history
  • Loading branch information
somiaj committed Feb 8, 2024
1 parent 7ac8b57 commit 38d16c4
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 10 deletions.
30 changes: 24 additions & 6 deletions lib/WeBWorK/ContentGenerator/Instructor/ProblemSetList.pm
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ sub pre_header_initialize ($c) {
$c->{totalUsers} = $db->countUsers;

if (defined $c->param('action') && $c->param('action') eq 'score' && $authz->hasPermissions($user, 'score_sets')) {
my @setsToScore = $c->param('selected_sets');
my $scope = $c->param('action.score.scope');
my @setsToScore = $scope eq 'all' ? @{ $c->{allSetIDs} } : $c->param('selected_sets');

return unless @setsToScore;

Expand Down Expand Up @@ -361,21 +362,34 @@ sub sort_handler ($c) {
}

sub edit_handler ($c) {
$c->{visibleSetIDs} = [ $c->param('selected_sets') ];
$c->{editMode} = 1;
my $scope = $c->param('action.edit.scope');
$c->{editMode} = 1;

if ($scope eq 'all') {
$c->{visibleSetIDs} = $c->{allSetIDs};
return (1, $c->maketext('Editing all sets.'));
}

$c->{visibleSetIDs} = [ $c->param('selected_sets') ];
return (1, $c->maketext('Editing selected sets.'));
}

sub publish_handler ($c) {
my $db = $c->db;
my $value = $c->param('action.publish.value');
my @setIDs = $c->param('selected_sets');
my $scope = $c->param('action.publish.scope');
my @setIDs = $scope eq 'all' ? @{ $c->{allSetIDs} } : $c->param('selected_sets');

# Can we use UPDATE here, instead of fetch/change/store?
my @sets = $db->getGlobalSets(@setIDs);
map { $_->visible($value); $db->putGlobalSet($_); } @sets;

if ($scope eq 'all') {
return $value
? (1, $c->maketext('All sets made visible for all students.'))
: (1, $c->maketext('All sets hidden from all students.'));
}

return $value
? (1, $c->maketext('All selected sets made visible for all students.'))
: (1, $c->maketext('All selected sets hidden from all students.'));
Expand Down Expand Up @@ -540,10 +554,14 @@ sub import_handler ($c) {

# this does not actually export any files, rather it sends us to a new page in order to export the files
sub export_handler ($c) {
$c->{selectedSetIDs} = $c->{visibleSetIDs} = [ $c->param('selected_sets') ];
my $scope = $c->param('action.export.scope');
$c->{selectedSetIDs} = $scope eq 'all' ? $c->{allSetIDs} : [ $c->param('selected_sets') ];
$c->{visibleSetIDs} = $c->{selectedSetIDs};
$c->{exportMode} = 1;

return (1, $c->maketext('Selected sets were exported.'));
return $scope eq 'all'
? (1, $c->maketext('All sets were exported.'))
: (1, $c->maketext('Selected sets were exported.'));
}

sub cancel_export_handler ($c) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<div class="row mb-2">
<p><%= maketext('Select sets to edit.') =%></p>
<%= label_for edit_select => maketext('Edit which sets?'), class => 'col-form-label col-form-label-sm col-auto' =%>
<div class="col-auto">
<%= select_field 'action.edit.scope' => [
[ maketext('all sets') => 'all' ],
[ maketext('selected sets') => 'selected', selected => undef ]
],
id => 'edit_select', class => 'form-select form-select-sm' =%>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<div class="row mb-2">
<p><%= maketext('Select sets to export.') =%></p>
<%= label_for export_select => maketext('Prepare which sets for export?'),
class => 'col-form-label col-form-label-sm col-auto' =%>
<div class="col-auto">
<%= select_field 'action.export.scope' => [
[ maketext('all sets') => 'all' ],
[ maketext('selected sets') => 'selected', selected => undef ],
],
id => 'export_select', class => 'form-select form-select-sm' =%>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<div>
<div class="row mb-2">
<%= label_for publish_visibility_select => maketext('Choose visibility of the selected sets') . ':',
<%= label_for publish_filter_select => maketext('Choose which sets to be affected') . ':',
class => 'col-form-label col-form-label-sm col-sm-auto' =%>
<div class="col-auto">
<%= select_field 'action.publish.scope' => [
[ maketext('all sets') => 'all' ],
[ maketext('selected sets') => 'selected', selected => undef ]
],
id => 'publish_filter_select', class => 'form-select form-select-sm' =%>
</div>
</div>
<div class="row mb-2">
<%= label_for publish_visibility_select => maketext('Choose visibility of the sets to be affected') . ':',
class => 'col-form-label col-form-label-sm col-sm-auto' =%>
<div class="col-auto">
<%= select_field 'action.publish.value' => [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<div class="row mb-2">
<p><%= maketext('Select sets to score.') =%></p>
<%= label_for score_select => maketext('Score which sets?'),
class => 'col-form-label col-form-label-sm col-auto' =%>
<div class="col-auto">
<%= select_field 'action.score.scope' => [
[ maketext('all sets') => 'all' ],
[ maketext('selected sets') => 'selected', selected => undef ]
],
id => 'score_select', class => 'form-select form-select-sm' =%>
</div>
</div>

0 comments on commit 38d16c4

Please sign in to comment.