Difference between revisions of "EquationEvaluators"
m |
m |
||
Line 54: | Line 54: | ||
<pre> |
<pre> |
||
$eqn = ImplicitEquation("y = (x-1)^2", |
$eqn = ImplicitEquation("y = (x-1)^2", |
||
− | solutions=>[[0,0],[1,1],[-1,1], |
+ | solutions=>[[0,0],[1,1],[-1,1],[2,4],[-2,4]]); |
− | [2,4],[-2,4]]); |
||
</pre> |
</pre> |
||
<p> |
<p> |
||
Line 117: | Line 117: | ||
[[Category:Problem Techniques]] |
[[Category:Problem Techniques]] |
||
+ | |||
+ | |||
+ | |||
+ | <ul> |
||
+ | <li>POD documentation: [http://webwork.maa.org/doc/cvs/pg_CURRENT/macros/parserImplicitEquation.pl.html parserImplicitEquation.pl]</li> |
||
+ | <li>PG macro: [http://cvs.webwork.rochester.edu/viewcvs.cgi/pg/macros/parserImplicitEquation.pl parserImplictEquation.pl]</li> |
||
+ | </ul> |
Revision as of 21:53, 24 January 2010
Equation Answer Evaluation
This code shows how to check student answers that are equations.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros("parserImplicitEquation.pl"); TEXT(beginproblem()); |
Initialization:
To check equations given as answers, we don't have to change the tagging and documentation section of the problem file. In the initialization section, we need to include the macros file |
Context("ImplicitEquation"); Context()->variables->set( x=>{limits=>[-2,2]}, y=>{limits=>[0,4]} ); $eqn = ImplicitEquation("y = (x-1)^2"); |
Setup:
We specify that the Context should be
By default, the
Two other notes: if it's possible that a student's solution may evaluate to true for the test points that are used in the answer checker, it may be a good idea to specify what (x,y) solution values are used to check the answer. This can be done in the $eqn = ImplicitEquation("y = (x-1)^2", solutions=>[[0,0],[1,1],[-1,1],[2,4],[-2,4]]);
And, for this type of answer checking it is more likely than for regular formulas that the student will represent the function in a form that exceeds the default problem checking tolerances, and so be marked as incorrect. To correct this, it may be necessary to specify a tolerance; an absolute tolerance can be set in the $eqn = ImplicitEquation("y = (x-1)^2", tolerance=>0.0001);
It is possible to remove the error message "Can't find any solutions to your equation" by remapping it to another error message. The message has to be non-empty, but it can be just a blank Context()->{error}{msg}{"Can't find any solutions to your equation"} = " "; This will eliminate the error message (though the "messages" column will be displayed in the answer table at the top of the problem, but no message will be there). For another way to remove this error message, see the |
BEGIN_TEXT Give the equation of a shift of the parabola \(y = x^2\) which is upward opening and has its vertex at (1,0). $PAR equation: \{ ans_rule(35) \} END_TEXT |
Main Text: The problem text section of the file is as we'd expect. |
ANS( $eqn->cmp() ); ENDDOCUMENT(); |
Answer Evaluation:
Another way to remove the error message "Can't find any solutions to your equation" would be to use a post-filter to remove the message after the answer has been graded. The ANS($eqn->cmp->withPostFilter(sub { my $ans = shift; $ans->{ans_message} = "" if $ans->{ans_message} eq "Can't find any solutions to your equation"; return $ans; })); |
- POD documentation: parserImplicitEquation.pl
- PG macro: parserImplictEquation.pl