And I'd like the students to answer withx^2 = 1/49

Thanks to Davide's help (http://webwork.maa.org/moodle/mod/forum/discuss.php?d=3036) I have the customized answer helper to give hints to the students such asx=1/7,x=-1/7

*Are you sure you have all the solutions?*

I'm having trouble requiring the students to reduce their fractions. I have read http://webwork.maa.org/moodle/mod/forum/discuss.php?d=3002 which seems like it will be relevant- I have put my attempt below, but I now get the message

Allowing the solution to be an assignment (x=....) is making this tricky- otherwise I could use the solution from http://webwork.maa.org/moodle/mod/forum/discuss.php?d=2879Your first value isn't solution (it looks like a variable equal to a fraction)

Any help would be greatly appreciated.

DOCUMENT();loadMacros("PGstandard.pl", "MathObjects.pl", "parserAssignment.pl", "answerHints.pl", "PGML.pl", "contextFraction.pl", );##############################################Context("LimitedFraction")->flags->set(reduceFractions => 0); parser::Assignment->Allow; Context()->operators->redefine(',',using=>',',from=>'Numeric'); Context()->operators->redefine('or',using=>',',from=>'Numeric'); Context()->operators->set(','=>{string=>' or ',TeX=>' or '}, 'or'=>{string=>' or ',TeX=>' or '});$var = "x"; #$a = Fraction(1,random(2,10,1)); $a = Fraction(1,7); #$ans = Compute("$var = -$a, $var = $a"); $ans = Compute("-$a, $a"); ##############################################TEXT(beginproblem());BEGIN_PGMLSolve the quadratic equation [` [$var]^2 = [$a**2] `][______________________]END_PGML ############################################## $showPartialCorrectAnswers = 1; ANS($ans->cmp(entry_type => "solution", checker => sub { my ($correct,$student,$ans,$nth,$value) = @_; my ($cvar,$cfrac) = ($correct->{lop},$correct->{rop}); # get the variable and fraction my ($svar,$sfrac) = ($student->{lop},$student->{rop}); # get the variable and fraction return 0 unless Value::classMatch($sfrac,'Fraction'); return $cfrac == $sfrac if $sfrac->isReduced; $correct->context->setError("Your $nth $value is not reduced","",undef,undef,$Value::CMP_WARNING) unless $ans->{isPreview}; return 0; },extra => sub { my ($student,$ansHash,$nth,$value) = @_; if ($student->type ne "Assignment" && $ansHash->{student_formula}->type ne "Assignment") { $student->context->setError("$nth solution: $cfrac $student $check2->{ans_message} it should be written $var = ___","",undef,undef,$Value::CMP_WARNING); return; } return Value::Real->typeMatch($student); })->withPostFilter( AnswerHints( ["$var=$a","$var=-$a"] => "Are you sure you have all the solutions?", [$a,-$a] => ["Your solution is a correct one, but you should write $var = ___<br>Are you sure you have all the solutions?",replaceMessage=>1], ["$a,-$a","-$a,$a"] => ["Your solutions are correct, but you should write $var = ___",replaceMessage=>1], )));ENDDOCUMENT();