From: dpvc v. a. <we...@ma...> - 2005-08-10 14:27:18
|
Log Message: ----------- The Parser versions of num_cmp and fun_cmp incorrectly left the current Context set to the base context used by the answer checker. The Context is now correctly reset to the one in effect before the call to num_cmp or fun_cmp. Also removed some redundant values in if-then checks. Modified Files: -------------- pg/lib/Parser/Legacy: PGanswermacros.pl Revision Data ------------- Index: PGanswermacros.pl =================================================================== RCS file: /webwork/cvs/system/pg/lib/Parser/Legacy/PGanswermacros.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -Llib/Parser/Legacy/PGanswermacros.pl -Llib/Parser/Legacy/PGanswermacros.pl -u -r1.7 -r1.8 --- lib/Parser/Legacy/PGanswermacros.pl +++ lib/Parser/Legacy/PGanswermacros.pl @@ -1046,21 +1046,21 @@ my $context; for ($mode) { /^strict$/i and do { - $context = &$Context("LimitedNumeric")->copy; + $context = $Parser::Context::Default::context{LimitedNumeric}->copy; last; }; /^arith$/i and do { - $context = &$Context("LegacyNumeric")->copy; + $context = $Parser::Context::Default::context{LegacyNumeric}->copy; $context->functions->disable('All'); last; }; /^frac$/i and do { - $context = &$Context("LimitedNumeric-Fraction")->copy; + $context = $Parser::Context::Default::context{'LimitedNumeric-Fraction'}->copy; last; }; # default - $context = &$Context("LegacyNumeric")->copy; + $context = $Parser::Context::Default::context{LegacyNumeric}->copy; } $context->{format}{number} = $num_params{'format'}; $context->strings->clear; @@ -1069,7 +1069,7 @@ # # Add the strings to the context # - if (defined($num_params{strings}) && $num_params{strings}) { + if ($num_params{strings}) { foreach my $string (@{$num_params{strings}}) { my %tex = ($string =~ m/(-?)inf(inity)?/i)? (TeX => "$1\\infty"): (); $context->strings->add(uc($string) => {%tex}); @@ -1100,7 +1100,7 @@ # using the initialized context # my $oldContext = &$Context($context); my $r; - if (defined($num_params{units}) && $num_params{units}) { + if ($num_params{units}) { $r = new Parser::Legacy::NumberWithUnits($correctAnswer); $options{rh_correct_units} = $num_params{units}; } else { |