Difference between revisions of "FormulaAnswer1"

From WeBWorK_wiki
Jump to navigation Jump to search
(Add link to PGML version in OPL)
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<h2>Answer is a Number or a Formula</h2>
+
<h2>Answer is a Number or a Formula - [https://testcourses.webwork.maa.org/webwork2/Problem_Authoring_Techniques/T-PP-misc/1 Try it out]</h2>
   
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;">
 
  +
[[File:FormulaAnswer1.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 question whose answer is a number or a formula.
 
This PG code shows how to write a question whose answer is a number or a formula.
<ul>
 
<li>Download file: [[File:FormulaAnswer1.txt]] (change the file extension from txt to pg when you save it)</li>
 
<li>File location in NPL: <code>NationalProblemLibrary/FortLewis/Authoring/Templates/Misc/FormulaAnswer1.pg</code></li>
 
</ul>
 
 
</p>
 
</p>
  +
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Misc/FormulaAnswer1.pg FortLewis/Authoring/Templates/Misc/FormulaAnswer1.pg]
  +
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Misc/FormulaAnswer1_PGML.pg FortLewis/Authoring/Templates/Misc/FormulaAnswer1_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 70: Line 70:
   
 
$answer1 = Compute("$a");
 
$answer1 = Compute("$a");
$answer2 = Compute("$a x^($b) + $b");
+
$answer2 = Compute("$a x^($b) + $b")->reduce();
 
</pre>
 
</pre>
 
</td>
 
</td>
Line 153: Line 153:
   
 
[[Category:Top]]
 
[[Category:Top]]
[[Category:Authors]]
+
[[Category:Sample Problems]]
  +
[[Category:Subject Area Templates]]

Revision as of 21:12, 7 June 2015

Answer is a Number or a Formula - Try it out

Click to enlarge

This PG code shows how to write a question whose answer is a number or a formula.


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();

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

TEXT(beginproblem());

Initialization:

Context("Numeric");

$a = non_zero_random(-9,9,1);
do { $b = random(2,9,1); } until ( $b != $a );

$answer1 = Compute("$a");
$answer2 = Compute("$a x^($b) + $b")->reduce();

Setup: We use do { $b = random(2,9,1); } until ( $b != $a ); to generate distinct random numbers.

Context()->texStrings;
BEGIN_TEXT
Enter \( $answer1 \): 
\{ ans_rule(20) \}
\{ AnswerFormatHelp("numbers") \}
$BR
$BR
Enter \( $answer2 \): 
\{ ans_rule(20) \}
\{ AnswerFormatHelp("formulas") \}
END_TEXT
Context()->normalStrings;

Main Text:

$showPartialCorrectAnswers = 1;

ANS( $answer1->cmp() );
ANS( $answer2->cmp() );

Answer Evaluation:

Context()->texStrings;
BEGIN_SOLUTION
${PAR}SOLUTION:${PAR}
Solution explanation goes here.
END_SOLUTION
Context()->normalStrings;

COMMENT('MathObject version.');

ENDDOCUMENT();

Solution:

Templates by Subject Area