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> |
||
− | # Make a new checkbox multiple choice |
||
$cmc = new_checkbox_multiple_choice(); |
$cmc = new_checkbox_multiple_choice(); |
||
− | # $cmc now "contains" the checkbox multiple choice object. |
||
− | |||
− | # Insert a question and matching answers in the q/a list |
||
$cmc -> qa ( |
$cmc -> qa ( |
||
− | " |
+ | "Select all expressions that are equivalent to " . |
− | "\( e^{x^2 |
+ | "\( e^{x^2 + 1/x} \). There may be more than " . |
− | " |
+ | "one correct answer.", |
− | "\( e^{ |
+ | "\( e^{x^2} e^{1/x} \)", |
− | + | "\( e^{x^2} e^{x^{-1}} \)", |
|
− | + | "\( e^{ (x^3+1) / x } \)", |
|
); |
); |
||
− | # If the only correct answer is "All of the above" |
||
− | # or "None of the above", uncomment the |
||
− | # "All of the above" or "None of the above" string |
||
− | # above and remove all other correct answers from the list |
||
− | |||
− | |||
− | # Insert some incorrect answers |
||
$cmc -> extra( |
$cmc -> extra( |
||
− | "\( e^{ |
+ | "\( \displaystyle \frac{ e^{x^2} }{ e^x } \)$BR", |
− | "\( e^{x^2} e^{-x} \)", |
||
− | "\( e^{x^2} e^{-x} \)", |
||
− | "\( \displaystyle \frac{ e^{x^2} }{ e^x } \)", |
||
"\( e^{x^2} + e^{1/x} \)", |
"\( e^{x^2} + e^{1/x} \)", |
||
− | "\( e^{x^2} + e^{-x} \)", |
||
); |
); |
||
− | |||
# The next line can be uncommented. |
# The next line can be uncommented. |
||
# $cmc->makeLast("All of the above"); |
# $cmc->makeLast("All of the above"); |
||
− | |||
− | # Note that unlike match lists and select lists, you cannot call qa() again |
||
</pre> |
</pre> |
||
</td> |
</td> |
||
<td style="background-color:#ffffcc;padding:7px;"> |
<td style="background-color:#ffffcc;padding:7px;"> |
||
<p> |
<p> |
||
− | Setup: Create a new checkbox multiple choice object with <code>new_checkbox_multiple_choice</code>, and then store the question and correct answer with the <code>qa</code> method. Other answers are specified as a list of arguments to the <code>extra</code> method. To force an answer (either a new extra answer, or the correct answer) to appear last in the list of options, use the <code>makeLast</code> method. All other answers will be scrambled when the multiple choice problem is shown to students. |
||
+ | <b>Setup:</b> |
||
+ | Create a new checkbox multiple choice object <code>$cmc</code>with <code>$cmc->new_checkbox_multiple_choice();</code>. |
||
+ | </p> |
||
+ | <p> |
||
+ | Use <code>$cmc->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. |
||
+ | </p> |
||
+ | <p> |
||
+ | Incorrect answers are specified as a list of arguments to the <code>extra</code> method. |
||
+ | </p> |
||
+ | <p> |
||
+ | To force an answer (either a new extra answer, or the correct answer) to appear last in the list of options, use the <code>makeLast</code> method. All answers not in <code>makeLast()</code> will be scrambled when the multiple choice problem is shown to students. If the only correct answer is "None of the above" (or "All of the above"), use |
||
+ | <pre> |
||
+ | $cmc->qa("question","None of the above");</code> |
||
+ | $cmc->extra("very wrong 1","distractor 2","red herring 3"); |
||
+ | $cmc->makeLast("None of the above"); |
||
+ | </pre> |
||
+ | </p> |
||
+ | <p> |
||
+ | To force answers to appear in a certain order (like Yes followed by No), use only <code>$cmc->qa("question","Yes"); $cmc->makeLast("Yes","No");</code> and do not use <code>extra( )</code> at all. In this case, to randomize the question and answer, use |
||
+ | <pre> |
||
+ | @quest = ("question 1","question 2"); |
||
+ | @ans = ("Yes","No"); |
||
+ | $pick = random(0,1,1); |
||
+ | $cmc->new_checkbox_multiple_choice(); |
||
+ | $cmc->qa($quest[$pick],$ans[$pick]); |
||
+ | $cmc->makeLast("Yes","No"); |
||
+ | </pre> |
||
</p> |
</p> |
||
</td> |
</td> |
||
Line 84: | Line 95: | ||
<td style="background-color:#ffdddd;border:black 1px dashed;"> |
<td style="background-color:#ffdddd;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | # Print the text using $cmc->print_q() for the questions and |
||
− | # $cmc->print_a() to print the answers. |
||
BEGIN_TEXT |
BEGIN_TEXT |
||
Line 97: | Line 106: | ||
<td style="background-color:#ffcccc;padding:7px;"> |
<td style="background-color:#ffcccc;padding:7px;"> |
||
<p> |
<p> |
||
− | Main Text: Print the question and answers. |
+ | Main Text: Print the question and answers. Print the question text using <code>$cmc->print_q()</code> and |
+ | the list of all answers using <code>$cmc->print_a()</code>. |
||
</p> |
</p> |
||
</td> |
</td> |
Revision as of 15:55, 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 |
$cmc = new_checkbox_multiple_choice(); $cmc -> 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 } \)", ); $cmc -> extra( "\( \displaystyle \frac{ e^{x^2} }{ e^x } \)$BR", "\( e^{x^2} + e^{1/x} \)", ); # The next line can be uncommented. # $cmc->makeLast("All of the above"); |
Setup:
Create a new checkbox multiple choice object
Use
Incorrect answers are specified as a list of arguments to the
To force an answer (either a new extra answer, or the correct answer) to appear last in the list of options, use the $cmc->qa("question","None of the above");</code> $cmc->extra("very wrong 1","distractor 2","red herring 3"); $cmc->makeLast("None of the above");
To force answers to appear in a certain order (like Yes followed by No), use only @quest = ("question 1","question 2"); @ans = ("Yes","No"); $pick = random(0,1,1); $cmc->new_checkbox_multiple_choice(); $cmc->qa($quest[$pick],$ans[$pick]); $cmc->makeLast("Yes","No"); |
BEGIN_TEXT This is a place to insert additional text if you wish. $PAR \{ $cmc -> print_q() \} $PAR \{ $cmc -> 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($cmc->correct_ans)); ENDDOCUMENT(); |
Answer Evaluation: Grade the problem with |