Answer as an Inequality

Answer is an inequality

Complete Code

Download file: InequalityAnswer.pg

POD for Macro Files

PG problem file

Explanation

DOCUMENT();

loadMacros('PGstandard.pl', 'PGML.pl', 'contextInequalities.pl', 'PGcourse.pl');

Preamble

We must load contextInequalities.pl.

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

$a = random(3, 9);

$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 is left as a fraction rather than reduced to a decimal.

BEGIN_PGML
Solve the inequality [`\displaystyle [$ineq]`].
Enter your answer using inequality notation.

[_]{$answer}{20}

[@ helpLink('inequalities') @]*
END_PGML

Statement

This is the problem statement in PGML.
BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();

Solution

A solution should be provided here.