[system] Repository:
ViewVC logotype

Revision 2799


Jump to revision: Previous Next
Author: dpvc
Date: Sun Sep 19 11:49:32 2004 UTC (15 years, 1 month ago)
Log Message:
Added a new flag to the Formula()->cmp answer checker that allows a
constant-valued formula to be evaluated and then use the checker for
the resulting type.  This is useful when you want the correct answer
for a numeric check to be shown in a symbolic form (like "pi/4")
rather than as a decimal number.  To do this, use

       Formula("pi/4")->cmp(eval=>1);

rather than Real(pi/4)->cmp, which would show the correct answer as
0.785398.  Note that Formula("pi/4")->cmp would also match against
pi/4, but it does it as a function rather than a number, so error
messages might be issued indicating that the checker is expecting a
formula that returns a number, rather than just a number; this might
be confusing to a student.  It would also accept answers like
"pi/4-x+x" as correct, whereas with eval=>1 this would produce an
error message saying that the answer was supposed to be a number not a
formula returning a number.

Similarly, if you want to show sqrt(2)/2 as the correct answer, use

     Context()->flags->set(reduceConstants=>0, reduceConstantFunctions=>0);
     Formula("sqrt(2)/2")->cmp(eval=>1);

The first line tells the parser not to automatically reduce
expressions that only involve constants, so that the value of the
formula in the second line will not be reduced to a decimal before
the cmp method is called.

Changed paths:

Path Details
Directorytrunk/pg/lib/Value/AnswerChecker.pm modified , text changed

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9