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 authored and somiaj committed Mar 2, 2024
1 parent f1b088e commit 49f9ea8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
5 changes: 0 additions & 5 deletions htdocs/js/AchievementList/achievementlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
const filter_select = document.getElementById('filter_select');
const filter = filter_select?.value || '';
const filter_text = document.getElementById('filter_text');
const filter_category = document.getElementById('filter_category');
if (filter === 'selected' && !is_achievement_selected()) {
e.preventDefault();
e.stopPropagation();
Expand All @@ -72,10 +71,6 @@
e.preventDefault();
e.stopPropagation();
show_errors(['filter_text_err_msg'], [filter_select, filter_text]);
} else if (filter === 'match_category' && filter_category?.value === '') {
e.preventDefault();
e.stopPropagation();
show_errors(['filter_category_err_msg'], [filter_select, filter_category]);
}
} else if (['edit', 'assign', 'export', 'score'].includes(action)) {
const action_select = document.getElementById(`${action}_select`);
Expand Down
5 changes: 5 additions & 0 deletions lib/WeBWorK/DB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,11 @@ sub getAchievements {
return $self->{achievement}->gets(map { [$_] } @achievementIDs);
}

sub getAchievementCategories {
my ($self) = shift->checkArgs(\@_);
return map {@$_} $self->{achievement}->get_fields_where("DISTINCT category", undef, "category");
}

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 49f9ea8

Please sign in to comment.