Difference between revisions of "MultipleChoicePopup2"
(add historical tag and give links to newer problems.) |
|||
(8 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{historical}} |
||
+ | |||
+ | <p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Misc/MultipleChoicePopup.html a newer version of this problem]</p> |
||
+ | |||
+ | |||
<h2>Multiple Choice Question with a Popup Menu</h2> |
<h2>Multiple Choice Question with a Popup Menu</h2> |
||
[[File:MultipleChoicePopup2.png|300px|thumb|right|Click to enlarge]] |
[[File:MultipleChoicePopup2.png|300px|thumb|right|Click to enlarge]] |
||
− | <p style="background-color:# |
+ | <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> |
||
− | * Download file: [[File:MultipleChoicePopup2.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/MultipleChoicePopup2.pg FortLewis/Authoring/Templates/Misc/MultipleChoicePopup2.pg] |
||
− | * File location in NPL: <code>NationalProblemLibrary/FortLewis/Authoring/Templates/Misc/MultipleChoicePopup2.pg</code> |
||
+ | * PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Misc/MultipleChoicePopup2_PGML.pg FortLewis/Authoring/Templates/Misc/MultipleChoicePopup2_PGML.pg] |
||
Line 77: | Line 82: | ||
<b>Setup:</b> |
<b>Setup:</b> |
||
To create a radio object, use <code>$popup = PopUp([choices,...],correct);</code> |
To create a radio object, use <code>$popup = PopUp([choices,...],correct);</code> |
||
− | For details, see [http://webwork.maa.org/pod/ |
+ | For details, see [http://webwork.maa.org/pod/pg/macros/parserPopUp.html parserPopUp.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 89: | Line 94: | ||
Context()->texStrings; |
Context()->texStrings; |
||
BEGIN_TEXT |
BEGIN_TEXT |
||
− | + | Is my favorite color red, blue, or green? |
|
\{ $popup->menu() \} |
\{ $popup->menu() \} |
||
END_TEXT |
END_TEXT |
||
Line 97: | Line 102: | ||
<p> |
<p> |
||
<b>Main Text:</b> |
<b>Main Text:</b> |
||
+ | Since popup menus hide their choices, we write the entire list of choices into the question. It is essential to do this, otherwise a student who is working from a PDF copy of their homework won't know what the options are and won't be able to answer the question. |
||
</p> |
</p> |
||
</td> |
</td> |
||
Line 150: | Line 156: | ||
[[Category:Top]] |
[[Category:Top]] |
||
− | [[Category: |
+ | [[Category:Sample Problems]] |
+ | [[Category:Subject Area Templates]] |
Latest revision as of 06:18, 17 July 2023
This problem has been replaced with a newer version of this problem
Multiple Choice Question with a Popup Menu
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/MultipleChoicePopup2.pg
- PGML location in OPL: FortLewis/Authoring/Templates/Misc/MultipleChoicePopup2_PGML.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserPopUp.pl", ); TEXT(beginproblem()); |
Initialization:
We need |
Context("Numeric"); $popup = PopUp( ["?","Red","Blue","Green"], "Blue", ); |
Setup:
To create a radio object, use |
Context()->texStrings; BEGIN_TEXT Is my favorite color red, blue, or green? \{ $popup->menu() \} END_TEXT Context()->normalStrings; |
Main Text: Since popup menus hide their choices, we write the entire list of choices into the question. It is essential to do this, otherwise a student who is working from a PDF copy of their homework won't know what the options are and won't be able to answer the question. |
install_problem_grader(~~&std_problem_grader); $showPartialCorrectAnswers = 0; ANS( $popup->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 \{ $popup->correct_ans() \} END_SOLUTION Context()->normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT(); |
Solution: |