Difference between revisions of "MultipleChoiceRadio1"
Jump to navigation
Jump to search
(Created page with '<h2>Insert Title Here</h2> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> This PG code shows how to ... <ul> <li>Download file: File:filename.txt (…') |
|||
Line 1: | Line 1: | ||
− | <h2>Insert Title Here</h2> |
||
+ | <h2>Multiple Choice Question 1 (Radio Buttons)</h2> |
||
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
||
− | This PG code shows how to ... |
||
+ | 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). |
||
<ul> |
<ul> |
||
− | <li>Download file: [[File: |
+ | <li>Download file: [[File:MultipleChoice1.txt]] (change the file extension from txt to pg)</li> |
− | <li>File location in NPL: <code>NationalProblemLibrary/FortLewis/Authoring/Templates/. |
+ | <li>File location in NPL: <code>NationalProblemLibrary/FortLewis/Authoring/Templates/Misc/MultipleChoice1.pg</code></li> |
</ul> |
</ul> |
||
</p> |
</p> |
||
Line 66: | Line 66: | ||
Context("Numeric"); |
Context("Numeric"); |
||
− | $answer = Compute("1"); |
||
+ | $radio = RadioButtons( |
||
+ | ["Red","Blue","Green","None of these"], |
||
+ | "Blue", # correct answer |
||
+ | last => ["None of these"], # can be a list |
||
+ | ); |
||
</pre> |
</pre> |
||
</td> |
</td> |
||
Line 72: | Line 76: | ||
<p> |
<p> |
||
<b>Setup:</b> |
<b>Setup:</b> |
||
+ | 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 83: | Line 88: | ||
Context()->texStrings; |
Context()->texStrings; |
||
BEGIN_TEXT |
BEGIN_TEXT |
||
− | Question text |
||
+ | My favorite color is |
||
$BR |
$BR |
||
$BR |
$BR |
||
− | Answer = |
||
+ | \{ $radio->buttons() \} |
||
− | \{ ans_rule(20) \} |
||
− | \{ AnswerFormatHelp("formulas") \} |
||
END_TEXT |
END_TEXT |
||
Context()->normalStrings; |
Context()->normalStrings; |
||
Line 104: | Line 107: | ||
<td style="background-color:#eeddff;border:black 1px dashed;"> |
<td style="background-color:#eeddff;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | $showPartialCorrectAnswers = 1; |
||
+ | install_problem_grader(~~&std_problem_grader); |
||
− | ANS( $answer->cmp() ); |
||
+ | $showPartialCorrectAnswers = 0; |
||
+ | |||
+ | ANS( $radio->cmp() ); |
||
</pre> |
</pre> |
||
<td style="background-color:#eeccff;padding:7px;"> |
<td style="background-color:#eeccff;padding:7px;"> |
||
<p> |
<p> |
||
<b>Answer Evaluation:</b> |
<b>Answer Evaluation:</b> |
||
+ | We use the standard problem grader, which gives full credit or no credit. For other graders, see [http://webwork.maa.org/wiki/WeightedGrader weighted graders] |
||
</p> |
</p> |
||
</td> |
</td> |
||
Line 120: | Line 126: | ||
<td style="background-color:#ddddff;border:black 1px dashed;"> |
<td style="background-color:#ddddff;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | |||
Context()->texStrings; |
Context()->texStrings; |
||
BEGIN_SOLUTION |
BEGIN_SOLUTION |
||
− | ${PAR}SOLUTION:$ |
+ | ${PAR}SOLUTION:$PAR |
− | + | Just guess! |
|
END_SOLUTION |
END_SOLUTION |
||
Context()->normalStrings; |
Context()->normalStrings; |
Revision as of 18:48, 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
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserRadioButtons.pl", ); TEXT(beginproblem()); |
Initialization: |
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 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: |