Any Answer is Marked Correct

Shows how to implement any answer marked correct.

Complete Code

Download file: AnyAnswerMarkedCorrect.pg

PG problem file

Explanation

DOCUMENT();

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

Preamble

These standard macros need to be loaded.
$a = Compute(random(2, 9));

$ans = $a->cmp(checker => sub { return 1; });

Setup

Wrap the random command with Compute to make $a a MathObject.

The checker simply returns 1 which will make any answer correct.

BEGIN_PGML
Enter anything, e.g. [`[$a]`] and it will be marked correct: [__]{$ans}
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.