Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions lib/WeBWorK/ContentGenerator/Grades.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WeBWorK::ContentGenerator::Grades - Display statistics by user.

=cut

use WeBWorK::Utils qw(wwRound);
use WeBWorK::Utils qw(wwRound max);
use WeBWorK::Utils::DateTime qw(after);
use WeBWorK::Utils::JITAR qw(jitar_id_to_seq);
use WeBWorK::Utils::Sets qw(grade_set format_set_name_display);
Expand Down Expand Up @@ -181,21 +181,21 @@ sub displayStudentStats ($c, $studentID) {
my $courseTotalRight = 0;

for my $setID (@allSetIDs) {
my $set = $db->getGlobalSet($setID);
my $num_of_problems;
# For jitar sets we only display grades for top level problems, so we need to count how many there are.
my $set = $db->getGlobalSet($setID);
my $max_problem_id = 0;
# For jitar sets we only display grades for top level problems, so we need to filter.
if ($set && $set->assignment_type() eq 'jitar') {
my @problemIDs = $db->listGlobalProblems($setID);
for my $problemID (@problemIDs) {
my @seq = jitar_id_to_seq($problemID);
$num_of_problems++ if ($#seq == 0);
$max_problem_id = $seq[0] if ($#seq == 0 && $seq[0] > $max_problem_id);
}
} else {
# For other sets we just count the number of problems.
$num_of_problems = $db->countGlobalProblems($setID);
# For other sets we just get the largest problem ID.
$max_problem_id = max($db->listGlobalProblems($setID));
Comment on lines +194 to +195
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is going to need to be a special case for tests that does what the previous else case did for those. For example, if a test has numbers 1, 3, 5, then this will get 5 for the largest problem id. However, the problems will be displayed under numbers 1, 2, and 3 (on both the grades page and in the test). So this may add extra problem numbers that are shown even though there may not be any sets with those problem numbers.

}
$max_problems =
$set && after($set->open_date) && $max_problems < $num_of_problems ? $num_of_problems : $max_problems;
$set && after($set->open_date) && $max_problems < $max_problem_id ? $max_problem_id : $max_problems;
}

# Variables to help compute gateway scores.
Expand Down Expand Up @@ -320,9 +320,23 @@ sub displayStudentStats ($c, $studentID) {
$show_problem_scores = 0;
}

my @skipped;
for my $i (0 .. $max_problems - 1) {
my $score = defined $problem_scores->[$i] && $show_problem_scores ? $problem_scores->[$i] : '';
my $is_correct = $score =~ /^\d+$/ && compute_unreduced_score($ce, $problem_records->[$i], $set) == 1;
my $j;
if ($setIsVersioned) {
$j = $i;
} else {
$j = $problem_records->[$i]{problem_id} // 0;
if ($set && $set->assignment_type() eq 'jitar') {
my @seq = jitar_id_to_seq($j);
$j = $#seq == 0 ? $seq[0] : 0;
}
my @new_skipped = ($i + 1 .. $j - 1 - scalar @skipped);
push(@skipped, @new_skipped);
push(@html_prob_scores, ($c->tag('td', class => 'problem-data')) x scalar @new_skipped);
}
push(
@html_prob_scores,
$c->tag(
Expand All @@ -341,6 +355,7 @@ sub displayStudentStats ($c, $studentID) {
)->join('')
)
);
last if ($i + scalar @skipped == $max_problems - 1);
}

# Get percentage correct.
Expand Down