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
198 stars 118 forks source link

Deal with `expression("")` as an operand #971

Closed christianp closed 1 year ago

christianp commented 1 year ago

A question uses a variable v to represent a variable which will be multiplied by a coefficient c. They have some TeX: \simplify{ {c}{v} }.

Sometimes this should be a constant, so v = expression(""). This leads to v being an expression value whose tree attribute is null. Nothing is currently set up to expect a null value for the tree.

Before v7, substitution into \simplify was done by string interpolation of the JME rendering of the value, so this produced an empty string. Perhaps we should catch empty values at the point where the curly braces are replaced with subvars function calls.