Difference between revisions of "MultipleSelectProblems"
Line 74: | Line 74: | ||
<td style="background-color:#ffdddd;border:black 1px dashed;"> |
<td style="background-color:#ffdddd;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | BEGIN_TEXT |
||
+ | TEXT(beginproblem()); |
||
− | \{ $mc->print_q() \} |
||
+ | |||
− | \{ $mc->print_a() \} |
||
+ | # Print the text using $mc->print_q for the questions and |
||
− | END_TEXT |
||
+ | # $mc->print_a to print the answers. |
||
+ | BEGIN_TEXT |
||
+ | |||
+ | This is the place to insert additional text if you wish. |
||
+ | $PAR |
||
+ | \{ $cmc -> print_q() \} |
||
+ | $PAR |
||
+ | \{ $cmc -> print_a() \} |
||
+ | END_TEXT |
||
</pre> |
</pre> |
||
<td style="background-color:#ffcccc;padding:7px;"> |
<td style="background-color:#ffcccc;padding:7px;"> |
||
Line 88: | Line 96: | ||
<td style="background-color:#eeddff;border:black 1px dashed;"> |
<td style="background-color:#eeddff;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | ANS( radio_cmp( $mc->correct_ans() ) ); |
||
+ | # Enter the correct answers to be checked against the answers to the students. |
||
+ | ANS(checkbox_cmp( $cmc->correct_ans ) ) ; |
||
+ | |||
+ | ENDDOCUMENT(); |
||
</pre> |
</pre> |
||
<td style="background-color:#eeccff;padding:7px;"> |
<td style="background-color:#eeccff;padding:7px;"> |
||
<p> |
<p> |
||
− | And we grade the problem with <code> |
+ | And we grade the problem with <code>checkbox_cmp</code>. |
</p> |
</p> |
||
</td> |
</td> |
Revision as of 21:04, 4 October 2009
Multiple Select Problems (or Checkbox Multiple Choice or Select All That Apply): PG Code Snippet
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 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 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" ); # Do not show which answers are incorrect. $showPartialCorrectAnswers = 0; |
In the initialization section of the file we need to include |
# Make a 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 ( "Please select all vectors that are named.", # question "\(\vec{a} = \langle 1, 1, 1 \rangle \)", # a correct answer "\(\vec{n} = \langle 1, -1, 0 \rangle \)", # another correct answer "\(\vec{z} = \langle 0, 0, 0 \rangle \)", # Use " ... " to enter a string ); # Insert some incorrect answers $cmc -> extra( "\(\langle -2, 2, 2 \rangle\)", "\(\langle \pi, 4, -1 \rangle\)", ); $cmc->makeLast("None of the above"); # Note that unlike match lists and select lists, you cannot call qa() again |
In the problem set-up, we create a new checkbox multiple choice object with |
TEXT(beginproblem()); # Print the text using $mc->print_q for the questions and # $mc->print_a to print the answers. BEGIN_TEXT This is the place to insert additional text if you wish. $PAR \{ $cmc -> print_q() \} $PAR \{ $cmc -> print_a() \} END_TEXT |
In the text section we print the question and answers. |
# Enter the correct answers to be checked against the answers to the students. ANS(checkbox_cmp( $cmc->correct_ans ) ) ; ENDDOCUMENT(); |
And we grade the problem with |