Multiple Choice with Popup

Multiple choice template

Complete Code

Download file: MultipleChoicePopup.pg

POD for Macro Files

PG problem file

Explanation

DOCUMENT();

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

Preamble

The macro parserPopUp.pl is used for pop up (or drop down) menus.

$showPartialCorrectAnswers = 0;

$popup = PopUp([ '?', 'Red', 'Blue', 'Green' ], 'Blue');

$dropdown1 = DropDown([ 'Red', 'Blue', 'Green' ], 'Green');

$dropdown2 =
    DropDown([ 'Red', 'Blue', 'Green' ], 'Red', placeholder => 'Select One');

Setup

Call PopUp or DropDown to create a pop up answer object. The format is

PopUp([choices, ...], correct, options);
DropDown([choices, ...], correct, options);

The difference between the PopUp and DropDown methods is that the latter will add an unselectable placeholder value. The value is ? by default, but can be customized with the placeholder option. Generally, you should use the DropDown method. The PopUp method is considered deprecated.

For details, see parserPopUp.pl.

Setting the $showPartialCorrectAnswers to 0 is often desirable for multiple choice problems to prevent guessing of answers.

BEGIN_PGML
Select my favorite color [_]{$popup}

*Same thing, but using DropDown*

Select my favorite color [_]{$dropdown1}

*Same thing, but using DropDown with placeholder option*

Select my favorite color [_]{$dropdown2}
END_PGML

Statement

This is the problem statement in PGML.
BEGIN_PGML_SOLUTION
* The first correct answer is [$popup->correct_ans].
* The second correct answer is [$dropdown1->correct_ans].
* The third correct answer is [$dropdown2->correct_ans].
END_PGML_SOLUTION

ENDDOCUMENT();

Solution

A solution should be provided here.