maths / moodle-qtype_stack

Stack question type for Moodle
GNU General Public License v3.0
142 stars 149 forks source link

Validation of x^+ #1281

Closed georgekinnear closed 1 month ago

georgekinnear commented 1 month ago

I have an algebraic input (with "don't insert stars") where a student typed x^+5 when they had meant to type x^2+5.

I've tried this out for myself and the validation message looks a bit strange: image

Inspecting the MathJax, the underlying tex is apparently x+^{5}

I would have expected this would either (a) be flagged as a validation error (the ^+ being an odd combination), or (b) the expression would be interpreted and displayed as x^{+5} (which is what seems to happen if I type this into maxima).

sangwinc commented 1 month ago

This has already been reported, and is related to this testcase. https://github.com/maths/moodle-qtype_stack/blob/master/tests/fixtures/inputfixtures.class.php#L420

It's related to Maxima's tex() function, not something we do in STACK specifically.

A minimal example in wxMaxima is

simp:false;
p:sin(+x);
tex(p);

Your example is

simp:false;
p:x^+5;
tex(p);

This gives $$x+^{5}$$ which is why this ends up in STACK. Please can you raise this with the Maxima community @georgekinnear?

georgekinnear commented 1 month ago

@sangwinc done - see https://sourceforge.net/p/maxima/bugs/4388/

smacrakis commented 1 month ago

Maxima is not specified to work correctly with unsimplified expressions. With simplification turned off (simp:false), x^+5 is parsed as (in prefix form): "^"(x,"+"(5)). But simplified expressions never have 1-argument "+".