Skip to content

Commit 6e0bcec

Browse files
committed
Remove the filtering of large courses on the course admin "Manage OTP Secrets" page.
This page loads quickly regardless of if these courses are filtered out. Furthermore the menus are generally responsive even when these large courses are included. The only case where something is a bit slow is in the case that on the "Copy Single Secret" tab the selected "Source Course ID" is one of these large courses. In that case if you click on the "Source User ID" it takes some time for the dropdown menu to appear and even then it has to be an astronomically large course for that to be slow (more than 20,000 users). However, even if the large courses are included as long as a large course is not selected the menus are quick. It is interesting that the multiple select elements on the "Copy Multiple Secrets" tab are still fast even with astronomically large courses. It is just the single select elements on the "Copy Single Secret" tab that experience a noticeable slowdown. In any case, the point is that there is no reason to filter these courses. Doing so just adds unnecessary steps for the user.
1 parent 688fd34 commit 6e0bcec

5 files changed

Lines changed: 9 additions & 38 deletions

File tree

lib/WeBWorK/ContentGenerator/CourseAdmin.pm

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,23 +2442,14 @@ sub do_save_lti_course_map ($c) {
24422442

24432443
# Form to copy or reset OTP secrets.
24442444
sub manage_otp_secrets_form ($c) {
2445-
my $courses = {};
2446-
my $dbs = {};
2447-
my $skipped_courses = [];
2448-
my $show_all_courses = $c->param('show_all_courses') || 0;
2445+
my $courses = {};
2446+
my $dbs = {};
24492447

24502448
# Create course data first, since it is used in all cases and initializes course db references.
24512449
for my $courseID (listCourses($c->ce)) {
24522450
my $ce = WeBWorK::CourseEnvironment->new({ courseName => $courseID });
2453-
$dbs->{$courseID} = WeBWorK::DB->new($ce->{dbLayouts}{ $ce->{dbLayoutName} });
2454-
2455-
# By default ignore courses larger than 200 users, as this can cause a large load building menus.
2456-
my @users = $dbs->{$courseID}->listUsers;
2457-
if ($show_all_courses || scalar @users < 200) {
2458-
$courses->{$courseID} = \@users;
2459-
} else {
2460-
push(@$skipped_courses, $courseID);
2461-
}
2451+
$dbs->{$courseID} = WeBWorK::DB->new($ce->{dbLayouts}{ $ce->{dbLayoutName} });
2452+
$courses->{$courseID} = [ $dbs->{$courseID}->listUsers ];
24622453
}
24632454

24642455
# Process the confirmed rest or copy actions here.
@@ -2500,11 +2491,7 @@ sub manage_otp_secrets_form ($c) {
25002491
}
25012492
}
25022493

2503-
return $c->include(
2504-
'ContentGenerator/CourseAdmin/manage_otp_secrets_form',
2505-
courses => $courses,
2506-
skipped_courses => $skipped_courses
2507-
);
2494+
return $c->include('ContentGenerator/CourseAdmin/manage_otp_secrets_form', courses => $courses);
25082495
}
25092496

25102497
# Deals with both single and multiple copy confirmation.

templates/ContentGenerator/CourseAdmin/copy_otp_secrets_confirm.html.ep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
</tbody>
4141
</table>
4242
</div>
43-
<%= $c->hidden_fields('subDisplay', 'show_all_courses') =%>
43+
<%= $c->hidden_fields('subDisplay') =%>
4444
% if ($total > 0) {
4545
% my $skipped = @$action_rows - $total;
4646
<%= content 'hidden-rows' %>

templates/ContentGenerator/CourseAdmin/manage_otp_secrets_form.html.ep

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,6 @@
88
%
99
<h2><%= maketext('Manage OTP Secrets') %> <%= $c->helpMacro('AdminManageOTPSecrets') %></h2>
1010
<%= form_for current_route, method => 'POST', begin =%>
11-
% if (@$skipped_courses) {
12-
<div class="mb-3">
13-
<div class="alert alert-warning mb-2">
14-
<%= maketext('The following large courses are not shown: [_1]', join(', ', @$skipped_courses)); =%>
15-
</div>
16-
<p>
17-
<%= submit_button maketext('Show All Courses'),
18-
name => 'show_all_courses', class => 'btn btn-primary' =%>
19-
</p>
20-
</div>
21-
% }
2211
<div>
2312
<ul class="nav nav-tabs mb-2" role="tablist">
2413
% for my $tab ('single', 'multiple', 'reset') {
@@ -147,7 +136,7 @@
147136
disabled => undef,
148137
selected => undef,
149138
],
150-
sort (@course_keys, @$skipped_courses)
139+
sort @course_keys
151140
],
152141
id => 'destMultipleCourseID',
153142
class => 'form-select',
@@ -195,7 +184,7 @@
195184
</div>
196185
</div>
197186
</div>
198-
<%= $c->hidden_fields('subDisplay', 'show_all_courses') =%>
187+
<%= $c->hidden_fields('subDisplay') =%>
199188
<%= hidden_field action => $active_tab, id => 'current_action' =%>
200189
<div class="mb-3">
201190
<%= submit_button $active_tab eq 'single'

templates/ContentGenerator/CourseAdmin/reset_otp_secrets_confirm.html.ep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</tbody>
2929
</table>
3030
</div>
31-
<%= $c->hidden_fields('subDisplay', 'show_all_courses', 'sourceResetCourseID') =%>
31+
<%= $c->hidden_fields('subDisplay', 'sourceResetCourseID') =%>
3232
% if ($total > 0) {
3333
% my $skipped = @$action_rows - $total;
3434
<%= content 'hidden-rows' %>

templates/HelpFiles/AdminManageOTPSecrets.html.ep

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,3 @@
3434
<%= maketext('If resetting secrets, choose a source course ID, then choose one (or more) users whose secrets '
3535
. 'will be reset. Note, the user(s) will have to setup two factor authentication afterwards.') =%>
3636
</p>
37-
<p class="mb-0">
38-
<%= maketext('By default, courses larger than 200 users will not be shown, as this can cause extra CPU usage '
39-
. 'when generating the user menus. If any large course is skipped, a message will inform you of which '
40-
. 'courses were skipped, and a button to show all courses can be used to include those courses.') =%>
41-
</p>

0 commit comments

Comments
 (0)