From 38d16c4b8da88217727137cc3656c3ee5b64049a Mon Sep 17 00:00:00 2001 From: Jaimos Skriletz Date: Thu, 8 Feb 2024 10:31:47 -0700 Subject: [PATCH] Add all/selected action scope back to sets manager. --- .../Instructor/ProblemSetList.pm | 30 +++++++++++++++---- .../ProblemSetList/edit_form.html.ep | 9 +++++- .../ProblemSetList/export_form.html.ep | 10 ++++++- .../ProblemSetList/publish_form.html.ep | 13 +++++++- .../ProblemSetList/score_form.html.ep | 10 ++++++- 5 files changed, 62 insertions(+), 10 deletions(-) diff --git a/lib/WeBWorK/ContentGenerator/Instructor/ProblemSetList.pm b/lib/WeBWorK/ContentGenerator/Instructor/ProblemSetList.pm index 4bc85771e5..7b2e8dafba 100644 --- a/lib/WeBWorK/ContentGenerator/Instructor/ProblemSetList.pm +++ b/lib/WeBWorK/ContentGenerator/Instructor/ProblemSetList.pm @@ -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; @@ -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.')); @@ -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) { diff --git a/templates/ContentGenerator/Instructor/ProblemSetList/edit_form.html.ep b/templates/ContentGenerator/Instructor/ProblemSetList/edit_form.html.ep index f40a42039d..b163bd3821 100644 --- a/templates/ContentGenerator/Instructor/ProblemSetList/edit_form.html.ep +++ b/templates/ContentGenerator/Instructor/ProblemSetList/edit_form.html.ep @@ -1,3 +1,10 @@
-

<%= maketext('Select sets to edit.') =%>

+ <%= label_for edit_select => maketext('Edit which sets?'), class => 'col-form-label col-form-label-sm 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' =%> +
diff --git a/templates/ContentGenerator/Instructor/ProblemSetList/export_form.html.ep b/templates/ContentGenerator/Instructor/ProblemSetList/export_form.html.ep index 2e0faf44b0..38e28b5d2e 100644 --- a/templates/ContentGenerator/Instructor/ProblemSetList/export_form.html.ep +++ b/templates/ContentGenerator/Instructor/ProblemSetList/export_form.html.ep @@ -1,3 +1,11 @@
-

<%= maketext('Select sets to export.') =%>

+ <%= label_for export_select => maketext('Prepare which sets for export?'), + class => 'col-form-label col-form-label-sm 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' =%> +
diff --git a/templates/ContentGenerator/Instructor/ProblemSetList/publish_form.html.ep b/templates/ContentGenerator/Instructor/ProblemSetList/publish_form.html.ep index 31db2466f7..5f91cc3b95 100644 --- a/templates/ContentGenerator/Instructor/ProblemSetList/publish_form.html.ep +++ b/templates/ContentGenerator/Instructor/ProblemSetList/publish_form.html.ep @@ -1,6 +1,17 @@
- <%= 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' =%> +
+ <%= 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' =%> +
+
+
+ <%= 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' =%>
<%= select_field 'action.publish.value' => [ diff --git a/templates/ContentGenerator/Instructor/ProblemSetList/score_form.html.ep b/templates/ContentGenerator/Instructor/ProblemSetList/score_form.html.ep index ca255f23b0..1cdb51cac3 100644 --- a/templates/ContentGenerator/Instructor/ProblemSetList/score_form.html.ep +++ b/templates/ContentGenerator/Instructor/ProblemSetList/score_form.html.ep @@ -1,3 +1,11 @@
-

<%= maketext('Select sets to score.') =%>

+ <%= label_for score_select => maketext('Score which sets?'), + class => 'col-form-label col-form-label-sm 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' =%> +