MultipleChoiceRadio1: Difference between revisions
No edit summary |
(add historical tag and give links to newer problems.) |
||
| (10 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
{{historical}} | |||
<p style="background-color:# | <p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Misc/MultipleChoiceRadio.html a newer version of this problem]</p> | ||
<h2>Multiple Choice Question with Radio Buttons</h2> | |||
[[File:MultipleChoiceRadio1.png|300px|thumb|right|Click to enlarge]] | |||
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"> | |||
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> | ||
* 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] | |||
* 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" /> | |||
<p style="text-align:center;"> | <p style="text-align:center;"> | ||
[[SubjectAreaTemplates|Templates by Subject Area]] | [[SubjectAreaTemplates|Templates by Subject Area]] | ||
| Line 77: | Line 82: | ||
<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/ | 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> | ||
| Line 152: | Line 157: | ||
[[Category:Top]] | [[Category:Top]] | ||
[[Category: | [[Category:Sample Problems]] | ||
[[Category:Subject Area Templates]] | |||
Latest revision as of 11:17, 17 July 2023
This problem has been replaced with a newer version of this problem
Multiple Choice Question with 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).
- File location in OPL: FortLewis/Authoring/Templates/Misc/MultipleChoiceRadio1.pg
- PGML location in OPL: FortLewis/Authoring/Templates/Misc/MultipleChoiceRadio1_PGML.pg
| PG problem file | Explanation |
|---|---|
|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserRadioButtons.pl", ); TEXT(beginproblem()); |
Initialization:
We need |
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 |
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: |