http://webwork.maa.org/pod/pg_TRUNK/macros/parserPopUp.pl.html
to create a popup question with randomized choices. I see the same documentation in
However, the code for the randomization results in a rendering error, even when I copy the line of code from the documentation. The relevant lines are highlighted.
Thanks.
----------------------------------------------
The first code below works. The second code gets an error saying the the correct answer needs to be in the list.
--------------------------------------
Working code
--------------------------------------
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserPopUp.pl",
"PGcourse.pl"
);
TEXT(beginproblem());
$showPartialCorrectAnswers = 0;
##########################
# Setup
Context("Numeric");
$radio1 = PopUp(
[
"First Item",
"Random 1","Random 2","Random 3",
"Last Item"
],
"Random 3"
); # Correct answer
##########################
# Main text
Context()->texStrings;
BEGIN_TEXT
Pick one \{ $radio1->menu() \} .
END_TEXT
Context()->normalStrings;
##########################
# Answer evaluation
ANS( $radio1->cmp() );
ENDDOCUMENT();
------------------------------------------
Code that doesn't work with error
------------------------------------------
ERRORS from evaluating PG file: The correct choice must be one of the PopUp menu items at line 2 of (eval 2787) Died within Value::Error called at line 100 of [PG]/macros/parserPopUp.pl from within parser::PopUp::new called at line 2 of (eval 2787) from within main::PopUp called at line 17 of (eval 2564)
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserPopUp.pl",
"PGcourse.pl"
);
TEXT(beginproblem());
$showPartialCorrectAnswers = 0;
##########################
# Setup
Context("Numeric");
$radio1 = PopUp(
[
"First Item",
["Random 1","Random 2","Random 3"],
"Last Item"
],
"Random 3"
); # Correct answer
##########################
# Main text
Context()->texStrings;
BEGIN_TEXT
Pick one \{ $radio1->menu() \} .
END_TEXT
Context()->normalStrings;
##########################
# Answer evaluation
ANS( $radio1->cmp() );
ENDDOCUMENT();