From 4d3f77edd6d62668d1f7fb053b2eb6dd3108fc92 Mon Sep 17 00:00:00 2001 From: Jaimos Skriletz Date: Mon, 19 Feb 2024 08:44:16 -0700 Subject: [PATCH] Fixes to achievement filter. Fix text showing disabled achievements. Fix text when no achievements are found in the filter, but the course has achievements. Fix a bug where export/edit all achievements didn't show all achievements if they were previously filtered. This is done by adding a variable to show all achievements so any previous filter remains unchanged. --- .../ContentGenerator/Instructor/AchievementList.pm | 13 +++++++++---- .../AchievementList/default_table.html.ep | 6 +++++- .../Instructor/AchievementList/edit_table.html.ep | 6 +++++- .../Instructor/AchievementList/export_table.html.ep | 6 +++++- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/lib/WeBWorK/ContentGenerator/Instructor/AchievementList.pm b/lib/WeBWorK/ContentGenerator/Instructor/AchievementList.pm index 57a4360f4f..df13f4423d 100644 --- a/lib/WeBWorK/ContentGenerator/Instructor/AchievementList.pm +++ b/lib/WeBWorK/ContentGenerator/Instructor/AchievementList.pm @@ -144,7 +144,10 @@ sub initialize ($c) { $c->stash->{axpList} = [ $c->getAxpList ] unless $c->{editMode} || $c->{exportMode}; # Get and sort achievements. Achievements are sorted by in the order they are evaluated. - $c->stash->{achievements} = [ sortAchievements($c->db->getAchievements(@{ $c->{visibleAchievementIDs} })) ]; + $c->stash->{achievements} = + $c->{showAllAchievements} + ? [ sortAchievements($c->db->getAchievements(@{ $c->{allAchievementIDs} })) ] + : [ sortAchievements($c->db->getAchievements(@{ $c->{visibleAchievementIDs} })) ]; return; } @@ -182,7 +185,7 @@ sub filter_handler ($c) { $result = $c->maketext('Showing enabled achievements.'); $c->{visibleAchievementIDs} = [ map { $_->[0] } $db->listAchievementsWhere({ enabled => 1 }) ]; } elsif ($scope eq 'disabled') { - $result = $c->maketext('Showing enabled achievements.'); + $result = $c->maketext('Showing disabled achievements.'); $c->{visibleAchievementIDs} = [ map { $_->[0] } $db->listAchievementsWhere({ enabled => 0 }) ]; } @@ -196,7 +199,8 @@ sub edit_handler ($c) { my $scope = $c->param('action.edit.scope'); if ($scope eq "all") { $c->{selectedAchievementIDs} = $c->{allAchievementIDs}; - $result = $c->maketext('Editing all achievements.'); + $result = $c->maketext('Editing all achievements.'); + $c->{showAllAchievements} = 1; } elsif ($scope eq "selected") { $result = $c->maketext('Editing selected achievements.'); } @@ -498,8 +502,9 @@ sub export_handler ($c) { my $scope = $c->param('action.export.scope'); if ($scope eq "all") { - $result = $c->maketext('Exporting all achievements.'); + $result = $c->maketext('Exporting all achievements.'); $c->{selectedAchievementIDs} = $c->{allAchievementIDs}; + $c->{showAllAchievements} = 1; } else { $result = $c->maketext('Exporting selected achievements.'); $c->{selectedAchievementIDs} = [ $c->param('selected_achievements') ]; diff --git a/templates/ContentGenerator/Instructor/AchievementList/default_table.html.ep b/templates/ContentGenerator/Instructor/AchievementList/default_table.html.ep index 6c5aaadf43..fb1ccf9b33 100644 --- a/templates/ContentGenerator/Instructor/AchievementList/default_table.html.ep +++ b/templates/ContentGenerator/Instructor/AchievementList/default_table.html.ep @@ -85,5 +85,9 @@ % % unless (@$achievements) { -

<%= maketext('No achievements shown. Create an achievement!') %>

+ % if (@{ $c->{allAchievementIDs} }) { +

<%= maketext('No achievements shown. Use the filter above to list achievements.') %>

+ % } else { +

<%= maketext('No course achievements. Create or import achievements above.') %>

+ % } % } diff --git a/templates/ContentGenerator/Instructor/AchievementList/edit_table.html.ep b/templates/ContentGenerator/Instructor/AchievementList/edit_table.html.ep index 587b47a29f..0bb0bf1d78 100644 --- a/templates/ContentGenerator/Instructor/AchievementList/edit_table.html.ep +++ b/templates/ContentGenerator/Instructor/AchievementList/edit_table.html.ep @@ -74,6 +74,10 @@ % % unless (@$achievements) { -

<%= maketext('No achievements shown. Create an achievement!') %>

+ % if (@{ $c->{allAchievementIDs} }) { +

<%= maketext('No achievements selected to edit.') %>

+ % } else { +

<%= maketext('No course achievements to edit. Create or import achievements.') %>

+ % } % } % } diff --git a/templates/ContentGenerator/Instructor/AchievementList/export_table.html.ep b/templates/ContentGenerator/Instructor/AchievementList/export_table.html.ep index 928d788f4d..8cd66dac88 100644 --- a/templates/ContentGenerator/Instructor/AchievementList/export_table.html.ep +++ b/templates/ContentGenerator/Instructor/AchievementList/export_table.html.ep @@ -41,5 +41,9 @@ % % unless (@$achievements) { -

<%= maketext('No achievements shown. Create an achievement!') %>

+ % if (@{ $c->{allAchievementIDs} }) { +

<%= maketext('No achievements selected to export.') %>

+ % } else { +

<%= maketext('No course achievements to export. Create or import achievements.') %>

+ % } % }