EquationDefiningFunction1: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(add historical tag and give links to newer problems.) |
||
| (10 intermediate revisions by 3 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/Algebra/EquationDefiningFunction.html a newer version of this problem]</p> | |||
<h2>Answer is an Equation Defining a Function</h2> | <h2>Answer is an Equation Defining a Function</h2> | ||
<p style="background-color:# | [[File:EquationDefiningFunction1.png|300px|thumb|right|Click to enlarge]] | ||
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"> | |||
This PG code shows how to check student answers that are equations that define functions. If an equation defines a function, it is much more reliable to use the this method of answer evaluation (via <code>parserAssignment.pl</code>) than the implicit equation method (via <code>parserImplicitEquation.pl</code>) | This PG code shows how to check student answers that are equations that define functions. If an equation defines a function, it is much more reliable to use the this method of answer evaluation (via <code>parserAssignment.pl</code>) than the implicit equation method (via <code>parserImplicitEquation.pl</code>) | ||
</p> | </p> | ||
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Algebra/EquationDefiningFunction1.pg FortLewis/Authoring/Templates/Algebra/EquationDefiningFunction1.pg] | |||
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Algebra/EquationDefiningFunction1_PGML.pg FortLewis/Authoring/Templates/Algebra/EquationDefiningFunction1_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 75: | Line 80: | ||
<p> | <p> | ||
<b>Setup:</b> | <b>Setup:</b> | ||
We must allow assignment, and declare any function names we wish to use. For more details and examples in other MathObjects contexts, see [http://webwork.maa.org/ | We must allow assignment, and declare any function names we wish to use. For more details and examples in other MathObjects contexts, see [http://webwork.maa.org/pod/pg/macros/parserAssignment.html parserAssignment.pl] | ||
</p> | </p> | ||
</td> | </td> | ||
| Line 88: | Line 93: | ||
BEGIN_TEXT | BEGIN_TEXT | ||
Enter \( y = 5x+2 \) \{ ans_rule(20) \} | Enter \( y = 5x+2 \) \{ ans_rule(20) \} | ||
$BR | |||
$BR | $BR | ||
Enter \( f(x) = 3x^2+2x \) \{ ans_rule(20) \} | Enter \( f(x) = 3x^2+2x \) \{ ans_rule(20) \} | ||
| Line 152: | Line 158: | ||
[[Category:Top]] | [[Category:Top]] | ||
[[Category: | [[Category:Sample Problems]] | ||
[[Category:Subject Area Templates]] | |||
Latest revision as of 09:42, 18 July 2023
This problem has been replaced with a newer version of this problem
Answer is an Equation Defining a Function

This PG code shows how to check student answers that are equations that define functions. If an equation defines a function, it is much more reliable to use the this method of answer evaluation (via parserAssignment.pl) than the implicit equation method (via parserImplicitEquation.pl)
- File location in OPL: FortLewis/Authoring/Templates/Algebra/EquationDefiningFunction1.pg
- PGML location in OPL: FortLewis/Authoring/Templates/Algebra/EquationDefiningFunction1_PGML.pg
| PG problem file | Explanation |
|---|---|
|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserAssignment.pl", ); TEXT(beginproblem()); |
Initialization:
We need to include the macro file |
Context("Numeric")->variables->are(x=>"Real",y=>"Real");
parser::Assignment->Allow;
parser::Assignment->Function("f");
$eqn = Formula("y=5x+2");
$fun = Formula("f(x)=3x^2+2x");
|
Setup: We must allow assignment, and declare any function names we wish to use. For more details and examples in other MathObjects contexts, see parserAssignment.pl |
Context()->texStrings;
BEGIN_TEXT
Enter \( y = 5x+2 \) \{ ans_rule(20) \}
$BR
$BR
Enter \( f(x) = 3x^2+2x \) \{ ans_rule(20) \}
END_TEXT
Context()->normalStrings;
|
Main Text: The problem text section of the file is as we'd expect. |
$showPartialCorrectAnswers = 1; ANS( $eqn->cmp() ); ANS( $fun->cmp() ); |
Answer Evaluation: As is the answer. |
Context()->texStrings;
BEGIN_SOLUTION
${PAR}SOLUTION:${PAR}
Solution explanation goes here.
END_SOLUTION
Context()->normalStrings;
COMMENT('MathObject version.');
ENDDOCUMENT();
|
Solution: |