MultipleChoiceProblems: Difference between revisions
m (2 revisions: import all default namespace pages from old wiki) |
No edit summary |
||
Line 9: | Line 9: | ||
<p> | <p> | ||
We give two examples here. The first uses old-style answer checkers; the second newer parser based code. Note that the functionality that is provided in either case is different; the latter is syntactically cleaner and simpler, but doesn't have the same range of functions provided by the first. | |||
</p> | </p> | ||
<p style="text-align:center;"> | <p style="text-align:center;"> | ||
[[ | [[Problem_Techniques|Problem Techniques Index]] | ||
</p> | |||
<p> | |||
<strong>With Old-Style Answer Checkers</strong> | |||
</p> | </p> | ||
Line 104: | Line 108: | ||
</tr> | </tr> | ||
</table> | </table> | ||
<p> | |||
<strong>With Newer Answer Checkers</strong> | |||
</p> | |||
<table cellspacing="0" cellpadding="2" border="0"> | |||
<tr valign="top"> | |||
<th> PG problem file </th> | |||
<th> Explanation </th> | |||
</tr> | |||
<tr valign="top"> | |||
<td style="background-color:#ddffdd;border:black 1px dashed;"> | |||
<pre> | |||
DOCUMENT(); | |||
loadMacros( | |||
"PGstandard.pl", | |||
"parserRadioButtons.pl", | |||
); | |||
</pre> | |||
</td> | |||
<td style="background-color:#ccffcc;padding:7px;"> | |||
<p> | |||
<b>Initialization:</b> Include <code>parserRadioButtons.pl</code> in the list of loaded macro files. This allows use of radio buttons (all options are shown, with a select-one button in front of each). We could also use <code>parserPopUp.pl</code> instead, which would allow creation of a drop-down menu of options. This is noted below as well. | |||
</p> | |||
</td> | |||
</tr> | |||
<tr valign="top"> | |||
<td style="background-color:#ffffdd;border:black 1px dashed;"> | |||
<pre> | |||
$mc = RadioButtons( | |||
[ "Blue", "Red", "Green", | |||
"None of the above" ], | |||
"Blue" ); | |||
</pre> | |||
</td> | |||
<td style="background-color:#ffffcc;padding:7px;"> | |||
<p> | |||
<b>Setup:</b> We create a radio button object with <code>RadioButtons</code>. The first argument is a reference to a list of options: <code>["Blue","Red",...]</code>, and the second is the correct answer, which needs to be one of the options. | |||
</p> | |||
<p> | |||
To create a drop-down ("pop-up") option (having loaded <code>parserPopUp.pl</code>, of course), we use the same syntax: | |||
</p> | |||
<pre> | |||
$mc = PopUp( | |||
[ "?", "Blue", "Red", "Green", | |||
"None of the above" ], | |||
"Blue" ); | |||
</pre> | |||
<p> | |||
Note that in this case we should specify a generic non-answer as the first option, so that when the selector is displayed it does not automatically give the student an answer (which may or may not be correct). | |||
</p> | |||
</td> | |||
</tr> | |||
<tr valign="top"> | |||
<td style="background-color:#ffdddd;border:black 1px dashed;"> | |||
<pre> | |||
BEGIN_TEXT | |||
What color most resembles the sky? | |||
$BR | |||
\{ $mc->buttons() \} | |||
END_TEXT | |||
</pre> | |||
<td style="background-color:#ffcccc;padding:7px;"> | |||
<p> | |||
<b>Main text:</b> In the text section we print the question and radio buttons giving the answers. For a PopUp object, the call to create the menu of options is <code>$mc->menu()</code>. | |||
</p> | |||
</td> | |||
</tr> | |||
<tr valign="top"> | |||
<td style="background-color:#eeddff;border:black 1px dashed;"> | |||
<pre> | |||
$showPartialCorrectAnswers = 0; | |||
ANS( $mc->cmp() ); | |||
ENDDOCUMENT(); | |||
</pre> | |||
<td style="background-color:#eeccff;padding:7px;"> | |||
<p> | |||
<b>Answer Evaluation:</b> In most cases we will want to set <code>$showPartialCorrectAnswers</code> to <code>0</code> (false) for multiple choice problems. Otherwise, students can use the feedback or the partial credit received to guess and check if their answers are correct. | |||
We grade the problem as expected. | |||
</p> | |||
</td> | |||
</tr> | |||
</table> | |||
<p style="text-align:center;"> | <p style="text-align:center;"> | ||
[[ | [[Problem_Techniques|Problem Techniques Index]] | ||
</p> | </p> | ||
[[Category:Problem Techniques]] | [[Category:Problem Techniques]] |
Revision as of 14:41, 20 June 2013
Multiple Choice Problems: PG Code Snippet
This code snippet shows the essential PG code to include a multiple-choice question in a problem.
For an example of a multiple choice problem in which the choices are graphs, see Example 1 of GraphsInTables
We give two examples here. The first uses old-style answer checkers; the second newer parser based code. Note that the functionality that is provided in either case is different; the latter is syntactically cleaner and simpler, but doesn't have the same range of functions provided by the first.
With Old-Style Answer Checkers
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "PGchoicemacros.pl", ); |
Initialization: Include |
$mc = new_multiple_choice(); $mc->qa( "What is your favorite color?", "blue" ); $mc->extra( "red", "green", ); $mc->makeLast("none of the above"); |
Setup: Create a new multiple choice object with
To make answers appear in a certain order (e.g., Yes followed by No and Maybe), use @quest = ("How many legs do cats have?", "How many legs to ostriches have?"); @ans = ("4","2"); $pick = random(0,1,1); $mc->new_checkbox_multiple_choice(); $mc->qa($quest[$pick],$ans[$pick]); $mc->makeLast("2","4","None of the above"); |
BEGIN_TEXT \{ $mc->print_q() \} $BR \{ $mc->print_a() \} END_TEXT |
Main text: In the text section we print the question and answers. |
$showPartialCorrectAnswers = 0; ANS( radio_cmp( $mc->correct_ans() ) ); ENDDOCUMENT(); |
Answer Evaluation: In most cases we will want to set |
With Newer Answer Checkers
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "parserRadioButtons.pl", ); |
Initialization: Include |
$mc = RadioButtons( [ "Blue", "Red", "Green", "None of the above" ], "Blue" ); |
Setup: We create a radio button object with
To create a drop-down ("pop-up") option (having loaded $mc = PopUp( [ "?", "Blue", "Red", "Green", "None of the above" ], "Blue" ); Note that in this case we should specify a generic non-answer as the first option, so that when the selector is displayed it does not automatically give the student an answer (which may or may not be correct). |
BEGIN_TEXT What color most resembles the sky? $BR \{ $mc->buttons() \} END_TEXT |
Main text: In the text section we print the question and radio buttons giving the answers. For a PopUp object, the call to create the menu of options is |
$showPartialCorrectAnswers = 0; ANS( $mc->cmp() ); ENDDOCUMENT(); |
Answer Evaluation: In most cases we will want to set |