Skip to content

Commit

Permalink
change achievement categrory selection to dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Jordan committed Feb 29, 2024
1 parent b3ecaa9 commit 6cc78ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions lib/WeBWorK/DB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,12 @@ sub getAchievements {
return $self->{achievement}->gets(map { [$_] } @achievementIDs);
}

sub getAchievementCategories {
my ($self) = shift->checkArgs(\@_);
my %categories = map { $_->category => '' } ($self->getAchievements($self->listAchievements));
return sort keys %categories;
}

sub addAchievement {
my ($self, $Achievement) = shift->checkArgs(\@_, qw/REC:achievement/);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@
<div id="filter_text_err_msg" class="alert alert-danger p-1 mb-2 d-inline-flex d-none">
<%= maketext('Please enter a list of IDs to match.') %>
</div>
% my @categories = $c->db->getAchievementCategories;
% for (@categories) {
% $_ = [$_ => $_];
% }
<div id="filter_category_elements" class="row mb-2">
<%= label_for 'filter_category', class => 'col-form-label col-form-label-sm col-sm-auto', begin =%>
<%= maketext('Match on which category? (enter in exact match)') =%>
<span class="required-field">*</span>
<%= maketext('Match on which category?') =%>
<% end =%>
<div class="col-auto">
<%= text_field 'action.filter.category' => '', id => 'filter_category', 'aria-required' => 'true',
class => 'form-control form-control-sm', dir => 'ltr' =%>
<%= select_field 'action.filter.category' => \@categories,
id => 'filter_category', class => 'form-select form-select-sm' =%>
</div>
</div>
<div id="filter_category_err_msg" class="alert alert-danger p-1 mb-2 d-inline-flex d-none">
<%= maketext('Please enter a category to match.') %>
</div>
</div>

0 comments on commit 6cc78ce

Please sign in to comment.