I modified what Davide gave me in this forum when I asked about allowing on correct value out of many...This might work:

DOCUMENT();

loadMacros(

"PGstandard.pl", # Standard macros for PG language

"MathObjects.pl",

"contextFraction.pl",

);

TEXT(beginproblem());

Context("Fraction");

BEGIN_TEXT

A decimal number between 0 and 1 is \{ans_rule(20)\}

END_TEXT

ANS(Compute("0.5")->cmp(

checker => sub {

my ($correct,$student,$ans) = @_;

my ($x) = $student->value;

return $x >0 && $x

I think Bruce was going to say to use

ANS(Compute("0.5")->cmp( checker => sub { my ($correct,$student,$ans) = @_; my $x = $student->value; return $x > 1 && $x < 2; }));which is essentially what I was going to suggest as well.

There is an issue to consider, however, and that's the use of `$student->value`

rather than `$student`

itself. If one uses `$student`

, then the MathObject's fuzzy real comparisons will be used, so that values that are fuzzy-equal to 1 or 2 will be excluded (i.e., the check is really more like `$x > 1+epsilon && $x < 2-epsilon`

). The difference would be whether you expect students to enter a computed value (a numeric formula) or to type a decimal directly. If it is a formula that they will be computing, you might want to use the fuzzy check, so that something that computes 1.99999 (but should have been 2 had it not been for round-off errors) will not be counted as correct, as it would when the non-fuzzy check it performed.

I'm not sure which I think is the right approach. It really depends on the problem, how you expect students to approach it, and how likely you think answers near the endpoints will be.

Davide