Log Message:
-----------
Roll back Mike's change, since this can cause unwanted error messages
in list comparisons and other situations where the equality check
could compare different types of objects (for example) or where the
comparison could legitimately fail. We only want to report errors
here when the user-supplied checker code fails.
This change would cause errors to be reported, for example, when the
user (incorrectly) entered a vector one time and then a formula
(correctly) the next time. When the previous answer is checked against
the current one, this change would report an error rather than
silently ignoring the error, as it should.
Modified Files:
--------------
pg/lib/Value:
AnswerChecker.pm
Revision Data
-------------
Index: AnswerChecker.pm
===================================================================
RCS file: /webwork/cvs/system/pg/lib/Value/AnswerChecker.pm,v
retrieving revision 1.72
retrieving revision 1.73
diff -Llib/Value/AnswerChecker.pm -Llib/Value/AnswerChecker.pm -u -r1.72 -r1.73
--- lib/Value/AnswerChecker.pm
+++ lib/Value/AnswerChecker.pm
@@ -204,19 +204,14 @@
sub cmp_compare {
my $self = shift; my $other = shift; my $ans = shift; my $nth = shift || '';
- my $equal = undef;
- unless ( ref($ans->{checker}) eq 'CODE' ) {
- $equal = eval {$self == $other} ;
- } else {
- $equal = eval {&{$ans->{checker}}($self,$other,$ans,$nth,@_)};
- }
- if (!defined($equal) && $@ ne '' && ($$Value::context->{error}{flag} || $ans->{showAllErrors})) {
- $$Value::context->setError(["<I>An error occurred while checking your$nth answer:</I>\n".
- '<DIV STYLE="margin-left:1em">%s</DIV>',$@],'',undef,undef,$CMP_ERROR);
- warn "Please inform your instructor that an error occurred while checking your answer";
+ return eval {$self == $other} unless ref($ans->{checker}) eq 'CODE';
+ my $equal = eval {&{$ans->{checker}}($self,$other,$ans,$nth,@_)};
+ if (!defined($equal) && $@ ne '' && (!$$Value::context->{error}{flag} || $ans->{showAllErrors})) {
+ $$Value::context->setError(["<I>An error occurred while checking your$nth answer:</I>\n".
+ '<DIV STYLE="margin-left:1em">%s</DIV>',$@],'',undef,undef,$CMP_ERROR);
+ warn "Please inform your instructor that an error occurred while checking your answer";
}
return $equal;
-
}
sub cmp_list_compare {Value::List::cmp_list_compare(@_)}
|