Difference between revisions of "MultipleChoiceRadio1"
Jump to navigation
Jump to search
Paultpearson (talk | contribs) |
Paultpearson (talk | contribs) m |
||
Line 152: | Line 152: | ||
[[Category:Top]] |
[[Category:Top]] |
||
− | [[Category:Authors]] |
||
[[Category:Sample Problems]] |
[[Category:Sample Problems]] |
||
[[Category:Subject Area Templates]] |
[[Category:Subject Area Templates]] |
Revision as of 15:20, 3 January 2012
Multiple Choice Question with Radio Buttons
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:MultipleChoiceRadio1.txt (change the file extension from txt to pg when you save it)
- File location in NPL:
FortLewis/Authoring/Templates/Misc/MultipleChoiceRadio1.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserRadioButtons.pl", ); TEXT(beginproblem()); |
Initialization:
We need |
Context("Numeric"); $radio = RadioButtons( ["Red","Blue","Green","None of these"], "Blue", # correct answer last => ["None of these"], # can be a list ); |
Setup:
To create a radio object, use |
Context()->texStrings; BEGIN_TEXT My favorite color is $BR $BR \{ $radio->buttons() \} END_TEXT Context()->normalStrings; |
Main Text: |
install_problem_grader(~~&std_problem_grader); $showPartialCorrectAnswers = 0; ANS( $radio->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 \{ $radio->correct_ans() \} END_SOLUTION Context()->normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT(); |
Solution: |