Difference between revisions of "MultipleChoiceProblems"
m |
|||
Line 60: | Line 60: | ||
</p> |
</p> |
||
<p> |
<p> |
||
− | To make answers appear in a certain order (e.g., Yes followed by No and Maybe), use <code>$mc->qa("question","Yes"); $mc->makeLast("Yes","No","Maybe");</code> and do not use <code>extra( )</code> at all. |
+ | To make answers appear in a certain order (e.g., Yes followed by No and Maybe), use <code>$mc->qa("question","Yes"); $mc->makeLast("Yes","No","Maybe");</code> and do not use <code>extra( )</code> at all. Note that if we have a list of questions (and correct answers) it is easy to randomly pick one to display. For example, if we want to pick between the questions "How many legs do cats have?" and "How many legs to ostriches have?", we could use the following: |
<pre> |
<pre> |
||
− | @quest = (" |
+ | @quest = ("How many legs do cats have?", |
− | + | "How many legs to ostriches have?"); |
|
+ | @ans = ("4","2"); |
||
$pick = random(0,1,1); |
$pick = random(0,1,1); |
||
$mc->new_checkbox_multiple_choice(); |
$mc->new_checkbox_multiple_choice(); |
||
$mc->qa($quest[$pick],$ans[$pick]); |
$mc->qa($quest[$pick],$ans[$pick]); |
||
− | $mc->makeLast(" |
+ | $mc->makeLast("2","4","None of the above"); |
</pre> |
</pre> |
||
</p> |
</p> |
||
Line 90: | Line 90: | ||
<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; |
$showPartialCorrectAnswers = 0; |
||
Line 100: | Line 98: | ||
<td style="background-color:#eeccff;padding:7px;"> |
<td style="background-color:#eeccff;padding:7px;"> |
||
<p> |
<p> |
||
− | <b>Answer Evaluation:</b> |
+ | <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 with <code>radio_cmp</code>. |
We grade the problem with <code>radio_cmp</code>. |
||
</p> |
</p> |
Revision as of 13:50, 26 March 2010
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
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 |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "PGchoicemacros.pl", ); TEXT(beginproblem()); |
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 |