The contexts in contextLimitedPolynomial.pl allow to force students to enter a univariate polynomial as a sum of products of coefficients and monomials with the optional restriction that each exponent occurs at most once in this sum.
I could not find a similar context for multivariate polynomials. More specifically I am looking for a context that would force a student to enter a polynomial as a sum of terms (i.e. a product of a coefficient and a monomial) such that the exponents of the terms are pairwise different.
For example, given the answer polynomial is 3x^2+x*y+x I would like to accept
as a correct answer, but neither
Is this currently possible using MathObjects of type Formula?
In the PCC macros folder of the OPL, there is contextForm.pl:
You could try this. After loading this macro library file, then try:
$answer = Formula("3x^2+xy+x");
If that does not behave as desired, let me know the details, and I may be able to suggest one or two more lines to make it work.