InequalityEvaluators: Difference between revisions
mNo edit summary |
(added historical tag and gave updated problem link) |
||
(6 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/problem-techniques/InequalityEvaluators.html a newer version of this problem]</p> | |||
<h2>Inequalities as Answers</h2> | <h2>Inequalities as Answers</h2> | ||
Line 37: | Line 40: | ||
<p> | <p> | ||
<b>Initialization:</b> | <b>Initialization:</b> | ||
Include the macro file <code>contextInequalities.pl</code>. | Include the macro file <code>contextInequalities.pl</code>, which automatically loads <code>MathObjects.pl</code>. | ||
</p> | </p> | ||
</td> | </td> | ||
Line 51: | Line 54: | ||
# Context()->constants->add(EmptySet => Set()); | # Context()->constants->add(EmptySet => Set()); | ||
# Context()->flags->set(noneWord=>"EmptySet"); | # Context()->flags->set(noneWord=>"EmptySet"); | ||
# Context()->flags->set(ignoreEndpointTypes=>1); | |||
# f(x) = x^2 - 16 on -1 <= x <= 5 | # f(x) = x^2 - 16 on -1 <= x <= 5 | ||
Line 63: | Line 67: | ||
<p> | <p> | ||
<b>Setup:</b> | <b>Setup:</b> | ||
Using <code>Context("Inequalities-Only")</code>, if the student enters the inequality <code>-16 <= y <= 9</code> their answer will be marked correct, but the equivalent interval <code>[-16,9]</code> would be incorrect. If we had used <code>Context("Inequalities")</code> instead, both the inequality and the interval be marked correct. | Using <code>Context("Inequalities-Only")</code>, if the student enters the inequality <code>-16 <= y <= 9</code> their answer will be marked correct, but the equivalent interval <code>[-16,9]</code> would be incorrect. If we had used <code>Context("Inequalities")</code> instead, both the inequality and the interval would be marked correct. | ||
</p> | </p> | ||
<p> | <p> | ||
Line 69: | Line 73: | ||
</p> | </p> | ||
<p> | <p> | ||
Uncommenting <code>Context()->flags->set(ignoreEndpointTypes=>1);</code> would also mark the student answers <code>-16 < y < 9</code> or <code>-16 <= y < 9</code> or <code>-16 < y <= 9</code> correct. | |||
</p> | </p> | ||
<p> | <p> | ||
As of January 2010, the inequality is not variable-specific. If we had not removed the default variable x from the context using <code>Context()->variables->remove("x");</code>, then the student answer <code>-16 <= x <= 9</code> would also be marked correct. Note that we removed the variable x from the context <i>after</i> we defined the formula <code>$f</code> that uses this variable (otherwise there would be errors and PG file would not work). | |||
</p> | </p> | ||
</td> | </td> | ||
Line 84: | Line 88: | ||
Context()->texStrings; | Context()->texStrings; | ||
BEGIN_TEXT | BEGIN_TEXT | ||
What is the range of | What is the range of | ||
\( y = f(x) = $f \) on the domain \( -1 \leq x \leq 5 \)? | \( y = f(x) = $f \) on the domain \( -1 \leq x \leq 5 \)? | ||
Line 91: | Line 94: | ||
Range: \{ ans_rule(20) \} Enter your answer using | Range: \{ ans_rule(20) \} Enter your answer using | ||
inequalities (not intervals). | inequalities (not intervals). | ||
END_TEXT | END_TEXT | ||
Context()->normalStrings; | Context()->normalStrings; | ||
Line 127: | Line 128: | ||
[[Category:Problem Techniques]] | [[Category:Problem Techniques]] | ||
<ul> | |||
<li>POD documentation: [http://webwork.maa.org/pod/pg/macros/contextInequalities.html contextInequalities.pl]</li> | |||
<li>PG macro: [http://webwork.maa.org/viewvc/system/trunk/pg/macros/contextInequalities.pl?view=log contextInequalities.pl]</li> | |||
</ul> |
Latest revision as of 13:56, 28 June 2023
This problem has been replaced with a newer version of this problem
Inequalities as Answers
This is the essential code for having inequalities as student answers.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "contextInequalities.pl", "PGcourse.pl", ); TEXT(beginproblem()); |
Initialization:
Include the macro file |
Context("Inequalities-Only"); Context()->variables->add(y=>"Real"); # Context()->constants->add(EmptySet => Set()); # Context()->flags->set(noneWord=>"EmptySet"); # Context()->flags->set(ignoreEndpointTypes=>1); # f(x) = x^2 - 16 on -1 <= x <= 5 $f = Formula("x^2 - 16"); $range = Compute("-16 <= y <= 9"); Context()->variables->remove("x"); |
Setup:
Using
Uncommenting the lines containing
Uncommenting
As of January 2010, the inequality is not variable-specific. If we had not removed the default variable x from the context using |
Context()->texStrings; BEGIN_TEXT What is the range of \( y = f(x) = $f \) on the domain \( -1 \leq x \leq 5 \)? $BR $BR Range: \{ ans_rule(20) \} Enter your answer using inequalities (not intervals). END_TEXT Context()->normalStrings; |
Main Text: The problem text section of the file is as we'd expect. |
ANS( $range->cmp() ); ENDDOCUMENT(); |
Answer Evaluation: As is the answer. |
- POD documentation: contextInequalities.pl
- PG macro: contextInequalities.pl