I have having a strange issue pop up in the below problem. I want to ensure students only enter fractions, and not decimals. The code here seems to be working, but when a student enters the decimal value for the [1,1] entry and the fraction value for the other entries, they just get 'incorrect' and not the message saying they need to use fractions. When a student enters the decimal in the [2,2] entry they get the desired message of 'in entry (2,2): You are only allowed to enter fractions, not decimals." Weird! Any insight as to why this is and if there is a fix?

DOCUMENT();

loadMacros(

"PGstandard.pl",

"MathObjects.pl",

"PGchoicemacros.pl",

"PGmatrixmacros.pl",

"parserAssignment.pl",

"PGML.pl",

"MatrixReduce.pl",

"PGcourse.pl",

);

TEXT(beginproblem());

##########################

# Setup

Context('Fraction-NoDecimals');

Context()->parens->set("[" => {formMatrix => 1});

do {

$a = random(-1,1,2) * random(2,9,1);

$d = random(-1,1,2) * random(2,9,1);

$b = 0;

$c = 0;

} until ($a != $d);

$A = Matrix([[$a, $b], [$c, $d]]);

$A = apply_fraction_to_matrix_entries($A);

$Ainv = $A->inverse;

$Ainv = apply_fraction_to_matrix_entries($Ainv);

Context()->texStrings;

BEGIN_TEXT

If \( A = $A, \)

$BR

then

$BR

\( A^{-1} = \) \{ $Ainv->ans_array(7) \}.

$BR

Enter elements as fractions, not decimals.

END_TEXT

Context()->normalStrings;

ANS($Ainv->cmp);

COMMENT();

ENDDOCUMENT();