Skip to content

Commit

Permalink
Add a fallback sort to the problem set list (the Sets Manager)
Browse files Browse the repository at this point in the history
If the `set_id` field is neither the primary sort field nor the
secondary sort field, then it is added as the tertiary sort order
(always in ascending order).

This was suggested in #2507.
  • Loading branch information
drgrice1 committed Aug 13, 2024
1 parent 59dab44 commit fcabc7f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/WeBWorK/ContentGenerator/Instructor/ProblemSetList.pm
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,21 @@ sub initialize ($c) {

$c->stash->{formsToShow} = $c->{editMode} ? EDIT_FORMS() : $c->{exportMode} ? EXPORT_FORMS() : VIEW_FORMS();
$c->stash->{setDefList} = [ getDefList($ce) ] unless $c->{editMode} || $c->{exportMode};

# Get requested sets in the requested order.
$c->stash->{sets} = [
@{ $c->{visibleSetIDs} }
? $db->getGlobalSetsWhere({ set_id => $c->{visibleSetIDs} },
\("$c->{primarySortField} $c->{primarySortOrder}, $c->{secondarySortField} $c->{secondarySortOrder}"))
? $db->getGlobalSetsWhere(
{ set_id => $c->{visibleSetIDs} },
\(
"$c->{primarySortField} $c->{primarySortOrder}, "
. "$c->{secondarySortField} $c->{secondarySortOrder}"
. (
$c->{primarySortField} ne 'set_id'
&& $c->{secondarySortField} ne 'set_id' ? ', set_id ASC' : ''
)
)
)
: ()
];

Expand Down

0 comments on commit fcabc7f

Please sign in to comment.