Difference between revisions of "MultipleChoiceProblems"
m |
m |
||
Line 2: | Line 2: | ||
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
||
− | <em>This code snippet shows the essential PG code to include multiple-choice |
+ | <em>This code snippet shows the essential PG code to include a multiple-choice question in a problem.</em> |
</p> |
</p> |
||
Revision as of 12:34, 2 January 2010
Multiple Choice Problems: PG Code Snippet
This code snippet shows the essential PG code to include a multiple-choice question in a problem.
Note that in this example we use old-style multiple choice answer objects. The new-style MathObjects have a multiple choice object as well, but its behavior is sufficiently different than that suggested here that is not documented here.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PG.pl", "PGbasicmacros.pl", "PGchoicemacros.pl", "PGanswermacros.pl", "PGcourse.pl", ); TEXT(beginproblem()); |
Initialization: Include |
$mc = new_multiple_choice(); $mc->qa( "What is your favorite color?", "blue" ); $mc->extra( "red", "green" ); $mc->makeLast("none of the above"); |
Setup: Create a new multiple choice object with
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: In the text section we print the question and answers. |
install_problem_grader(~~&std_problem_grader); $showPartialCorrectAnswers = 0; ANS( radio_cmp( $mc->correct_ans() ) ); ENDDOCUMENT(); |
Answer Evaluation: Use the standard problem grader to give credit only if all answers are correct, and do not give feedback on partial correct answers. Otherwise, students can use the feedback or the partial credit received to guess and check if their answers are correct.
We grade the problem with |