Skip to content

Commit

Permalink
Merge pull request #993 from somiaj/fix-ans-score-hotfix
Browse files Browse the repository at this point in the history
[Hotfix] Ensure a false score is saved as 0 in AnswerHash.
  • Loading branch information
pstaabp authored Jan 24, 2024
2 parents daff8af + 3b42928 commit 9cefdf9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/AnswerHash.pm
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ sub input { #$rh_ans->input('foo') is a synonym for $rh_ans->{student_ans}='f
sub score {
my $self = shift;
my $score = shift;
$self->{score} = $score if defined($score);
$self->{score} = $score || 0 if defined($score);
$self->{score};
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Value/AnswerChecker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,7 @@ sub cmp_list_compare {
#
# Check for empty lists
#
if (scalar(@correct) == 0) { $ans->score($m == 0); return }
if (scalar(@correct) == 0) { $ans->score($m == 0 ? 1 : 0); return }

#
# Loop through student answers looking for correct ones
Expand Down

0 comments on commit 9cefdf9

Please sign in to comment.