topic started 7/31/2000; 2:08:10 PM last post 7/31/2000; 2:08:10 PM |
7/31/2000; 2:08:10 PM (reads: 3158, responses: 0) |
|
(1 pt) rochesterLibrary/setMAAtutorial/multiplechoiceexample.pg
WARNINGS µ¦å{h <hr noshade="noshade" /> <pre>DOCUMENT(); # This should be the first executable line in the problem.<br />loadMacros("PGbasicmacros.pl",<br /> "PGchoicemacros.pl",<br /> "PGanswermacros.pl",<br /><br />);<br />TEXT(beginproblem(), $BR,$BBOLD, "Multiple choice example", $EBOLD, $BR,$BR);<br /><br />$showPartialCorrectAnswers = 0;<br /># Make a new multiple choice object.<br />$mc = new_multiple_choice();<br /># $mc now "contains" the multiple choice object.<br /><br /># Insert some questions and matching answers in the q/a list<br />$mc -> qa (# Notice that the first string is the question<br /> "What is the derivative of tan(x)?",<br /> # The second string is the correct answer<br /> "\( \sec^2(x) \)", <br />);<br />$mc ->extra( <br /> "\( -\cot(x) \)", <br /> "\( \tan(x) \)", <br /> # Use double quotes " ... " to enter a string<br /> "\( \cosh(x) \)",<br /> "\( \sin(x) \)",<br /> "\( \cos^3(x) \)",<br /> "\( \text{sech}(x) \)" # Remember that in these strings we are only specifying typography, # via TeX, not any calculational rules. ); # Print the question using $mc->print_q # Use $mc->print_a to print the list of possible answers. # These need to be done inside BEGIN_TEXT/END_TEXT to make sure that the # equations inside the questions and answers are processed properly. BEGIN_TEXT \{$mc -> print_q \} $PAR \{$mc -> print_a\} END_TEXT # Enter the correct answers to be checked against the answers to the students. ANS(str_cmp( $mc->correct_ans ) ) ; ENDDOCUMENT(); Create a multiple choice question using the new_multiple_choice call. Use qa() to enter the question and the correct answer. Any duplicates will be eliminated. After calling qa you can use extra() to add in extra incorrect answers that (along with the correct answer) will be made into a random list of answers shown to the student. If you want certain answers to be at the end of the list instead of having them be randomized you can use makeLast to add specific answers to the end of the list of answers or to force already existing answers to be moved to the end of the list. This is usually done for 'None of the above', or 'All of the above' type answers. Note that if 'None of the above' is the correct answer then you must put it in qa() and then also makeLast() but the duplicate will be eliminated. If more than one extra answer is added via makeLast, they are added in the same order they are given in makeLast. Now you would start your problem with a C<BEGIN_TEXT> tag and print the questions and answers with the print_q() and print_a() commands. Within the C<BEGIN_TEXT/END_TEXT block>, all calls to objects must be enclosed in ( ). (The $PAR start a new paragraph by printing a blank line). Now all that''s left is sending the students answers to the answer evaluator along with the correct answers so that the students answers can be checked and a score can be given. This is done using C<ANS>, an answer evaluator and the C<correct_ans> variable. |