NAME

parserPopUp.pl - Pop-up menus compatible with Value objects.

DESCRIPTION

This file implements a pop-up menu object that is compatible with MathObjects, and in particular, with the MultiAnswer object, and with PGML.

To create a PopUp object, use one of:

$popup = PopUp([choices,...], correct);
$dropdown = DropDown([choices,...], correct);
$truefalse = DropDownTF(correct);

where "choices" are the strings for the items in the popup menu, and "correct" is the choice that is the correct answer for the popup (or its index, with 0 being the first one).

The difference between PopUp() and DropDown() is that in HTML, the latter will have an unselectable placeholder value. This value is '?' by default, but can be customized with a placeholder option.

DropDownTF() is like DropDown with options being localized versions of "True" and "False". 1 is understood as "True" and 0 as "False". The initial letter of the localized word is understood as that word if those letter are different. All of this is case-insensitive. Also, in static output (PDF, PTX) showInStatic is 0. It is assumed that context makes the menu redundant.

By default, the choices are left in the order that you provide them, but you can cause some or all of them to be ordered randomly by enclosing those that should be randomized within a second set of brackets. For example

$radio = PopUp([
                 "First Item",
                 ["Random 1","Random 2","Random 3"],
                 "Last Item"
               ],
               "Random 3"
             );

will make a pop-up menu that has the first item always on top, the next three ordered randomly, and the last item always on the bottom. In this example

$radio = PopUp([["Random 1","Random 2","Random 3"]],2);

all the entries are randomized, and the correct answer is "Random 3" (the one with index 2 in the original, unrandomized list). You can have as many randomized groups, with as many static items in between, as you want.

Note that pop-up menus can not contain mathematical notation, only plain text. This is because the PopUp object uses the browser's native menus, and these can contain only text, not mathematics or graphics.

To insert the pop-up menu into the problem text, use

BEGIN_TEXT
\{$popup->menu\}
END_TEXT

and then

ANS($popup->cmp);

to get the answer checker for the popup.

You can use the PopUp menu object in MultiAnswer objects. This is the reason for the pop-up menu's ans_rule method (since that is what MultiAnswer calls to get answer rules).

There is one option, showInStatic. It is 1 by default, except for DropDownTF it is 0. This option controls whether or not the menu is displayed in a static output format (PDF hardcopy or PTX).