We have questions whose answer is a list of fractions. (E.g. below.) The Fraction-NoDecimals context works to force students to enter fractions instead of decimals, but we can't seem to force reduced fractions in lists.

Also, the author of the problem defined a "no solution" string. But, if a student enters "no solution" to a question which in fact has a solution the reply is "numerators must be integers" rather than "incorrect."

Any advice about how to implement the desired behavior?

Thanks,

Jason

# DESCRIPTION # Solve an abs val eqn of the form k - |ax + b| = k, one solution. # ENDDESCRIPTION ## DBsubject('Algebra') ## DBchapter('Equations and Inequalities') ## DBsection('Absolute Value') ## KEYWORDS('linear', 'absolute value', 'equation') ## Author('Rick Lynch') ## Institution('University of Missouri-Columbia') ########################################################################### # initialization ########################################################################### DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "PeriodicRerandomization.pl", "contextFraction.pl" ); TEXT(beginproblem()); $showPartialCorrectAnswers = 1; PeriodicRerandomization("3"); ########################################################################### # setup contexts and variables ########################################################################### Context("Fraction-NoDecimals"); Context()->strings->add( "no solution"=>{}, "none"=>{alias=>"no solution"} ); $var = list_random('x','y','z','w','p','q','r','s','t','u','v'); $a = random(2,20)*random(-1,1,2); $b = -sgn($a)*random(1,20); $k = non_zero_random(-15,15); $eqn = "$k - \left| $a $var + $b\right| = $k"; $answer = List(Fraction(-$b,$a)); ########################################################################### # state the problem ########################################################################### Context()->texStrings; BEGIN_TEXT Solve the following equation for \($var\): $PAR \[ $eqn \] $PAR \( $var = \) \{ ans_rule(20) \} END_TEXT ########################################################################### # check the answer ########################################################################### ANS($answer->cmp(studentMustReduceFractions=>1)); ########################################################################### # use PeriodicRerandomization to write the answer and generate a new # version of the problem ########################################################################### if ($attempts_modp == 0 && $actualAttempts != 0) { BEGIN_TEXT $PAR $BBOLD Answer: $EBOLD \($var = $answer\) $PAR END_TEXT } else { BEGIN_TEXT $PAR $BBOLD Help: $EBOLD Enter your answers as a comma separated list if there is more than one correct answer. Write "no solution" if the equation has no solution. $BR END_TEXT } Context()->normalStrings; PeriodicStatus(); COMMENT('Features Periodic Rerandomization. Edited and updated in 2012/2013. $BR Desc: Solve an abs val eqn of the form k - |ax + b| = k, one solution.'); ENDDOCUMENT();