Difference between revisions of "MultipleChoiceRadio1"

From WeBWorK_wiki
Jump to navigation Jump to search
(Created page with '<h2>Insert Title Here</h2> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> This PG code shows how to ... <ul> <li>Download file: File:filename.txt (…')
 
(add historical tag and give links to newer problems.)
 
(16 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<h2>Insert Title Here</h2>
 
  +
{{historical}}
   
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;">
 
  +
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Misc/MultipleChoiceRadio.html a newer version of this problem]</p>
This PG code shows how to ...
 
  +
<ul>
 
  +
<li>Download file: [[File:filename.txt]] (change the file extension from txt to pg)</li>
 
  +
<h2>Multiple Choice Question with Radio Buttons</h2>
<li>File location in NPL: <code>NationalProblemLibrary/FortLewis/Authoring/Templates/...</code></li>
 
  +
</ul>
 
  +
[[File:MultipleChoiceRadio1.png|300px|thumb|right|Click to enlarge]]
  +
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;">
  +
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).
 
</p>
 
</p>
  +
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Misc/MultipleChoiceRadio1.pg FortLewis/Authoring/Templates/Misc/MultipleChoiceRadio1.pg]
  +
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Misc/MultipleChoiceRadio1_PGML.pg FortLewis/Authoring/Templates/Misc/MultipleChoiceRadio1_PGML.pg]
   
  +
<br clear="all" />
 
<p style="text-align:center;">
 
<p style="text-align:center;">
 
[[SubjectAreaTemplates|Templates by Subject Area]]
 
[[SubjectAreaTemplates|Templates by Subject Area]]
Line 54: Line 59:
 
<p>
 
<p>
 
<b>Initialization:</b>
 
<b>Initialization:</b>
</p>
 
  +
We need <code>parserRadioButtons.pl</code></p>
 
</td>
 
</td>
 
</tr>
 
</tr>
Line 66: Line 71:
 
Context("Numeric");
 
Context("Numeric");
   
$answer = Compute("1");
 
  +
$radio = RadioButtons(
  +
["Red","Blue","Green","None of these"],
  +
"Blue", # correct answer
  +
last => ["None of these"], # can be a list
  +
);
 
</pre>
 
</pre>
 
</td>
 
</td>
Line 72: Line 81:
 
<p>
 
<p>
 
<b>Setup:</b>
 
<b>Setup:</b>
  +
To create a radio object, use <code>$radio = RadioButtons([choices,...],correct,options);</code>
  +
For all options, see [[MultipleChoiceProblems]] and [http://webwork.maa.org/pod/pg/macros/parserRadioButtons.html parserRadioButtons.pl]. The context is not really necessary, but multiple choice questions are often follow-up questions, so we leave it in.
 
</p>
 
</p>
 
</td>
 
</td>
Line 83: Line 94:
 
Context()->texStrings;
 
Context()->texStrings;
 
BEGIN_TEXT
 
BEGIN_TEXT
Question text
 
  +
My favorite color is
 
$BR
 
$BR
 
$BR
 
$BR
Answer =
 
  +
\{ $radio->buttons() \}
\{ ans_rule(20) \}
 
\{ AnswerFormatHelp("formulas") \}
 
 
END_TEXT
 
END_TEXT
 
Context()->normalStrings;
 
Context()->normalStrings;
Line 104: Line 113:
 
<td style="background-color:#eeddff;border:black 1px dashed;">
 
<td style="background-color:#eeddff;border:black 1px dashed;">
 
<pre>
 
<pre>
$showPartialCorrectAnswers = 1;
 
  +
install_problem_grader(~~&std_problem_grader);
   
ANS( $answer->cmp() );
 
  +
$showPartialCorrectAnswers = 0;
  +
  +
ANS( $radio->cmp() );
 
</pre>
 
</pre>
 
<td style="background-color:#eeccff;padding:7px;">
 
<td style="background-color:#eeccff;padding:7px;">
 
<p>
 
<p>
 
<b>Answer Evaluation:</b>
 
<b>Answer Evaluation:</b>
  +
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 [http://webwork.maa.org/wiki/WeightedGrader weighted graders]
 
</p>
 
</p>
 
</td>
 
</td>
Line 120: Line 133:
 
<td style="background-color:#ddddff;border:black 1px dashed;">
 
<td style="background-color:#ddddff;border:black 1px dashed;">
 
<pre>
 
<pre>
 
 
Context()->texStrings;
 
Context()->texStrings;
 
BEGIN_SOLUTION
 
BEGIN_SOLUTION
${PAR}SOLUTION:${PAR}
+
${PAR}SOLUTION:$PAR
Solution explanation goes here.
+
The correct answer is \{ $radio->correct_ans() \}
 
END_SOLUTION
 
END_SOLUTION
 
Context()->normalStrings;
 
Context()->normalStrings;
Line 145: Line 157:
   
 
[[Category:Top]]
 
[[Category:Top]]
[[Category:Authors]]
+
[[Category:Sample Problems]]
  +
[[Category:Subject Area Templates]]

Latest revision as of 06:17, 17 July 2023

This article has been retained as a historical document. It is not up-to-date and the formatting may be lacking. Use the information herein with caution.

This problem has been replaced with a newer version of this problem


Multiple Choice Question with Radio Buttons

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).


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();

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

TEXT(beginproblem());

Initialization: We need parserRadioButtons.pl

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 $radio = RadioButtons([choices,...],correct,options); For all options, see MultipleChoiceProblems and parserRadioButtons.pl. The context is not really necessary, but multiple choice questions are often follow-up questions, so we leave it in.

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:

Templates by Subject Area