This shows how to customize (remap) the error messages students receive after submitting an incorrect response or making a syntax error when entering their answer.
Download file: ErrorMessageCustomization.pg
DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl');
Preamble
These standard macros need to be loaded.Context()->{error}{msg}{"Missing operand after '-'"} =
"Enter '-1' instead of '-'";
$ans1 = Real(-1);
$ans2 = Formula('x - 2');
Setup
To change an error message the string in the
Context()->{error}{msg} hash must match exactly, and
then is replaced with the customized message.
BEGIN_PGML
Factor [`-1`] from [`-x + 2`]
[`-x + 2 =`] [__]{$ans1} [`\cdot \big(`] [__]{$ans2} [`\big)`]
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.