I'm trying to create a problem in which currency is used and hence it not unusual for students to include commas in their answers for big numbers over 999. The trouble is that this problem is asking for the cost, revenue and profit functions and students might try to use commas, but it gives a weird error that they will unlikely understand. We are fine if commas aren't allowed, and we'd just like to change the message since that seems to be the easiest. However, I tried to do so in both potential contexts (even though I think I only need it in the second), but it doesn't actually change the message. So my question is: can this message actually be changed, or can I make it so commas are in fact accepted in numbers inside of a formula doing something like what's on the wiki: https://webwork.maa.org/wiki/Modifying_Contexts_(advanced), or can I somehow disable commas for lists and adjust things that way? I should note that I'm only using the Limited Polynomial context to enforce simplifications.

Here's the code:

################################################################################

# Initialization

################################################################################

DOCUMENT();

loadMacros(

"PGstandard.pl",

"MathObjects.pl",

"PGML.pl",

"contextCurrency.pl",

"contextLimitedPolynomial.pl",

);

TEXT(beginproblem());

################################################################################

# Problem Setup

################################################################################

Context("Currency");

Context()->{error}{msg}{"Your answer isn't a formula that returns a number (it looks like a list of numbers)"} = "Commas should not appear in equations";

Context()->flags->set(trimTrailingZeros=>1);

Context()->noreduce('(-x)-y');

Context()->noreduce('(-x)-y','(-x)+y');

$fix = random(7500,15000,50);

$fixD = Currency($fix);

$prod = random(15,40);

$prodD = Currency($prod);

$sale = $prod+random(floor($prod/2),floor(5*$prod/6));

$saleD = Currency($sale);

$prof = $sale - $prod;

Context("LimitedPolynomial-Strict");

Context()->parens->redefine('(');

Context()->{error}{msg}{"Your answer isn't a formula that returns a number (it looks like a list of numbers)"} = "Commas should not appear in equations";

$C = Formula("$prod x + $fix")->reduce;

$R = Formula("$sale x")->reduce;

$P = Formula("$prof x - $fix")->reduce;

################################################################################

# Text

################################################################################

BEGIN_PGML

A company has monthly fixed costs of [$fixD]. The production cost of each

item is [$prodD] and each item sells for [$saleD]. Let [`x`] be the number

of items that are produced and sold.

a. What is the company's monthly cost function?

[`C(x) = `] [__]{$C}

b. What is the company's monthly revenue function?

[`R(x) = `] [__]{$R}

c. What is the company's monthly profit function?

[`P(x) = `] [__]{$P}

END_PGML

ENDDOCUMENT();