Log Message:
-----------
Report bad function calls in student Formulas (e.g., roots of
negatives), which used to be silently marked as incorrect. This is
done during the post-processing phase by calling the formula's reduce
method, which will return an error if there are illegal function calls
(or other errors).
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.119
retrieving revision 1.120
diff -Llib/Value/AnswerChecker.pm -Llib/Value/AnswerChecker.pm -u -r1.119 -r1.120
--- lib/Value/AnswerChecker.pm
+++ lib/Value/AnswerChecker.pm
@@ -1624,7 +1624,7 @@
sub cmp_call_filter {
my $ans = shift; my $method = shift;
- return $ans->{correct_value}->$method($ans);
+ return $ans->{correct_value}->$method($ans,@_);
}
sub cmp_prefilter {
@@ -1681,8 +1681,10 @@
sub cmp_postprocess {
my $self = shift; my $ans = shift;
- return unless $ans->{score} == 0 && !$ans->{isPreview};
- return if $ans->{ans_message};
+ return unless $ans->{score} == 0;
+ eval {$ans->{student_formula}->reduce} if defined($ans->{student_formula}); # check for bad function calls
+ $self->cmp_error($ans) if $self->{context}{error}{flag}; # and report the error
+ return if $ans->{ans_message} || $ans->{isPreview};
if ($self->{domainMismatch} && $ans->{showDomainErrors}) {
$self->cmp_Error($ans,"The domain of your function doesn't match that of the correct answer");
return;
|