There are problems that arise naturally in, say, differential equations, in which the solution is an equation in a form such as "f(x,y)=0" or "f(x,y,z)=C", where the left-hand-side is only determined up to a constant multiple, and we would like the student to enter it. However, 0 is always such a constant multiple, and it should specifically be disallowed.
I'm trying to use adaptive parameters. I don't really want an adaptive parameter to show up in the correct answer, since it might be confusing to the student, and I would prefer to have an answer evaluator that anyone could simply drop into a problem and use without having to modify it or figure out how it works. Ideally it shouldn't be restricted to using a fixed set of variables either.
I've tried things like the following:
$ans = Formula("x+y+z");#or any constant multiple
my ($correct, $student, $ans)=@_;
# add an adaptive parameter "a" to the context
return 0 if Formula("$student") == Formula("0"); #don't allow student to enter 0
return $correct == Formula("$student");
The question is: how do I add the adaptive parameter to the context? The obvious thing (Context()->variables->add(a=>'Parameter')) doesn't seem to work for me. The only success I've had is by creating a new context inside the answer evaluator, e.g.,
my $newcontext = Context("Numeric");
Note that this means I had to re-add the variables y and z. If an instructor used a different set of variables, the answer evaluator would need to be modified.
If I understood what was going on here, I think I would understand contexts a lot better.