Skip to content

Commit

Permalink
only sort visibleUsers
Browse files Browse the repository at this point in the history
cleanup
  • Loading branch information
drdrew42 committed Feb 23, 2023
1 parent 0cb2413 commit 1f9c84d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 4 additions & 3 deletions lib/WeBWorK/ContentGenerator/Instructor/UserList.pm
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ sub pre_header_initialize ($c) {
$c->{allUserIDs} = [ keys %allUsers ];
$c->{sortedUserIDs} = [
map { $_->user_id }
sort { &$primarySortSub || &$secondarySortSub || &$ternarySortSub } (values %allUsers)
sort { &$primarySortSub || &$secondarySortSub || &$ternarySortSub }
grep { $c->{visibleUserIDs}{ $_->user_id } } (values %allUsers)
];

return;
Expand Down Expand Up @@ -561,7 +562,7 @@ sub save_password_handler ($c) {
}

if (defined $c->param('prev_visible_users')) {
$c->{visibleUserIDs} = $c->every_param('prev_visible_users');
$c->{visibleUserIDs} = { map { $_ => 1 } @{ $c->every_param('prev_visible_users') } };
} elsif (defined $c->param('no_prev_visible_users')) {
$c->{visibleUserIDs} = {};
}
Expand Down Expand Up @@ -611,7 +612,7 @@ sub importUsersFromCSV ($c, $fileName, $createNew, $replaceExisting, @replaceLis
my $db = $c->db;
my $dir = $ce->{courseDirs}->{templates};
my $user = $c->param('user');
my $perm = $db->getPermissionLevel($user)->permission;
my $perm = $c->{userPermission};

die $c->maketext("illegal character in input: '/'") if $fileName =~ m|/|;
die $c->maketext("won't be able to read from file [_1]/[_2]: does it exist? is it readable?", $dir, $fileName)
Expand Down
4 changes: 2 additions & 2 deletions templates/ContentGenerator/Instructor/UserList.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
%
<%= form_for current_route, method => 'POST', name => 'userlist', id => 'user-list-form', class => 'font-sm', begin =%>
<%= $c->hidden_authen_fields =%>
% if (scalar(keys %{ $c->{visibleUserIDs} })) {
% if (keys %{ $c->{visibleUserIDs} }) {
% for (keys %{ $c->{visibleUserIDs} }) {
<%= hidden_field visible_users => $_ =%>
% }
% } else {
<%= hidden_field no_visible_users => '1' =%>
% }
% if (scalar(keys %{ $c->{prevVisibleUserIDs} })) {
% if (keys %{ $c->{prevVisibleUserIDs} }) {
% for (keys %{ $c->{prevVisibleUserIDs} }) {
<%= hidden_field prev_visible_users => $_ =%>
% }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,19 @@
</tr>
</thead>
<tbody class="table-group-divider">
% for (grep { $c->{visibleUserIDs}{$_} } @{ $c->{sortedUserIDs} }) {
% for (@{ $c->{sortedUserIDs} }) {
<%= include 'ContentGenerator/Instructor/UserList/user_row',
user => $c->{allUsers}{$_}, userSelected => exists $c->{selectedUserIDs}{$_}, editable => exists $c->{userIsEditable}{$_} =%>
user => $c->{allUsers}{$_},
userSelected => exists $c->{selectedUserIDs}{$_},
editable => exists $c->{userIsEditable}{$_}
=%>
% }
</tbody>
</table>
</div>
%
% # If there are no users shown print message.
% unless (scalar(keys %{ $c->{visibleUserIDs} })) {
% unless (scalar(@{ $c->{sortedUserIDs} })) {
<p>
<i>
<%= maketext('No students shown. Choose one of the options above to list the students in the course.') =%>
Expand Down

0 comments on commit 1f9c84d

Please sign in to comment.