Difference between revisions of "MultipleSelectProblems"
m |
m |
||
Line 43: | Line 43: | ||
<td style="background-color:#ffffdd;border:black 1px dashed;"> |
<td style="background-color:#ffffdd;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | $ |
+ | $mc = new_checkbox_multiple_choice(); |
− | $ |
+ | $mc -> qa ( |
"Select all expressions that are equivalent to |
"Select all expressions that are equivalent to |
||
\( e^{x^2 + 1/x} \). There may be more than |
\( e^{x^2 + 1/x} \). There may be more than |
||
Line 52: | Line 52: | ||
"\( e^{ (x^3+1) / x } \)", |
"\( e^{ (x^3+1) / x } \)", |
||
); |
); |
||
− | $ |
+ | $mc -> extra( |
"\( \displaystyle \frac{ e^{x^2} }{ e^x } \)$BR", |
"\( \displaystyle \frac{ e^{x^2} }{ e^x } \)$BR", |
||
"\( e^{x^2} + e^{1/x} \)", |
"\( e^{x^2} + e^{1/x} \)", |
||
); |
); |
||
# The next line can be uncommented. |
# The next line can be uncommented. |
||
− | # $ |
+ | # $mc->makeLast("All of the above"); |
</pre> |
</pre> |
||
</td> |
</td> |
||
Line 63: | Line 63: | ||
<p> |
<p> |
||
<b>Setup:</b> |
<b>Setup:</b> |
||
− | Create a new checkbox multiple choice object named <code>$ |
+ | Create a new checkbox multiple choice object named <code>$mc</code> with <code>$mc->new_checkbox_multiple_choice();</code>. |
</p> |
</p> |
||
<p> |
<p> |
||
− | Use <code>$ |
+ | Use <code>$mc->qa("question","correct answer 1","correct answer 2");</code> to store the question string and correct answer strings. Note that unlike match lists and select lists, you cannot call <code>qa( )</code> again. If you include math symbols you should switch to LaTeX mode using <code>\( \)</code>, and, if necessary, using <code>\displaystyle</code> and extra spacing <code>$BR</code> after each entry. For example, <code>$mc->qa("question","\( x^2 \)$BR","\( \displaystyle \frac{x^2}{4-x} \)$BR");</code> |
</p> |
</p> |
||
<p> |
<p> |
||
Line 74: | Line 74: | ||
To ensure an answer appears last in the list of options (either a new extra answer or the correct answer), use the <code>makeLast</code> method. All answers not in <code>makeLast()</code> will be shuffled when the multiple choice problem is shown to students, and answers in <code>makeLast</code> will retain their original ordering. For example, if the only correct answer is "None of the above" (or "All of the above"), use |
To ensure an answer appears last in the list of options (either a new extra answer or the correct answer), use the <code>makeLast</code> method. All answers not in <code>makeLast()</code> will be shuffled when the multiple choice problem is shown to students, and answers in <code>makeLast</code> will retain their original ordering. For example, if the only correct answer is "None of the above" (or "All of the above"), use |
||
<pre> |
<pre> |
||
− | $ |
+ | $mc->qa("question","None of the above");</code> |
− | $ |
+ | $mc->extra("very wrong","distractor","red herring"); |
− | $ |
+ | $mc->makeLast("None of the above"); |
</pre> |
</pre> |
||
</p> |
</p> |
||
<p> |
<p> |
||
− | To force answers to appear in a certain order (like Yes followed by No), use <code>$ |
+ | To force answers to appear in a certain order (like Yes followed by No), use <code>$mc->qa("question","Yes"); $mc->makeLast("Yes","No");</code> and do not use <code>extra( )</code> at all. In this case, to randomize the question and answer, where the answer to question 1 is Yes and the answer to question 2 is No, use |
<pre> |
<pre> |
||
@quest = ("question 1","question 2"); |
@quest = ("question 1","question 2"); |
||
@ans = ("Yes","No"); |
@ans = ("Yes","No"); |
||
$pick = random(0,1,1); |
$pick = random(0,1,1); |
||
− | $ |
+ | $mc->new_checkbox_multiple_choice(); |
− | $ |
+ | $mc->qa($quest[$pick],$ans[$pick]); |
− | $ |
+ | $mc->makeLast("Yes","No"); |
</pre> |
</pre> |
||
</p> |
</p> |
||
Line 100: | Line 100: | ||
$BR |
$BR |
||
$BR |
$BR |
||
− | \{ $ |
+ | \{ $mc -> print_q() \} |
$BR |
$BR |
||
− | \{ $ |
+ | \{ $mc -> print_a() \} |
END_TEXT |
END_TEXT |
||
Line 108: | Line 108: | ||
<td style="background-color:#ffcccc;padding:7px;"> |
<td style="background-color:#ffcccc;padding:7px;"> |
||
<p> |
<p> |
||
− | <b>Main Text:</b> Print the question and answers. Print the question text using <code>$ |
+ | <b>Main Text:</b> Print the question and answers. Print the question text using <code>$mc->print_q()</code> and |
− | the list of all answers using <code>$ |
+ | the list of all answers using <code>$mc->print_a()</code>. |
</p> |
</p> |
||
</td> |
</td> |
||
Line 120: | Line 120: | ||
$showPartialCorrectAnswers = 0; |
$showPartialCorrectAnswers = 0; |
||
− | ANS(checkbox_cmp($ |
+ | ANS(checkbox_cmp($mc->correct_ans)); |
ENDDOCUMENT(); |
ENDDOCUMENT(); |
Revision as of 16:30, 1 January 2010
Multiple Select Problems (or Checkbox Multiple Choice or Select All That Apply)
This code snippet shows the essential PG code to include multiple select question (or checkbox multiple choice or select all that apply) in a problem. A multiple choice question has only one correct answer, whereas a checkbox multiple choice question may require several items to be selected at the same time to be correct.
Note that in this example we use old-style checkbox multiple choice answer objects. The new-style MathObjects do not yet have a checkbox multiple choice answer object yet.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PG.pl", "PGbasicmacros.pl", "PGchoicemacros.pl", "PGanswermacros.pl", "PGcourse.pl", ); TEXT(beginproblem()); |
Initialization: We must load |
$mc = new_checkbox_multiple_choice(); $mc -> qa ( "Select all expressions that are equivalent to \( e^{x^2 + 1/x} \). There may be more than one correct answer.", "\( e^{x^2} e^{1/x} \)", "\( e^{x^2} e^{x^{-1}} \)", "\( e^{ (x^3+1) / x } \)", ); $mc -> extra( "\( \displaystyle \frac{ e^{x^2} }{ e^x } \)$BR", "\( e^{x^2} + e^{1/x} \)", ); # The next line can be uncommented. # $mc->makeLast("All of the above"); |
Setup:
Create a new checkbox multiple choice object named
Use
Incorrect answers are specified as a list of arguments to the
To ensure an answer appears last in the list of options (either a new extra answer or the correct answer), use the $mc->qa("question","None of the above");</code> $mc->extra("very wrong","distractor","red herring"); $mc->makeLast("None of the above");
To force answers to appear in a certain order (like Yes followed by No), use @quest = ("question 1","question 2"); @ans = ("Yes","No"); $pick = random(0,1,1); $mc->new_checkbox_multiple_choice(); $mc->qa($quest[$pick],$ans[$pick]); $mc->makeLast("Yes","No"); |
BEGIN_TEXT This is a place to insert additional instructions. $BR $BR \{ $mc -> print_q() \} $BR \{ $mc -> print_a() \} END_TEXT |
Main Text: Print the question and answers. Print the question text using |
install_problem_grader(~~&std_problem_grader); $showPartialCorrectAnswers = 0; ANS(checkbox_cmp($mc->correct_ans)); ENDDOCUMENT(); |
Answer Evaluation: We use the standard problem grader, an all-or-nothing grader that gives no partial credit, and set |