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 must be loaded.

$showPartialCorrectAnswers = 0;

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

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

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

Setup

To create a radio object, use $popup = PopUp([choices,...],correct); For details, see parserPopUp.pl The context is not really necessary, but multiple choice questions are often follow-up questions, so we leave it in.

The parsePopUp.pl macro has two methods PopUp and DropDown. The former requires that a default ? is coded in the first element. The latter will put that in unless the placeholder option is there.

Note: setting the $showPartialCorrectAnswers to 0 is often desirable for multiple choice problems so students don’t know which part is incorrect and could therefore just guess the answer.

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.