Skip to content

Commit 9cefdf9

Browse files
authored
Merge pull request #993 from somiaj/fix-ans-score-hotfix
[Hotfix] Ensure a false score is saved as 0 in AnswerHash.
2 parents daff8af + 3b42928 commit 9cefdf9

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/AnswerHash.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ sub input { #$rh_ans->input('foo') is a synonym for $rh_ans->{student_ans}='f
252252
sub score {
253253
my $self = shift;
254254
my $score = shift;
255-
$self->{score} = $score if defined($score);
255+
$self->{score} = $score || 0 if defined($score);
256256
$self->{score};
257257
}
258258

lib/Value/AnswerChecker.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,7 @@ sub cmp_list_compare {
16961696
#
16971697
# Check for empty lists
16981698
#
1699-
if (scalar(@correct) == 0) { $ans->score($m == 0); return }
1699+
if (scalar(@correct) == 0) { $ans->score($m == 0 ? 1 : 0); return }
17001700

17011701
#
17021702
# Loop through student answers looking for correct ones

0 commit comments

Comments
 (0)