Simple Popup

Answers are lists of points

Complete Code

Download file: SimplePopUp.pg

POD for Macro Files

PG problem file

Explanation

DOCUMENT();

loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl');

Preamble

We need to load parserPopUp.pl for this feature.

$popup = PopUp([ "?", "one", "two", "three" ], "three");

$dropdown1 = DropDown([ 'one', 'two', 'three' ], 'two');
$dropdown2 = DropDown([ 'one', 'two', 'three' ],
    'one', placeholder => 'Select an option');
$dropdown3 =
    DropDown([ 'one', [ 'two', 'three', 'four', 'five' ], 'six' ], 'six');

$tf = DropDownTF('T');

Setup

This shows a number of ways to use either PopUp (the legacy version) or DropDown (a more flexible version). Both create an HTML select object. The PopUp takes a array reference of option and the correct answer and creates the options. Notice in Popup the first element is shown, but selectable, whereas in DropDown, the first either defaults to ? or whatever is in the placeholder option. In Dropdown, the first element is not selectable.

Similar to other parser objects, inserting another array reference, randomizes those options.

Lastly, the DropDownTF creates a true/false dropdown for simplicity.

BEGIN_PGML

- [_]{$popup} (ans: 'three')
- [_]{$dropdown1} (ans: 'two')
- [_]{$dropdown2} (ans: 'one')
- [_]{$dropdown3} (ans: 'six')
- [_]{$tf} (ans: 'True')

END_PGML

Statement

This is the problem statement in PGML.
BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

COMMENT('MathObject version. Uses PGML.');

ENDDOCUMENT();

Solution

A solution should be provided here.