ANS(fun_cmp("k($ans) + c", var=>['x','y'], params=>['k','c'] ) );
The trouble is that 0 is counted as a correct answer. Can anyone help?
Maybe something like the following?
Context("Numeric")->variables->are( x=>'Real', y=>'Real' ); $ans = "..."; $ansObj = Compute( $ans ); ... ANS( $ansObj->cmp( checker=> sub { my ( $correct, $student, $self ) = @_; my $context = Context()->copy; $context->flags->set(no_parameters=>0); $context->variables->add( c=>'Parameter', k=>'Parameter' ); my $c = Formula($context,'c'); my $k = Formula($context,'k'); $student = Formula($context,$student); $correct = Formula($context,"$k*($ans) + $c"); return $correct == $student && Compute(0) != $student; }));
(This is shamelessly copied from the techniques page on adaptive parameters: <http://http://webwork.maa.org/wiki/AdaptiveParameters>.)
Gavin