From 697c8921d8b45baabf6bc608be7d3f0c14520853 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Fri, 18 Sep 2026 16:27:50 -0500 Subject: [PATCH] Fix some issues with the list handling for MultiAnswer and RadioMultiAnswer. There is a check in both macros that sets the `checkTypes` value to be 'compatible' when the default checker is used and `checkTypes` is not 'exact'. However, 'exact' is not a valid value ever. That is supposed to be 'equal'. Also in the `perform_check` method for a `RadioMultiAnswer` it should not return when the answer hash `ans_message` is set and `checkTypes` is `compatible`. For a `MultiAnswer` object it is already this way. This means that if an entry in a list answer is incorrect, the default or custom checker will not be called. The default checker will return 0 in this case (with a minor tweak to ensure the score is 1 instead of just nonzero that was added), but a custom checker might want to score this case and give partial credit. --- macros/parsers/parserMultiAnswer.pl | 2 +- macros/parsers/parserRadioMultiAnswer.pl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/macros/parsers/parserMultiAnswer.pl b/macros/parsers/parserMultiAnswer.pl index ab8c1ed3a0..5283fde157 100644 --- a/macros/parsers/parserMultiAnswer.pl +++ b/macros/parsers/parserMultiAnswer.pl @@ -95,7 +95,7 @@ sub cmp { } return 1; }; - $self->{checkTypes} = 'compatible' if $self->{checkTypes} && $self->{checkTypes} ne 'exact'; + $self->{checkTypes} = 'compatible' if $self->{checkTypes} && $self->{checkTypes} ne 'equal'; } if ($self->{allowBlankAnswers}) { diff --git a/macros/parsers/parserRadioMultiAnswer.pl b/macros/parsers/parserRadioMultiAnswer.pl index ae9d4b2966..073ead63b1 100644 --- a/macros/parsers/parserRadioMultiAnswer.pl +++ b/macros/parsers/parserRadioMultiAnswer.pl @@ -359,12 +359,12 @@ sub cmp { return 0 if ($correct->[0] != $student->[0]); for (0 .. $#{ $correct->[ $correct->[0] ] }) { - return 0 unless $self->{ans}[ $correct->[0] - 1 ][$_]{score}; + return 0 unless $self->{ans}[ $correct->[0] - 1 ][$_]{score} == 1; } return 1; }; - $self->{checkTypes} = 'compatible' if $self->{checkTypes} && $self->{checkTypes} ne 'exact'; + $self->{checkTypes} = 'compatible' if $self->{checkTypes} && $self->{checkTypes} ne 'equal'; } if ($self->{allowBlankAnswers}) { @@ -559,7 +559,7 @@ sub perform_check { push(@part_student, $ans->{student_value}); # Only check types for the student's selected part. next if $student[0] != $part_index; - return if $ans->{ans_message} ne '' || !defined $ans->{student_value}; + return if ($checkTypes ne 'compatible' && $ans->{ans_message}) || !defined $ans->{student_value}; return if $checkTypes eq 'equal' && $ans->{student_value}->type ne $ans->{correct_value}->type