Skip to content

Commit

Permalink
Fixes to achievement filter.
Browse files Browse the repository at this point in the history
  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.
  • Loading branch information
somiaj committed Feb 24, 2024
1 parent 9480c5b commit 4d3f77e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
13 changes: 9 additions & 4 deletions lib/WeBWorK/ContentGenerator/Instructor/AchievementList.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 }) ];
}

Expand All @@ -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.');
}
Expand Down Expand Up @@ -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') ];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,9 @@
</div>
%
% unless (@$achievements) {
<p><i><%= maketext('No achievements shown. Create an achievement!') %></i></p>
% if (@{ $c->{allAchievementIDs} }) {
<p><em><%= maketext('No achievements shown. Use the filter above to list achievements.') %></em></p>
% } else {
<p><em><%= maketext('No course achievements. Create or import achievements above.') %></em></p>
% }
% }
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
</div>
%
% unless (@$achievements) {
<p><i><%= maketext('No achievements shown. Create an achievement!') %></i></p>
% if (@{ $c->{allAchievementIDs} }) {
<p><em><%= maketext('No achievements selected to edit.') %></em></p>
% } else {
<p><em><%= maketext('No course achievements to edit. Create or import achievements.') %></em></p>
% }
% }
% }
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,9 @@
</div>
%
% unless (@$achievements) {
<p><i><%= maketext('No achievements shown. Create an achievement!') %></i></p>
% if (@{ $c->{allAchievementIDs} }) {
<p><em><%= maketext('No achievements selected to export.') %></em></p>
% } else {
<p><em><%= maketext('No course achievements to export. Create or import achievements.') %></em></p>
% }
% }

0 comments on commit 4d3f77e

Please sign in to comment.