numbas / Numbas

A completely browser-based e-assessment/e-learning system, with an emphasis on mathematics
http://www.numbas.org.uk
Apache License 2.0
197 stars 118 forks source link

Brackets get lost when substituting a sub-expression into a JME part's expected answer field #1011

Closed christianp closed 1 year ago

christianp commented 1 year ago

Example by Martin Jones: https://numbas.mathcentre.ac.uk/question/142459/error-multiplying-functions/

There's a variable f = expression("2t+5") and it's used in a mathematical expression part's expected answer field: t*({f}).

The resulting correct answer is 2t*t + 5. It looks like the brackets around f are lost, so the substitution produces t*2t + 5, and then it's rearranged.

The substitution is performed correctly when done in a variable definition, f2 = expression("t*({f})"), but not when the brackets around {f} are omitted. That also needs to be fixed.