Difference between revisions of "InequalityAnswer1"

From WeBWorK_wiki
Jump to navigation Jump to search
(Add link to PGML version in OPL)
Line 79: Line 79:
 
<p>
 
<p>
 
<b>Setup:</b>
 
<b>Setup:</b>
We require students to use inequalities by using <code>Context("Inequalities-Only")</code>. If we had used <code>Context("Inequalities")</code> instead, then students could also enter their answer using interval notation. For more details, please see [http://webwork.maa.org/pod/pg_TRUNK/macros/contextInequalities.pl.html contextInequalities.pl.html]
+
We require students to use inequalities by using <code>Context("Inequalities-Only")</code>. If we had used <code>Context("Inequalities")</code> instead, then students could also enter their answer using interval notation. For more details, please see [http://webwork.maa.org/pod/pg/macros/contextInequalities.html contextInequalities.pl]
 
</p>
 
</p>
 
<p>
 
<p>

Revision as of 17:53, 7 April 2021

Answer is an Inequality

Click to enlarge

This PG code shows a question whose answer is an inequality.


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();

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

TEXT(beginproblem());

Initialization: We must load contextInequalities.pl.

Context("Inequalities-Only");
Context()->flags->set(formatStudentAnswer=>'parsed');

$a = random(3,9,1);

$ineq = "-$a x \leq 10";  # TeX

$answer = Compute("x >= -10 / $a");

Setup: We require students to use inequalities by using Context("Inequalities-Only"). If we had used Context("Inequalities") instead, then students could also enter their answer using interval notation. For more details, please see contextInequalities.pl

We use formatStudentAnswer=>'parsed' and Compute() so that the student's answer are left as fractions rather than reduced to decimals.

Context()->texStrings;
BEGIN_TEXT
Solve the inequality \( \displaystyle $ineq \).
Enter your answer using inequality notation.
$BR
$BR
\{ ans_rule(40) \}
\{ AnswerFormatHelp("inequalities") \}
END_TEXT
Context()->normalStrings;

Main Text:

$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