Forum archive 2000-2006

Robert (Rochester ugrad) - Multiple Choice example

Robert (Rochester ugrad) - Multiple Choice example

by Arnold Pizer -
Number of replies: 0
inactiveTopicMultiple Choice example topic started 7/31/2000; 2:08:10 PM
last post 7/31/2000; 2:08:10 PM
userRobert (Rochester ugrad) - Multiple Choice example  blueArrow
7/31/2000; 2:08:10 PM (reads: 3158, responses: 0)

(1 pt) rochesterLibrary/setMAAtutorial/multiplechoiceexample.pg

Multiple choice example

What is the derivative of tan(x)?


A. \cos^3(x)
B. \cosh(x)
C. -\cot(x)
D. \sec^2(x)
E. \sin(x)
F. \text{sech}(x)
G. \tan(x)

 

 


WARNINGS
µ¦å{h­
DOCUMENT();        # This should be the first executable line in the problem.
loadMacros("PGbasicmacros.pl",
"PGchoicemacros.pl",
"PGanswermacros.pl",

);
TEXT(beginproblem(), $BR,$BBOLD, "Multiple choice example", $EBOLD, $BR,$BR);

$showPartialCorrectAnswers = 0;
# Make a new multiple choice object.
$mc = new_multiple_choice();
# $mc now "contains" the multiple choice object.

# Insert some questions and matching answers in the q/a list
$mc -> qa (# Notice that the first string is the question
"What is the derivative of tan(x)?",
# The second string is the correct answer
"\( \sec^2(x) \)",
);
$mc ->extra(
"\( -\cot(x) \)",
"\( \tan(x) \)",
# Use double quotes " ... " to enter a string
"\( \cosh(x) \)",
"\( \sin(x) \)",
"\( \cos^3(x) \)",
"\( \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.

<| Post or View Comments |>