## WeBWorK Problems

### wierd earning

by Carl Yao -
Number of replies: 6
Hello:

The following is a fairly easy problem involving radio buttons. This is the line which is causing problem:

$choice0 =$a1*$b; I don't understand why WeBWorK gave me a warning: ## WeBWorK Warnings WeBWorK has encountered warnings while processing your request. If this occured when viewing a problem, it was likely caused by an error or ambiguity in that problem. Otherwise, it may indicate a problem with the WeBWorK system itself. If you are a student, report these warnings to your professor to have them corrected. If you are a professor, please consult the warning output below for more information. ### Warning messages • Use of uninitialized value$value in string eq at line 314 of [PG]/macros/parserRadioButtons.pl
• Use of uninitialized value $value in string eq at line 314 of [PG]/macros/parserRadioButtons.pl Thank you for any help! Carl Yao Portland Community College # WeBWorK problem written by Carl Yao # Portland Community College # # Estimate the product of multiplication like 2856*4 # # Last edited: Carl Yao 10/13/2016 # DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "PGML.pl", "parserRadioButtons.pl", "PGcourse.pl", ); ###################################### TEXT(beginproblem()); Context("Numeric");$a = random(2,9,1);
$b = random(2,7,1);$a1Exp = random(2,4,1);
$a1Ten = 10**$a1Exp;
$a1 =$a*$a1Ten;$a1Close = $a1+10**($a1Exp-1)*non_zero_random(-2,2,1)+10**($a1Exp-2)*non_zero_random(-2,2,1);$choice0 = $a1*$b;
$choice1 = ($a-1)*$a1Ten*$b;
$choice2 = ($a+1)*$a1Ten*$b;
$choice3 =$choice0*10;

$radio = RadioButtons( [$choice0,$choice1,$choice2,$choice3],$choice0, #correct
);

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

BEGIN_PGML

Without using a calculator, round the first number to a number easier to calculate, and then estimate the product.

[ [$a1Close] \cdot [$b] \approx ? ]

[@ $radio->buttons() @]* END_PGML ############################################################ ANS($radio->cmp() );

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

BEGIN_PGML_SOLUTION

The correct answer is [[@ $radio->correct_ans() @]*]. END_PGML_SOLUTION ###################################### ENDDOCUMENT(); In reply to Carl Yao ### Re: wierd earning by Alex Jordan - The error message refers to the eq operator, which is for comparing strings. Reading the documentation for parserRadioButtons.pl, it sounds as if the choices are assumed to be strings. (https://github.com/openwebwork/pg/blob/master/macros/parserRadioButtons.pl) So you might try making your choices be strings instead of perl reals.$radio = RadioButtons(
["$choice0","$choice1","$choice2","$choice3"],

### Re: wierd earning

by Carl Yao -
Mystery solved! :) Thank you!

Carl Yao

### Re: wierd earning

by Paul Pearson -
Hi,

I recently asked Davide Cervone about this.  I think he may have updated parserRadioButtons.pl to fix this in the github version.  As a work around, Davide suggested answers such as " 300000 " (notice the extra spaces) instead of "300000".  The extra spaces should mean that the it gets interpreted as a string, not a number.  This work around is probably the safest way to fix the problem (the work around should be backward and forward compatible).

Best regards,

Paul Pearson