WeBWorK Problems

Error on a problem using the LimitedNumeric context

Error on a problem using the LimitedNumeric context

by Robin Cruz -
Number of replies: 1

A student got the following error on a problem we've used in 6 courses -- without anyone reporting an error in the past.  The seed used on the problem when the error occurs is 348.  I've included a copy of the problem template below.

--rac

---------------------------------------------Error message--------------------------------------

Can't use '*' in this context; see position 16 of formula at line 93 of [PG]/macros/Parser.pl Died within main::Formula called at line 93 of [PG]/macros/Parser.pl from within main::Compute called at line 60 of [TMPL]/tmpEdit/Problems/setAppliedMath_01_02_Polynomials/AppMath_01_Polynomials.pg.rcruz.tmp

Error details

 Problem1 ERROR caught by Translator while processing problem file:tmpEdit/Problems/setAppliedMath_01_02_Polynomials/AppMath_01_Polynomials.pg.rcruz.tmp **************** Can't use '*' in this context; see position 16 of formula at line 93 of [PG]/macros/Parser.pl Died within main::Formula called at line 93 of [PG]/macros/Parser.pl from within main::Compute called at line 60 of [TMPL]/tmpEdit/Problems/setAppliedMath_01_02_Polynomials/AppMath_01_Polynomials.pg.rcruz.tmp 
---------------------------Problem Template------------------------------
 
loadMacros(
  "PGstandard.pl",
  "MathObjects.pl",
  "contextLimitedNumeric.pl"
);
 
TEXT(&beginproblem);
 
######################################
#  Setup
 
$p = non_zero_random(-12,12,1);
do {$q = non_zero_random(-7,7,1);} while ($p==$q||$q==1||$q==-1);
$r = random(4,9,1) + random(.1,.9,.1); #Make sure its not an integer
 
$a = random(4,6,1);
$b = random(4,6,1);
 
######################################
#  Main text
 
BEGIN_TEXT
Use a calculator to approximate the following numbers:
$PAR
a) \( $r^$a \)
$BR
ANSWER: \{ans_rule(10)\}
$PAR
b) \( \displaystyle \left( \frac{$p}{$q} \right)^$b \)
$BR
ANSWER: \{ans_rule(10)\}
END_TEXT
 
######################################
#  Answers
 

Context("LimitedNumeric");
 
$ans_a = Compute($r**$a);
ANS($ans_a->cmp);
 
$ans_b = Compute(($p/$q)**$b);
ANS($ans_b->cmp);
 
$showPartialCorrectAnswers = 1;
 
######################################
 
ENDDOCUMENT(); # This should be the last executable line in the problem.
In reply to Robin Cruz

Re: Error on a problem using the LimitedNumeric context

by Davide Cervone -
This is not an error, it is correct behavior. LimitedNumeric context does not allow any operations, like '*' or implied multiplication, which are both represented as '*'. It may be that the student has included a space between two numbers, say, which will generate this same error.

Davide