From aa5d7fd4d484d7e260bbf1f95fa0356fafa0a136 Mon Sep 17 00:00:00 2001 From: Jaimos Skriletz Date: Sat, 28 Sep 2024 11:48:42 -0600 Subject: [PATCH 1/2] Use reduced credit when checking if problem is correct in Grades table. Use compute_unreduced_grade to determine if a problem is correct or not on the student's grade table to highlight correct problems. --- lib/WeBWorK/ContentGenerator/Grades.pm | 10 ++++++---- lib/WeBWorK/Utils/Sets.pm | 12 +++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/WeBWorK/ContentGenerator/Grades.pm b/lib/WeBWorK/ContentGenerator/Grades.pm index 6845193158..bc6881fa36 100644 --- a/lib/WeBWorK/ContentGenerator/Grades.pm +++ b/lib/WeBWorK/ContentGenerator/Grades.pm @@ -26,6 +26,7 @@ use WeBWorK::Utils qw(wwRound); 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); +use WeBWorK::Utils::ProblemProcessing qw(compute_unreduced_score); use WeBWorK::Localize; sub initialize ($c) { @@ -319,7 +320,7 @@ sub displayStudentStats ($c, $studentID) { next; } - my ($totalRight, $total, $problem_scores, $problem_incorrect_attempts) = + my ($totalRight, $total, $problem_scores, $problem_incorrect_attempts, $problem_records) = grade_set($db, $set, $studentID, $setIsVersioned, 1); $totalRight = wwRound(2, $totalRight); @@ -334,8 +335,9 @@ sub displayStudentStats ($c, $studentID) { $show_problem_scores = 0; } - for (my $i = 0; $i < $max_problems; ++$i) { - my $score = defined $problem_scores->[$i] && $show_problem_scores ? $problem_scores->[$i] : ''; + 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; push( @html_prob_scores, $c->tag( @@ -344,7 +346,7 @@ sub displayStudentStats ($c, $studentID) { $c->c( $c->tag( 'span', - class => $score eq '100' ? 'correct' : $score eq ' . ' ? 'unattempted' : '', + class => $is_correct ? 'correct' : $score eq ' . ' ? 'unattempted' : '', $c->b($score) ), $c->tag('br'), diff --git a/lib/WeBWorK/Utils/Sets.pm b/lib/WeBWorK/Utils/Sets.pm index 5c2d69c868..01ab657526 100644 --- a/lib/WeBWorK/Utils/Sets.pm +++ b/lib/WeBWorK/Utils/Sets.pm @@ -114,7 +114,8 @@ sub grade_set ($db, $set, $studentName, $setIsVersioned = 0, $wantProblemDetails } if (wantarray) { - return ($totalRight, $total, $problem_scores, $problem_incorrect_attempts); + return ($totalRight, $total, $wantProblemDetails ? ($problem_scores, $problem_incorrect_attempts) : (), + \@problemRecords); } else { return $total ? $totalRight / $total : 0; } @@ -306,10 +307,11 @@ The arguments C<$db>, C<$set>, and C<$studentName> are required. If C<$setIsVersioned> is true, then the given set is assumed to be a set version. In list context this returns a list containing the total number of correct -problems, and the total number of problems in the set. If -C<$wantProblemDetails> is true, then a reference to an array of the scores for -each problem, and a reference to the array of the number of incorrect attempts -for each problem are also included in the returned list. +problems, the total number of problems in the set, and a reference to an array +of merged user problem records from the set. If C<$wantProblemDetails> is true, +then a reference to an array of the scores for each problem, and a reference to +the array of the number of incorrect attempts for each problem are also included +in the returned list before the reference to the array of problem records. In scalar context this returns the percentage correct. From 1b766f8b79b9d33121aff534ac26b5ca8b8cd711 Mon Sep 17 00:00:00 2001 From: Jaimos Skriletz Date: Thu, 21 Nov 2024 16:57:02 -0700 Subject: [PATCH 2/2] Show non-zero status of unattempted problems in grades table. This fixes #2627. --- lib/WeBWorK/Utils/Sets.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/WeBWorK/Utils/Sets.pm b/lib/WeBWorK/Utils/Sets.pm index 01ab657526..d0193ddfba 100644 --- a/lib/WeBWorK/Utils/Sets.pm +++ b/lib/WeBWorK/Utils/Sets.pm @@ -103,7 +103,7 @@ sub grade_set ($db, $set, $studentName, $setIsVersioned = 0, $wantProblemDetails $status = 1 if $status > 1; if ($wantProblemDetails) { - push(@$problem_scores, $problemRecord->attempted ? 100 * wwRound(2, $status) : ' . '); + push(@$problem_scores, $status || $problemRecord->attempted ? 100 * wwRound(2, $status) : ' . '); push(@$problem_incorrect_attempts, $problemRecord->num_incorrect || 0); }