Difference between revisions of "MultipleChoiceRadio1"

From WeBWorK_wiki
Jump to navigation Jump to search
Line 54: Line 54:
 
<p>
 
<p>
 
<b>Initialization:</b>
 
<b>Initialization:</b>
</p>
 
  +
We need <code>parserRadioButtons.pl</code></p>
 
</td>
 
</td>
 
</tr>
 
</tr>

Revision as of 19:57, 30 November 2010

Multiple Choice Question 1 (Radio Buttons)

This PG code shows how to write a multiple choice question in which all of the options are displayed to the student and the student can only choose one correct answer (it uses radio buttons).

  • Download file: File:MultipleChoice1.txt (change the file extension from txt to pg)
  • File location in NPL: NationalProblemLibrary/FortLewis/Authoring/Templates/Misc/MultipleChoice1.pg

Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserRadioButtons.pl",
);

TEXT(beginproblem());

Initialization: We need parserRadioButtons.pl

Context("Numeric");

$radio = RadioButtons(
  ["Red","Blue","Green","None of these"],
  "Blue", # correct answer
  last => ["None of these"], # can be a list
);

Setup: The context is not really necessary, but multiple choice questions are often follow-up questions, so we leave it in.

Context()->texStrings;
BEGIN_TEXT
My favorite color is
$BR
$BR
\{ $radio->buttons() \}
END_TEXT
Context()->normalStrings;

Main Text:

install_problem_grader(~~&std_problem_grader);

$showPartialCorrectAnswers = 0;

ANS( $radio->cmp() );

Answer Evaluation: We withhold feedback by choosing not to show partially correct answers. We use the standard problem grader, which gives full credit or no credit. For other graders, see weighted graders

Context()->texStrings;
BEGIN_SOLUTION
${PAR}SOLUTION:$PAR
Just guess!
END_SOLUTION
Context()->normalStrings;

COMMENT('MathObject version.');

ENDDOCUMENT();

Solution:

Templates by Subject Area