Difference between revisions of "MultipleChoiceCheckbox3"

From WeBWorK_wiki
Jump to navigation Jump to search
(add historical tag and give links to newer problems.)
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
  +
{{historical}}
  +
  +
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Misc/MultipleChoiceCheckbox.html a newer version of this problem]</p>
  +
  +
 
<h2>Multiple Choice with Checkboxes</h2>
 
<h2>Multiple Choice with Checkboxes</h2>
   
 
[[File:MultipleChoiceCheckbox3.png|300px|thumb|right|Click to enlarge]]
 
[[File:MultipleChoiceCheckbox3.png|300px|thumb|right|Click to enlarge]]
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;">
+
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;">
 
This PG code shows how to write a multiple choice question with possibly more than one correct answer by using checkboxes.
 
This PG code shows how to write a multiple choice question with possibly more than one correct answer by using checkboxes.
 
</p>
 
</p>
* Download file: [[File:MultipleChoiceCheckbox3.txt]] (change the file extension from txt to pg when you save it)
 
  +
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Misc/MultipleChoiceCheckbox3.pg FortLewis/Authoring/Templates/Misc/MultipleChoiceCheckbox3.pg]
* File location in NPL: <code>FortLewis/Authoring/Templates/Misc/MultipleChoiceCheckbox3.pg</code>
 
  +
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Misc/MultipleChoiceCheckbox3_PGML.pg FortLewis/Authoring/Templates/Misc/MultipleChoiceCheckbox3_PGML.pg]
   
 
<br clear="all" />
 
<br clear="all" />
Line 70: Line 75:
 
\( e^{x^2 + 1/x} \). There may be more than
 
\( e^{x^2 + 1/x} \). There may be more than
 
one correct answer.",
 
one correct answer.",
"\( e^{x^2} e^{1/x} \)$BR",
+
"\( e^{x^2} e^{1/x} \) $BR",
"\( e^{x^2} e^{x^{-1}} \)$BR",
+
"\( e^{x^2} e^{x^{-1}} \) $BR",
"\( e^{ (x^3+1) / x } \)$BR",
 
 
);
 
);
   
 
$mc -> extra(
 
$mc -> extra(
"\( \displaystyle \frac{ e^{x^2} }{ e^x } \)$BR",
+
"\( \displaystyle \frac{ e^{x^2} }{ e^x } \) $BR",
"\( e^{x^2} + e^{1/x} \)$BR",
 
 
);
 
);
   
Line 86: Line 91:
 
Use the question and answer method <code>qa( )</code> to store the question string and correct answer strings in <code>$mc</code>. For example, <code>$mc->qa("question","correct answer 1","correct answer 2");</code>. Note that unlike match lists and select lists, you cannot call the <code>qa( )</code> method again. If you include math symbols you should switch to LaTeX mode <code>\( \)</code>, and use <code>\displaystyle</code> with extra spacing <code>$BR</code> after each entry, if necessary. For example, <pre>
 
Use the question and answer method <code>qa( )</code> to store the question string and correct answer strings in <code>$mc</code>. For example, <code>$mc->qa("question","correct answer 1","correct answer 2");</code>. Note that unlike match lists and select lists, you cannot call the <code>qa( )</code> method again. If you include math symbols you should switch to LaTeX mode <code>\( \)</code>, and use <code>\displaystyle</code> with extra spacing <code>$BR</code> after each entry, if necessary. For example, <pre>
 
$mc->qa(
 
$mc->qa(
"question", "\( x^2 \) $BR",
 
  +
"Question text here.",
  +
"\( x^2 \) $BR",
 
"\( \displaystyle \frac{x^2}{4-x} \) $BR"
 
"\( \displaystyle \frac{x^2}{4-x} \) $BR"
 
);
 
);
Line 157: Line 163:
 
Context()->texStrings;
 
Context()->texStrings;
 
BEGIN_SOLUTION
 
BEGIN_SOLUTION
${PAR}SOLUTION:${PAR}
+
${PAR}SOLUTION:$PAR
Solution explanation goes here.
+
The correct answer is \{ $mc->correct_ans() \}
 
END_SOLUTION
 
END_SOLUTION
 
Context()->normalStrings;
 
Context()->normalStrings;
Line 180: Line 186:
   
 
[[Category:Top]]
 
[[Category:Top]]
[[Category:Authors]]
+
[[Category:Sample Problems]]
  +
[[Category:Subject Area Templates]]

Latest revision as of 06:20, 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 with Checkboxes

Click to enlarge

This PG code shows how to write a multiple choice question with possibly more than one correct answer by using checkboxes.


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();  

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

TEXT(beginproblem());

Initialization:

$mc = new_checkbox_multiple_choice();

$mc -> qa (
"Select all expressions that are equivalent to  
\( e^{x^2 + 1/x} \).  There may be more than
one correct answer.", 
"\( e^{x^2} e^{1/x} \) $BR",
"\( e^{x^2} e^{x^{-1}} \) $BR",                
);

$mc -> extra(
"\( \displaystyle \frac{ e^{x^2} }{ e^x } \) $BR",
);

$mc -> makeLast("None of the above");

Setup: Use the question and answer method qa( ) to store the question string and correct answer strings in $mc. For example, $mc->qa("question","correct answer 1","correct answer 2");. Note that unlike match lists and select lists, you cannot call the qa( ) method again. If you include math symbols you should switch to LaTeX mode \( \), and use \displaystyle with extra spacing $BR after each entry, if necessary. For example,

$mc->qa(
"Question text here.", 
"\( x^2 \) $BR", 
"\( \displaystyle \frac{x^2}{4-x} \) $BR" 
);

Incorrect answers are specified as a list of string arguments to the extra( ) method.

The arguments of the makeLast( ) method will appear at the end of the list and will not be shuffled, unlike the arguments of extra( ), which are shuffled. The arguments to makeLast( ) can either be a new extra answers or only the correct answer. For example, if the only correct answer is "None of the above", use

$mc->qa("question","None of the above");
$mc->extra("very wrong","distractor","red herring");
$mc->makeLast("None of the above");

To make answers appear in a certain order (e.g., Yes followed by No and Maybe), use $mc->qa("question","Yes"); $mc->makeLast("Yes","No","Maybe"); and do not use extra( ) at all.

Context()->texStrings;
BEGIN_TEXT
Additional instructions can be put here.
$BR
\{ $mc -> print_q() \}
$BR
\{ $mc -> print_a() \}
END_TEXT
Context()->normalStrings;

Main Text: Print the question and answers. Print the question text using $mc->print_q() and the list of all answers using $mc->print_a().

install_problem_grader(~~&std_problem_grader);

$showPartialCorrectAnswers = 0;

ANS( checkbox_cmp( $mc->correct_ans() ) );

Answer Evaluation:

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

COMMENT('MathObject version.');

ENDDOCUMENT();

Solution:

Templates by Subject Area