WeBWorK Problems

Limited Radical Context not reducing

Limited Radical Context not reducing

by Brittni Lorton -
Number of replies: 2
This code is marking students correct for entering 1sqrt(3) but is marking them incorrect for entering sqrt(3). What am I missing?


DOCUMENT();

loadMacros(

  "PGstandard.pl",

  "MathObjects.pl",

  "PGML.pl",

  "contextFraction.pl",

  "contextLimitedRadical.pl",

  "PGcourse.pl",

  "parserRoot.pl",

);

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

TEXT(beginproblem());

Context("Numeric");

$b=4;

$c=-3;

$d = Compute("$b+$c");

Context("LimitedRadical");

$ans = Formula("$d*sqrt($a)");

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

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

BEGIN_PGML

Simplify the radical.

 [`` [$b]\sqrt{[$a]} + [$c]\sqrt{[$a]} = ``] [_____________]{$ans1}

END_PGML

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

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

ENDDOCUMENT();


In reply to Brittni Lorton

Re: Limited Radical Context not reducing

by Danny Glin -

According to the documentation for contextLimitedRadical.pl it doesn't actually check if the expression is simplified.  It is pretty much just checking if the student entered the answer in the same format as the correct answer.  That means that if the correct answer is "1*sqrt(3)" then the student will need to enter the coefficient of 1.

(In more detail, LimitedRadical uses bizarro arithmetic during the checking, which means that 1*x is not equal to x, which is why it marks it wrong if it doesn't have the coefficient of 1 in front.)

I'm assuming that your sample code is one case of a randomized problem.  You will have to treat the case where $d==1 separately (and probably 0 and -1 as well if they apply to your problem) and explicitly set the correct answer without the coefficient.

In reply to Danny Glin

Re: Limited Radical Context not reducing

by Brittni Lorton -

Thank you. You are right, it is randomized. I am fine with treating the case of 1*x differently than 2*x, that will be an easy enough fix for now.

But I am curious, is there a better context for me to use in this case that is not limited radical? The goal is to force simplification and so students should only be entering sqrt(3) and not 4sqrt(3)-3sqrt(3).