Difference between revisions of "MultipleChoiceProblems"
m |
m |
||
Line 21: | Line 21: | ||
<td style="background-color:#ddffdd;border:black 1px dashed;"> |
<td style="background-color:#ddffdd;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | + | loadMacros("PGchoicemacros.pl"); |
|
</pre> |
</pre> |
||
</td> |
</td> |
||
Line 33: | Line 33: | ||
<td style="background-color:#ffffdd;border:black 1px dashed;"> |
<td style="background-color:#ffffdd;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | + | $mc = new_multiple_choice(); |
|
− | + | $mc->qa("What is your favorite color?", "blue"); |
|
− | + | $mc->extra("red","green"); |
|
− | + | $mc->makeLast("none of the above"); |
|
</pre> |
</pre> |
||
</td> |
</td> |
||
Line 48: | Line 48: | ||
<td style="background-color:#ffdddd;border:black 1px dashed;"> |
<td style="background-color:#ffdddd;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | + | BEGIN_TEXT |
|
− | + | \{ $mc->print_q() \} |
|
− | + | \{ $mc->print_a() \} |
|
− | + | END_TEXT |
|
</pre> |
</pre> |
||
<td style="background-color:#ffcccc;padding:7px;"> |
<td style="background-color:#ffcccc;padding:7px;"> |
||
Line 62: | Line 62: | ||
<td style="background-color:#eeddff;border:black 1px dashed;"> |
<td style="background-color:#eeddff;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | + | install_problem_grader(~~&std_problem_grader); |
|
− | + | $showPartialCorrectAnswers = 0; |
|
− | + | ANS( radio_cmp( $mc->correct_ans() ) ); |
|
</pre> |
</pre> |
||
<td style="background-color:#eeccff;padding:7px;"> |
<td style="background-color:#eeccff;padding:7px;"> |
Revision as of 18:02, 7 November 2009
Multiple Choice Problems: PG Code Snippet
This code snippet shows the essential PG code to include multiple-choice questions in a problem. Note that these are insertions, not a complete PG file. This code will have to be incorporated into the problem file on which you are working.
Note that in this example we use old-style multiple choice answer objects. The new-style MathObjects have a multiple choice object as well, but its behavior is sufficiently different than that suggested here that is not documented here.
PG problem file | Explanation |
---|---|
loadMacros("PGchoicemacros.pl"); |
In the initialization section of the file we need to include |
$mc = new_multiple_choice(); $mc->qa("What is your favorite color?", "blue"); $mc->extra("red","green"); $mc->makeLast("none of the above"); |
In the problem set-up, we create a new multiple choice object with |
BEGIN_TEXT \{ $mc->print_q() \} \{ $mc->print_a() \} END_TEXT |
In the text section we print the question and answers. |
install_problem_grader(~~&std_problem_grader); $showPartialCorrectAnswers = 0; ANS( radio_cmp( $mc->correct_ans() ) ); |
Use the standard problem grader to give credit only if all answers are correct, and do not give feedback on partial correct answers. Otherwise, students can use the feedback or the partial credit received to guess and check if their answers are correct.
We grade the problem with |