maths / moodle-qtype_stack

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

Validation display bug for input `3sqrt(2)` #1106

Closed daniil-berg closed 5 months ago

daniil-berg commented 5 months ago

One of our teachers came across a strange bug that I cannot explain. When previewing or answering the question, entering 3sqrt(2) into the first input field shows a very strange interpretation of the input.

pic-full-240207-1316-56

It looks as follows in TeX notation:

3\, if unknown then sconcat("\\left(",tex1(sqrt(2)),"\\right)") else (if atom(sqrt(2)) or is(length(args(a)) = 1) or safe_op(sqrt(2)) = "^" then tex1(sqrt(2)) else sconcat("\\left(",tex1(sqrt(2)),"\\right)"))
Or in MathML: (click) ``` 3 i f u n k n o w n t h e n s c o n c a t ( " l 3 i f u n k n o w n t h e n s c o n c a t ( " l e f t ( " , t e x 1 ( s q r t ( 2 ) ) , " r i g h t ) " ) e l s e ( i f a t o m ( s q r t ( 2 ) ) o r i s ( l e n g t h ( a r g s ( a ) ) = 1 ) o r s a f e o p ( s q r t ( 2 ) ) = " " t h e n t e x 1 ( s q r t ( 2 ) ) e l s e s c o n c a t ( " l e f t ( " , t e x 1 ( s q r t ( 2 ) ) , " r i g h t ) " ) ) e f t ( " , t e x 1 ( s q r t ( 2 ) ) , " r i g h t ) " ) e l s e ( i f a t o m ( s q r t ( 2 ) ) o r i s ( l e n g t h ( a r g s ( a ) ) = 1 ) o r s a f e o p ( s q r t ( 2 ) ) = " " t h e n t e x 1 ( s q r t ( 2 ) ) e l s e s c o n c a t ( " l e f t ( " , t e x 1 ( s q r t ( 2 ) ) , " r i g h t ) " ) ) ````

The error persist, when entering 3*sqrt(2) for example.

But if you enter e.g. 3sqrt(x) the error goes away and you can see the 3\, \sqrt{x} TeX rendering properly.

It seems this buggy validation display has no effect on the answer being properly understood by STACK for grading etc., but the weird display can confuse students for obvious reasons.

If you want, I can send you the offending question as XML.


We are on Moodle 4.1 and STACK 4.5.0.

sangwinc commented 5 months ago

This looks like a duplicate of this (resolved) issue: https://github.com/maths/moodle-qtype_stack/issues/1087 Sorry about that.