Difference between revisions of "MultipleChoicePopup2"

From WeBWorK_wiki
Jump to navigation Jump to search
Line 89: Line 89:
 
Context()->texStrings;
 
Context()->texStrings;
 
BEGIN_TEXT
 
BEGIN_TEXT
My favorite color is
+
Is my favorite color red, blue, or green?
 
\{ $popup->menu() \}
 
\{ $popup->menu() \}
 
END_TEXT
 
END_TEXT
Line 97: Line 97:
 
<p>
 
<p>
 
<b>Main Text:</b>
 
<b>Main Text:</b>
  +
Since popup menus hide their choices, we write the entire list of choices into the question. It is essential to do this, otherwise a student who is working from a PDF copy of their homework won't know what the options are and won't be able to answer the question.
 
</p>
 
</p>
 
</td>
 
</td>

Revision as of 01:09, 5 December 2010

Multiple Choice Question with a Popup Menu

Click to enlarge

This PG code shows how to write a multiple choice question in which all of the options are displayed to the student and the student can only choose one correct answer (it uses radio buttons).

  • Download file: File:MultipleChoicePopup2.txt (change the file extension from txt to pg when you save it)
  • File location in NPL: FortLewis/Authoring/Templates/Misc/MultipleChoicePopup2.pg



Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserPopUp.pl",
);

TEXT(beginproblem());

Initialization: We need parserPopUp.pl

Context("Numeric");

$popup = PopUp(
  ["?","Red","Blue","Green"],
  "Blue",
);

Setup: To create a radio object, use $popup = PopUp([choices,...],correct); For details, see parserPopUp.pl.html The context is not really necessary, but multiple choice questions are often follow-up questions, so we leave it in.

Context()->texStrings;
BEGIN_TEXT
Is my favorite color red, blue, or green?
\{ $popup->menu() \}
END_TEXT
Context()->normalStrings;

Main Text: Since popup menus hide their choices, we write the entire list of choices into the question. It is essential to do this, otherwise a student who is working from a PDF copy of their homework won't know what the options are and won't be able to answer the question.

install_problem_grader(~~&std_problem_grader);

$showPartialCorrectAnswers = 0;

ANS( $popup->cmp() );

Answer Evaluation: We withhold feedback by choosing not to show partially correct answers. We use the standard problem grader, which gives full credit or no credit. For other graders, see weighted graders

Context()->texStrings;
BEGIN_SOLUTION
${PAR}SOLUTION:$PAR
The correct answer is \{ $popup->correct_ans() \}
END_SOLUTION
Context()->normalStrings;

COMMENT('MathObject version.');

ENDDOCUMENT();

Solution:

Templates by Subject Area