Difference between revisions of "MultipleChoiceRadio1"

From WeBWorK_wiki
Jump to navigation Jump to search
m
(Add link to Multiple Choice Problem Techniques page)
(3 intermediate revisions by 2 users not shown)
Line 5: Line 5:
 
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).
 
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).
 
</p>
 
</p>
* Download file: [[File:MultipleChoiceRadio1.txt]] (change the file extension from txt to pg when you save it)
 
  +
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Misc/MultipleChoiceRadio1.pg FortLewis/Authoring/Templates/Misc/MultipleChoiceRadio1.pg]
* File location in NPL: <code>FortLewis/Authoring/Templates/Misc/MultipleChoiceRadio1.pg</code>
 
  +
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Misc/MultipleChoiceRadio1_PGML.pg FortLewis/Authoring/Templates/Misc/MultipleChoiceRadio1_PGML.pg]
   
 
<br clear="all" />
 
<br clear="all" />
Line 77: Line 77:
 
<b>Setup:</b>
 
<b>Setup:</b>
 
To create a radio object, use <code>$radio = RadioButtons([choices,...],correct,options);</code>
 
To create a radio object, use <code>$radio = RadioButtons([choices,...],correct,options);</code>
For all options, see [http://webwork.maa.org/pod/pg_TRUNK/macros/parserRadioButtons.pl.html parserRadioButtons.pl.html] The context is not really necessary, but multiple choice questions are often follow-up questions, so we leave it in.
+
For all options, see [[MultipleChoiceProblems]] and [http://webwork.maa.org/pod/pg/macros/parserRadioButtons.html parserRadioButtons.pl]. The context is not really necessary, but multiple choice questions are often follow-up questions, so we leave it in.
 
</p>
 
</p>
 
</td>
 
</td>

Revision as of 12:10, 15 June 2021

Multiple Choice Question with Radio Buttons

Click to enlarge

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).


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: To create a radio object, use $radio = RadioButtons([choices,...],correct,options); For all options, see MultipleChoiceProblems and parserRadioButtons.pl. 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
The correct answer is \{ $radio->correct_ans() \}
END_SOLUTION
Context()->normalStrings;

COMMENT('MathObject version.');

ENDDOCUMENT();

Solution:

Templates by Subject Area