I'm specifically having problems with ImplicitEquation and Inequality answers since they each demand their own DIFFERENT context?!
cs
Set a Context1;Now at this point in your code, $MathObject1 still has all of its properties from Context1. When $MathObject1 was created, all of those properties, including its answer checker, were set as an internal part of $MathObject1.
Define a $MathObject1;
Set a Context2;
Define a $MathObject2;
$MathObject1 = Compute($MathObject1);then at this point the Compute command is computing via Context2, and so your $MathObject1 will lose its Context1 properties.
Set a Context1;As a side note, using ImplicitEquation requires more attention than usual to things like limits and test points for Formula checking.
Define a $MathObject1;
Define a $PerlScalar;
Set a Context2;
Define a $MathObject2;
BEGIN_PGML
Our first answer is [_____]{$MathObject1}
Our second answer is [_____]{$MathObject2}
A third answer could be [_____]{$PerlScalar} but note that it will be put through the current Context2 Compute command before it is checked against the student's answer.
END_PGML
Context("Context1"); $MathObject = Compute("..."); Context("Context2"); $MathObject1 = Compute($MathObject1);doesn't really recompute $MathObject1, it just switches what context it is associated with (but doesn't re-parse the object using the new rules). So, for example,
Context("Vector"); $f = Compute("<x,x+1>"); Context("Numeric"); $f = Compute($f);doesn't cause an error, it simply forces the formula for
$f
to think it is from the Numeric context. If
ANS($f->cmp);were used, the student would have no way to enter the correct answer, since the vector could not be entered in Numeric context.
On the other hand,
Context("Vector"); $f = Compute("<x,x+1>"); Context("Numeric"); $f = Compute("$f");would cause an error, because here
"$f"
means $f
is first stringified, and then Compute()
re-parses the string, leading to an error, since <
is not defined in Numeric context.
This is one of the places where the difference between $f
and "$f"
is crucial.
Davide