Skip to content
Open
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
19 changes: 13 additions & 6 deletions macros/answers/answerHints.pl
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ =head2 AnswerHints

=item C<S<< checkCorrect => 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<S<< replaceMessage => 0 or 1 >>>
Expand All @@ -45,9 +47,10 @@ =head2 AnswerHints

=item C<S<< checkTypes => 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<S<< processPreview => 0 or 1 >>>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -172,6 +174,7 @@ sub AnswerHints {
}
}
}
$context->{answerHash} = $hash;
return $ans;
},
@_
Expand All @@ -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;
Expand All @@ -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;
}

Expand Down
Loading