Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use reduced credit when checking if problem is correct in Grades table. #2584

Merged
Merged
Show file tree
Hide file tree
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
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
14 changes: 8 additions & 6 deletions lib/WeBWorK/Utils/Sets.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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) : '&nbsp;.&nbsp;');
push(@$problem_scores, $status || $problemRecord->attempted ? 100 * wwRound(2, $status) : '&nbsp;.&nbsp;');
push(@$problem_incorrect_attempts, $problemRecord->num_incorrect || 0);
}

Expand All @@ -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;
}
Expand Down Expand Up @@ -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.

Expand Down