Skip to content

Commit

Permalink
Use reduced credit when checking if problem is correct in Grades table.
Browse files Browse the repository at this point in the history
Use compute_unreduced_grade to determine if a problem is correct or not
on the student's grade table to highlight correct problems.
  • Loading branch information
somiaj committed Nov 13, 2024
1 parent 73af292 commit d96dc80
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 6 additions & 4 deletions lib/WeBWorK/ContentGenerator/Grades.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

Expand All @@ -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(
Expand All @@ -344,7 +346,7 @@ sub displayStudentStats ($c, $studentID) {
$c->c(
$c->tag(
'span',
class => $score eq '100' ? 'correct' : $score eq '&nbsp;.&nbsp;' ? 'unattempted' : '',
class => $is_correct ? 'correct' : $score eq '&nbsp;.&nbsp;' ? 'unattempted' : '',
$c->b($score)
),
$c->tag('br'),
Expand Down
5 changes: 3 additions & 2 deletions lib/WeBWorK/Utils/Sets.pm
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ sub grade_set ($db, $set, $studentName, $setIsVersioned = 0, $wantProblemDetails
}

if (wantarray) {
return ($totalRight, $total, $problem_scores, $problem_incorrect_attempts);
return ($totalRight, $total, $problem_scores, $problem_incorrect_attempts, \@problemRecords);
} else {
return $total ? $totalRight / $total : 0;
}
Expand Down Expand Up @@ -309,7 +309,8 @@ 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.
for each problem, and a reference to an array of merged problem records are also
included in the returned list.
In scalar context this returns the percentage correct.
Expand Down

0 comments on commit d96dc80

Please sign in to comment.