Log Message:
-----------
BACKPORT: Make sure flags set on the FormulaUpToConstant object are
inherited by the formulas used internally during the checking.
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.2.1
retrieving revision 1.11.2.1.2.2
diff -Lmacros/parserFormulaUpToConstant.pl -Lmacros/parserFormulaUpToConstant.pl -u -r1.11.2.1.2.1 -r1.11.2.1.2.2
--- macros/parserFormulaUpToConstant.pl
+++ macros/parserFormulaUpToConstant.pl
@@ -149,6 +149,7 @@
my $n01 = $context->variables->get("n01");
$context->variables->add(n01=>'Parameter') unless $n01 and $n01->{parameter};
$f->{adapt} = $f + "(n00-$n)$f->{constant} + n01";
+
return bless $f, $class;
}
@@ -175,9 +176,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('&{$main::{_cmp_}}'); # prevents errors with large adaptive parameters
- delete $main::{_cmp_}; # remove temprary function
+ $main::{_cmp_} = sub {return ($l->{adapt}->inherit($l)) == $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)
@@ -237,7 +238,7 @@
#
sub removeConstant {
my $self = shift;
- main::Formula($self->substitute($self->{constant}=>0))->reduce;
+ main::Formula($self->substitute($self->{constant}=>0))->reduce->inherit($self);
}
#
|