Difference between revisions of "SolutionForEquation1"

From WeBWorK_wiki
Jump to navigation Jump to search
(4 intermediate revisions by one other user not shown)
Line 5: Line 5:
 
This PG code shows how to check whether the student's answer is a solution to an equation.
 
This PG code shows how to check whether the student's answer is a solution to an equation.
 
</p>
 
</p>
* Download file: [[File:SolutionForEquation1.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/Algebra/SolutionForEquation1.pg FortLewis/Authoring/Templates/Algebra/SolutionForEquation1.pg]
* File location in NPL: <code>FortLewis/Authoring/Templates/Algebra/SolutionForEquation1.pg</code>
 
  +
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Algebra/SolutionForEquation1_PGML.pg FortLewis/Authoring/Templates/Algebra/SolutionForEquation1_PGML.pg]
   
 
<br clear="all" />
 
<br clear="all" />
Line 76: Line 76:
 
<p>
 
<p>
 
<b>Setup:</b>
 
<b>Setup:</b>
We use <code>SolutionFor(equation, point)</code> to define this MathObject. For more details and options, see the [http://webwork.maa.org/pod/pg_TRUNK/macros/parserSolutionFor.pl.html POD documentation]
+
We use <code>SolutionFor(equation, point)</code> to define this MathObject. For more details and options, see the [http://webwork.maa.org/pod/pg/macros/parserSolutionFor.html POD documentation]
 
</p>
 
</p>
 
</td>
 
</td>
Line 149: Line 149:
   
 
[[Category:Top]]
 
[[Category:Top]]
[[Category:Authors]]
+
[[Category:Sample Problems]]
  +
[[Category:Subject Area Templates]]

Revision as of 18:08, 7 April 2021

Answer is Any Solution For an Equation

Click to enlarge

This PG code shows how to check whether the student's answer is a solution to an equation.


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();   

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

TEXT(beginproblem());

Initialization: We must load parserSolutionFor.pl.

Context("Vector");

$r = random(3,6,1);

$answer = SolutionFor("x^2+y^2+z^2=$r^2", [$r,0,0] );

Setup: We use SolutionFor(equation, point) to define this MathObject. For more details and options, see the POD documentation

Context()->texStrings;
BEGIN_TEXT
A solution to the equation \( $answer->{f} \)
is \( (x,y,z) = \) 
\{ ans_rule(20) \}
\{ AnswerFormatHelp("points") \}
END_TEXT
Context()->normalStrings;

Main Text: To print the formula in the MathObject, we use ->f.

$showPartialCorrectAnswers = 1;

ANS( $answer->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