InequalityEvaluators: Difference between revisions
mNo edit summary |
mNo edit summary |
||
Line 51: | Line 51: | ||
# 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 67: | Line 68: | ||
<p> | <p> | ||
Uncommenting the lines containing <code>EmptySet</code> creates an empty set as a named constant and uses that name. | Uncommenting the lines containing <code>EmptySet</code> creates an empty set as a named constant and uses that name. | ||
</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> | ||
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; |
Revision as of 23:38, 24 January 2010
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 For a list of all available options for the interval context, see the POD documentation at http://webwork.maa.org/doc/cvs/pg_CURRENT/macros/contextInequalities.pl |
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. |