diff --git a/macros/answers/answerHints.pl b/macros/answers/answerHints.pl index e91327d5c5..bb4264dc37 100644 --- a/macros/answers/answerHints.pl +++ b/macros/answers/answerHints.pl @@ -32,8 +32,10 @@ =head2 AnswerHints =item C 0 or 1 >>> -1 means check for messages even -if the answer is correct. +In the list of incorrect answers to compare the student's answer with, 1 means +for each CODE reference incorrect answer, check the student's answer against +that CODE reference incorrect answer for messages even if the student answer is +correct. Default: 0 =item C 0 or 1 >>> @@ -45,9 +47,10 @@ =head2 AnswerHints =item C 0 or 1 >>> -1 means only perform the test -if the student answer is the -same type as the correct one. +In the list of incorrect answers to compare the student's answer with, 1 means +for each CODE reference incorrect answer, check the student's answer against +that CODE reference incorrect answer for messages only when the the student +answer the same type as the correct answer. Default: 1 =item C 0 or 1 >>> @@ -120,7 +123,6 @@ sub AnswerHints { my $hash = $context->{answerHash}; $context->{answerHash} = $ans; my $processPreview = $correct->getFlag('answerHintsProcessPreview', 0); - $context->{answerHash} = $hash; while (@_) { my $wrongList = shift; @@ -172,6 +174,7 @@ sub AnswerHints { } } } + $context->{answerHash} = $hash; return $ans; }, @_ @@ -191,6 +194,9 @@ sub Compare { $ans->{typeError} = 0; $ans->{ans_message} = $ans->{error_message} = ""; $ans->{score} = 0; + my $context = $self->context; + my $hash = $context->{answerHash}; + $context->{answerHash} = $ans; if ($self->address != $ans->{correct_value}->address) { $ans->{correct_ans} = $self->string; @@ -205,6 +211,7 @@ sub Compare { $self->cmp_preprocess($ans); $self->cmp_equal($ans); $self->cmp_postprocess($ans) if !$ans->{error_message} && !$ans->{typeError}; + $context->{answerHash} = $hash; return $ans->{score} >= 1; }