[system] / trunk / pg / macros / parserFormulaUpToConstant.pl Repository:
ViewVC logotype

Diff of /trunk/pg/macros/parserFormulaUpToConstant.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 5440 Revision 5460
120 # 120 #
121 my $n = $f->D($f->{constant}); 121 my $n = $f->D($f->{constant});
122 Value->Error("Your formula isn't linear in the arbitrary constant '%s'",$f->{constant}) 122 Value->Error("Your formula isn't linear in the arbitrary constant '%s'",$f->{constant})
123 unless $n->isConstant; 123 unless $n->isConstant;
124 # 124 #
125 # Make a version with an adaptive parameter for use in the 125 # Make a version with adaptive parameters for use in the
126 # comparison later on. We could like n0*C, but already have $n 126 # comparison later on. We could like n0*C, but already have $n
127 # copies of C, so remove them. That way, n0 will be 0 when there 127 # copies of C, so remove them. That way, n0 will be 0 when there
128 # are no C's in the student answer during the adaptive comparison. 128 # are no C's in the student answer during the adaptive comparison.
129 # (Again, should really check that n0 is not in use already) 129 # (Again, should really check that n0 is not in use already)
130 # 130 #
131 my $n0 = $context->variables->get("n0"); 131 my $n00 = $context->variables->get("n00");
132 $context->variables->add(n0=>'Parameter') unless $n0 and $n0->{parameter}; 132 $context->variables->add(n00=>'Parameter') unless $n00 and $n00->{parameter};
133 my $n01 = $context->variables->get("n01");
134 $context->variables->add(n01=>'Parameter') unless $n01 and $n01->{parameter};
133 $f->{adapt} = $f + "(n0-$n)$f->{constant}"; 135 $f->{adapt} = $f + "(n00-$n)$f->{constant} + n01";
134 return bless $f, $class; 136 return bless $f, $class;
135} 137}
136 138
137################################################## 139##################################################
138# 140#
160 return -1 unless $l->{adapt} == $r; 162 return -1 unless $l->{adapt} == $r;
161 # 163 #
162 # Check that n0 is non-zero (i.e., there is a multiple of C in the student answer) 164 # Check that n0 is non-zero (i.e., there is a multiple of C in the student answer)
163 # (remember: return value of 0 is equal, and non-zero is unequal) 165 # (remember: return value of 0 is equal, and non-zero is unequal)
164 # 166 #
165 return abs($context->variables->get("n0")->{value}) < $context->flag("zeroLevelTol"); 167 return abs($context->variables->get("n00")->{value}) < $context->flag("zeroLevelTol");
166} 168}
167 169
168################################################## 170##################################################
169# 171#
170# Here we override part of the answer comparison 172# Here we override part of the answer comparison

Legend:
Removed from v.5440  
changed lines
  Added in v.5460

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9