From: dpvc v. a. <we...@ma...> - 2008-09-12 21:38:20
|
Log Message: ----------- BACKPORT: Trap errors when comparing to student answer while trying to determine the correct error message. This prevents extraneous warnings that would confuse the student (and instructor). Tags: ---- rel-2-4-patches Modified Files: -------------- pg/macros: parserFormulaUpToConstant.pl Revision Data ------------- Index: parserFormulaUpToConstant.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserFormulaUpToConstant.pl,v retrieving revision 1.11.2.1 retrieving revision 1.11.2.1.2.1 diff -Lmacros/parserFormulaUpToConstant.pl -Lmacros/parserFormulaUpToConstant.pl -u -r1.11.2.1 -r1.11.2.1.2.1 --- macros/parserFormulaUpToConstant.pl +++ macros/parserFormulaUpToConstant.pl @@ -175,9 +175,9 @@ # # Compare with adaptive parameters to see if $l + n0 C = $r for some n0. # - $main::_cmp_ = sub {return $l->{adapt} == $r}; # a closure to access local variables - my $equal = main::PG_restricted_eval('&$_cmp_'); # prevents errors with large adaptive parameters - delete $main::{_cmp_}; # remove temprary function + $main::{_cmp_} = sub {return $l->{adapt} == $r}; # a closure to access local variables + my $equal = main::PG_restricted_eval('&{$main::{_cmp_}}'); # prevents errors with large adaptive parameters + delete $main::{_cmp_}; # remove temprary function return -1 unless $equal; # # Check that n0 is non-zero (i.e., there is a multiple of C in the student answer) @@ -214,7 +214,10 @@ my $context = $self->context; $context->flags->set(no_parameters=>0); $context->variables->add(x00=>'Real'); - $result = 1 if $self->removeConstant+"n01+n00x00" == $student+"x00"; # must use both parameters + my $correct = $self->removeConstant+"n01+n00x00"; # must use both parameters + $main::{_cmp_} = sub {return $correct == $student+"x00"}; # a closure to access local variables + $result = 1 if main::PG_restricted_eval('&{$main::{_cmp_}}'); # prevents domain errors (and other errors) + delete $main::{_cmp_}; # remove temprary function $context->variables->remove('x00'); $context->flags->set(no_parameters=>1); } |