Skip to content

Commit 6f609fb

Browse files
committed
No longer share siblings template between Stats and StudentProgress.
1 parent 539a714 commit 6f609fb

File tree

4 files changed

+69
-48
lines changed

4 files changed

+69
-48
lines changed

lib/WeBWorK/ContentGenerator/Instructor/Stats.pm

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,6 @@ sub initialize ($c) {
2222
# Check permissions
2323
return unless $c->authz->hasPermissions($user, 'access_instructor_tools');
2424

25-
# Cache a list of all users except set level proctors and practice users, and restrict to the sections or
26-
# recitations that are allowed for the user if such restrictions are defined. This list is sorted by last_name,
27-
# then first_name, then user_id. This is used in multiple places in this module, and is guaranteed to be used at
28-
# least once. So it is done here to prevent extra database access.
29-
$c->{student_records} = [
30-
$db->getUsersWhere(
31-
{
32-
user_id => [ -and => { not_like => 'set_id:%' }, { not_like => "$ce->{practiceUserPrefix}\%" } ],
33-
$ce->{viewable_sections}{$user} || $ce->{viewable_recitations}{$user}
34-
? (
35-
-or => [
36-
$ce->{viewable_sections}{$user} ? (section => $ce->{viewable_sections}{$user}) : (),
37-
$ce->{viewable_recitations}{$user} ? (recitation => $ce->{viewable_recitations}{$user}) : ()
38-
]
39-
)
40-
: ()
41-
},
42-
[qw/last_name first_name user_id/]
43-
)
44-
];
45-
4625
if ($c->current_route =~ /^instructor_(set|problem)_statistics$/) {
4726
my $setRecord = $db->getGlobalSet($c->stash('setID'));
4827
return unless $setRecord;
@@ -55,6 +34,27 @@ sub initialize ($c) {
5534
return unless $problemRecord;
5635
$c->{problemRecord} = $problemRecord;
5736
}
37+
38+
# Cache a list of all users except set level proctors and practice users, and restrict to the sections
39+
# or recitations that are allowed for the user if such restrictions are defined. This list is sorted by
40+
# last_name, then first_name, then user_id. This is used in multiple places in this module, and is used
41+
# on every page except the main page, so it is done here to prevent extra database access.
42+
$c->{student_records} = [
43+
$db->getUsersWhere(
44+
{
45+
user_id => [ -and => { not_like => 'set_id:%' }, { not_like => "$ce->{practiceUserPrefix}\%" } ],
46+
$ce->{viewable_sections}{$user} || $ce->{viewable_recitations}{$user}
47+
? (
48+
-or => [
49+
$ce->{viewable_sections}{$user} ? (section => $ce->{viewable_sections}{$user}) : (),
50+
$ce->{viewable_recitations}{$user} ? (recitation => $ce->{viewable_recitations}{$user}) : ()
51+
]
52+
)
53+
: ()
54+
},
55+
[qw/last_name first_name user_id/]
56+
)
57+
];
5858
}
5959

6060
return;
@@ -79,8 +79,7 @@ sub page_title ($c) {
7979
}
8080

8181
sub siblings ($c) {
82-
# Stats and StudentProgress share this template.
83-
return $c->include('ContentGenerator/Instructor/Stats/siblings', header => $c->maketext('Statistics'));
82+
return $c->include('ContentGenerator/Instructor/Stats/siblings');
8483
}
8584

8685
# Apply the currently selected filter to the student records, and return a reference to the

lib/WeBWorK/ContentGenerator/Instructor/StudentProgress.pm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ sub page_title ($c) {
6868
}
6969

7070
sub siblings ($c) {
71-
# Stats and StudentProgress share this template.
72-
return $c->include('ContentGenerator/Instructor/Stats/siblings', header => $c->maketext('Student Progress'));
71+
return $c->include('ContentGenerator/Instructor/StudentProgress/siblings');
7372
}
7473

7574
# Display student progress table

templates/ContentGenerator/Instructor/Stats/siblings.html.ep

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
% # Note that this template is used by both WeBWorK::ContentGenerator::Instructor::Stats and
2-
% # WeBWorK::ContentGenerator::Instructor::StudentProgress.
3-
%
41
% use WeBWorK::Utils::JITAR qw(jitar_id_to_seq);
52
% use WeBWorK::Utils::Sets qw(format_set_name_display);
63
%
@@ -9,24 +6,8 @@
96
% }
107
%
118
<div class="info-box bg-light">
12-
<h2><%= $header %></h2>
13-
% if (current_route =~ /^instructor_user_/) {
14-
<ul class="nav flex-column problem-list">
15-
% for (@{ $c->{student_records} }) {
16-
<li class="nav-item">
17-
<%= tag 'a',
18-
$_->user_id eq $c->{studentID}
19-
? (class => 'nav-link active')
20-
: (
21-
href => $c->systemLink(url_for(current_route, userID => $_->user_id)),
22-
class => 'nav-link'
23-
), begin =%>
24-
<%= $_->last_name =%>, <%= $_->first_name %> (<%= $_->user_id %>)
25-
<% end =%>
26-
</li>
27-
% }
28-
</ul>
29-
% } elsif (current_route eq 'instructor_problem_statistics') {
9+
<h2><%= maketext('Statistics') %></h2>
10+
% if (current_route eq 'instructor_problem_statistics') {
3011
<ul class="nav flex-column problem-list">
3112
% for (map { $_->[1] } $db->listGlobalProblemsWhere({ set_id => stash->{setID} }, 'problem_id')) {
3213
<li class="nav-item">
@@ -53,8 +34,7 @@
5334
defined stash('setID') && $_ eq stash('setID') ? (class => 'nav-link active')
5435
: (
5536
href => $c->systemLink(
56-
url_for(current_route =~ s/instructor_(progress|statistics)/instructor_set_$1/r,
57-
setID => $_),
37+
url_for('instructor_set_statistics', setID => $_),
5838
params => param('filter') ? { filter => param('filter') } : {}
5939
),
6040
class => 'nav-link'
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
% use WeBWorK::Utils::Sets qw(format_set_name_display);
2+
%
3+
% unless ($authz->hasPermissions(param('user'), 'access_instructor_tools')) {
4+
% last;
5+
% }
6+
%
7+
<div class="info-box bg-light">
8+
<h2><%= maketext('Student Progress') %></h2>
9+
% if (current_route eq 'instructor_user_progress') {
10+
<ul class="nav flex-column problem-list">
11+
% for (@{ $c->{student_records} }) {
12+
<li class="nav-item">
13+
<%= tag 'a',
14+
$_->user_id eq $c->{studentID}
15+
? (class => 'nav-link active')
16+
: (
17+
href => $c->systemLink(url_for(current_route, userID => $_->user_id)),
18+
class => 'nav-link'
19+
), begin =%>
20+
<%= $_->last_name =%>, <%= $_->first_name %> (<%= $_->user_id %>)
21+
<% end =%>
22+
</li>
23+
% }
24+
</ul>
25+
% } else {
26+
<ul class="nav flex-column problem-list" dir="ltr">
27+
% for (map { $_->[0] } $db->listGlobalSetsWhere({}, 'set_id')) {
28+
<li class="nav-item">
29+
<%= tag 'a',
30+
defined stash('setID') && $_ eq stash('setID') ? (class => 'nav-link active')
31+
: (
32+
href => $c->systemLink(
33+
url_for('instructor_set_progress', setID => $_),
34+
params => param('filter') ? { filter => param('filter') } : {}
35+
),
36+
class => 'nav-link'
37+
),
38+
format_set_name_display($_) =%>
39+
</li>
40+
% }
41+
</ul>
42+
% }
43+
</div>

0 commit comments

Comments
 (0)