Skip to content

Commit

Permalink
Don't filter out include_in_stats to early.
Browse files Browse the repository at this point in the history
  It should still be possible to see the stats or progress of users
  not included in stats, as they should only be filtered out when
  computing stats for the whole class or showing progress for a
  single set. This moves the include_in_stats filter to a more
  appropriate time.
  • Loading branch information
somiaj committed Feb 15, 2024
1 parent abed71b commit 873760d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
14 changes: 8 additions & 6 deletions lib/WeBWorK/ContentGenerator/Instructor/Stats.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ sub initialize ($c) {
# Cache a list of all users except set level proctors and practice users, and restrict to the sections or
# recitations that are allowed for the user if such restrictions are defined. This list is sorted by last_name,
# then first_name, then user_id. This is used in multiple places in this module, and is guaranteed to be used at
# least once. So it is done here to prevent extra database access. Filter out users not included in stats.
# least once. So it is done here to prevent extra database access.
$c->{student_records} = [
grep { $ce->status_abbrev_has_behavior($_->status, 'include_in_stats') } $db->getUsersWhere(
$db->getUsersWhere(
{
user_id => [ -and => { not_like => 'set_id:%' }, { not_like => "$ce->{practiceUserPrefix}\%" } ],
$ce->{viewable_sections}{$user} || $ce->{viewable_recitations}{$user}
Expand Down Expand Up @@ -104,14 +104,16 @@ sub siblings ($c) {
# Apply the currently selected filter to the student records, and return a reference to the
# list of students and a reference to the array of section/recitation filters.
sub filter_students ($c) {
my $filter = $c->param('filter') || 'all';
my @students =
$filter eq 'all' ? @{ $c->{student_records} } : filterRecords($c, 0, [$filter], @{ $c->{student_records} });
my $ce = $c->ce;
my $filter = $c->param('filter') || 'all';
my @students = grep { $ce->status_abbrev_has_behavior($_->status, 'include_in_stats') } @{ $c->{student_records} };

# Change visible name of the first 'all' filter.
my $filters = getFiltersForClass($c, [ 'section', 'recitation' ], @{ $c->{student_records} });
my $filters = getFiltersForClass($c, [ 'section', 'recitation' ], @students);
$filters->[0][0] = $c->maketext('All students');

@students = filterRecords($c, 0, [$filter], @students) unless $filter eq 'all';

return (\@students, $filters);
}

Expand Down
15 changes: 8 additions & 7 deletions lib/WeBWorK/ContentGenerator/Instructor/StudentProgress.pm
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ sub initialize ($c) {
# Cache a list of all users except set level proctors and practice users, and restrict to the sections or
# recitations that are allowed for the user if such restrictions are defined. This list is sorted by last_name,
# then first_name, then user_id. This is used in multiple places in this module, and is guaranteed to be used at
# least once. So it is done here to prevent extra database access. Filter out users not included in stats.
# least once. So it is done here to prevent extra database access.
$c->{student_records} = [
grep { $ce->status_abbrev_has_behavior($_->status, 'include_in_stats') } $db->getUsersWhere(
$db->getUsersWhere(
{
user_id => [ -and => { not_like => 'set_id:%' }, { not_like => "$ce->{practiceUserPrefix}\%" } ],
$ce->{viewable_sections}{$user} || $ce->{viewable_recitations}{$user}
Expand Down Expand Up @@ -116,20 +116,21 @@ sub displaySets ($c) {
: (date => 0, testtime => 0, timeleft => 0, problems => 1, section => 1, recit => 1, login => 1);
my $showBestOnly = $setIsVersioned ? $c->param('show_best_only') : 0;

my $filter = $c->param('filter') || 'all';
# Only show students who are included in stats.
my @student_records =
$filter eq 'all' ? @{ $c->{student_records} } : filterRecords($c, 0, [$filter], @{ $c->{student_records} });
grep { $ce->status_abbrev_has_behavior($_->status, 'include_in_stats') } @{ $c->{student_records} };

# Change visible name of the first 'all' filter.
my $filters = getFiltersForClass($c, [ 'section', 'recitation' ], @{ $c->{student_records} });
my $filter = $c->param('filter') || 'all';
my $filters = getFiltersForClass($c, [ 'section', 'recitation' ], @student_records);
$filters->[0][0] = $c->maketext('All students');

@student_records = filterRecords($c, 0, [$filter], @student_records) unless $filter eq 'all';

my @score_list;
my @user_set_list;

for my $studentRecord (@student_records) {
next unless $ce->status_abbrev_has_behavior($studentRecord->status, 'include_in_stats');

my $studentName = $studentRecord->user_id;
my ($allSetVersionNames, $notAssignedSet) =
list_set_versions($db, $studentName, $c->stash('setID'), $setIsVersioned);
Expand Down

0 comments on commit 873760d

Please sign in to comment.