Difference between revisions of "MultipleSelectProblems"
m |
m |
||
Line 68: | Line 68: | ||
</p> |
</p> |
||
<p> |
<p> |
||
− | Incorrect answers are specified as a list of arguments to the <code>extra( )</code> method. |
+ | Incorrect answers are specified as a list of string arguments to the <code>extra( )</code> method. |
</p> |
</p> |
||
<p> |
<p> |
||
− | The arguments of the <code>makeLast( )</code> method will appear at the end of the list and will not be shuffled, unlike the arguments of <code>extra( )</code>, which are shuffled. The arguments to <code>makeLast( )</code> can either be a new extra |
+ | The arguments of the <code>makeLast( )</code> method will appear at the end of the list and will not be shuffled, unlike the arguments of <code>extra( )</code>, which are shuffled. The arguments to <code>makeLast( )</code> can either be a new extra answers or only the correct answer. For example, if the only correct answer is "None of the above", use |
<pre> |
<pre> |
||
$mc->qa("question","None of the above"); |
$mc->qa("question","None of the above"); |
||
Line 79: | Line 79: | ||
</p> |
</p> |
||
<p> |
<p> |
||
− | To make answers appear in a certain order (e.g., 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 |
+ | 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. 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"); |
||
Line 86: | Line 86: | ||
$mc->new_checkbox_multiple_choice(); |
$mc->new_checkbox_multiple_choice(); |
||
$mc->qa($quest[$pick],$ans[$pick]); |
$mc->qa($quest[$pick],$ans[$pick]); |
||
− | $mc->makeLast("Yes","No"); |
+ | $mc->makeLast("Yes","No","Maybe"); |
</pre> |
</pre> |
||
</p> |
</p> |
||
Line 96: | Line 96: | ||
BEGIN_TEXT |
BEGIN_TEXT |
||
− | This is a place to insert additional instructions. |
||
− | $BR |
||
− | $BR |
||
\{ $mc -> print_q() \} |
\{ $mc -> print_q() \} |
||
$BR |
$BR |
Revision as of 12:06, 2 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} \)$BR", "\( e^{x^2} e^{x^{-1}} \)$BR", "\( e^{ (x^3+1) / x } \)$BR", ); $mc -> extra( "\( \displaystyle \frac{ e^{x^2} }{ e^x } \)$BR", "\( e^{x^2} + e^{1/x} \)$BR", ); $mc -> makeLast("None of the above"); |
Setup:
Create a new checkbox multiple choice object named
Use the question and answer method
Incorrect answers are specified as a list of string arguments to the
The arguments of the $mc->qa("question","None of the above"); $mc->extra("very wrong","distractor","red herring"); $mc->makeLast("None of the above");
To make answers appear in a certain order (e.g., Yes followed by No and Maybe), 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","Maybe"); |
BEGIN_TEXT \{ $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 |