Multiple choice template
Download file: MultipleChoiceRadio.pg
DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', 'parserRadioButtons.pl', 'PGcourse.pl');
Preamble
The macro parserRadioButtons.pl is used for radio button answers.
$radio1 = RadioButtons(
[ [ 'Red', 'Blue', 'Green' ], 'None of these' ],
'Blue', # correct answer
);
$radio2 = RadioButtons(
[ [ 'Red', 'Blue', 'Green' ], 'None of these' ],
2, # correct answer as an index (starting at 0)
separator => $SPACE x 5
);
Setup
Call RadioButtons to create a radio button answer
object. The format is
RadioButtons([choices, ...], correct, options);For more details see parserRadioButtons.pl.
Setting the option separator to $SPACE x 5
results in a horizontal list of radio buttons. Note that
$SPACE should be used and not so
that this works in both html and hard copy.
BEGIN_PGML
My favorite color is
[_]{$radio1}
The same question with horizontal options:
My favorite color is [_]{$radio2}
END_PGML
Statement
This is the problem statement in PGML.BEGIN_PGML_SOLUTION The correct answer to the first is [$radio1->correct_ans]. The correct answer to the first is [$radio2->correct_ans]. END_PGML_SOLUTION ENDDOCUMENT();
Solution
The correct_ans method can be called to get the correct
answer.