## WeBWorK Problems

### parserPopup.pl and randomizing choices

by Murphy Waggoner -
Number of replies: 4
I was trying to follow
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();
"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"

##########################
# 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();
"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"

##########################
# Main text

Context()->texStrings;
BEGIN_TEXT
Pick one \{ $radio1->menu() \} . END_TEXT Context()->normalStrings; ########################## # Answer evaluation ANS($radio1->cmp() );

ENDDOCUMENT();

### Re: parserPopup.pl and randomizing choices

by Alex Jordan -
HI Murphy,

http://math.simpson.edu/webwork2/

If so, it is using version 2.10. The changes to parserPopUp that make that kind of randomization possible are more recent. I'm not sure when they happened, but they work on 2.13.

### Re: parserPopup.pl and randomizing choices

by Murphy Waggoner -
Yes, that is our server.

Are the changes that make that kind of randomization possible isolated in parserPopUp.pl? If so, can I just copy the newest version of it to \macros for my course until we update our server?

### Re: parserPopup.pl and randomizing choices

by Davide Cervone -
The changes to parserPopUp.pl seem to be isolated to that file. But parserPopUp.pl relies on the MathObjects String class, and that was last modified in the summer of 2015. It looks like version 2.10 was released in January 2015, with an update to 2.10+ in November 2015, so it may be that some of the changes in the summer of 2015 are missing from your server (depending on when your copy of 2.10 was obtained). Since the String object is defined in a .pm not a .pl file, you won't be able to replace it without access to the server (and restarting it after the change). But it probably will work if you just upload the current parerPopUp.pl file. Give it a try and see.