Jump to: Site Navigation

NAME - Pop-up menus compatible with Value objects.


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

        $popup = PopUp([choices,...],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).

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


and then


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).

Site Navigation