Closed timhunt closed 8 months ago
Sorry Tim, I think I've caused the problem here: https://github.com/maths/moodle-qtype_stack/blame/master/stack/maximaparser/corrective_parser.php#L112
I don't think it si a problem character is banned. We want students to type x^2. The problem is that Insert stars assuming single-character variable names seems to skip the inital check, and then blows up badly later, rather than being handled well.
But, I have to say I think this bug is beyond me to fix. I am hoping your or Matti will see what is going on.
I've committed a fix here: https://github.com/maths/moodle-qtype_stack/tree/iss1107 This does "forbid" the use of superscript unicode. The difficulty is that, while x^2 is unambiguous, we have to parse the supercript characters, e.g. x^22. So, forbidding these at validation time is safer than partially accepting them. If someone is motivated to parse these situations, then please send in a pull request! In the mean time, this fix prevents the catastrophic crash at lease which is a marginal improvement.
I've updated the validation mechanism which should prevent this getting as far as Maxima. On reflection I think this is an overall improvement on things.
Expected result: A nice validation message like "This answer is invalid. CAS commands may not contain the following characters: ²." which is what happens without the insert stars option.
Actual result: ... this does seem to depend slightly on the Maxima back-end, but some sort of fatal error.
With goemaxima that is: stack_cas_session: tried to parse the value x*\², but got the following exception Expected "#pm#", "%not ", "'", "''", "(", "+", "+-", "-", "? ", "?", "?? ", "[", "do", "for", "from", "if", "in", "next", "not ", "not", "nounnot ", "nounnot", "step", "thru", "unless", "while", "{", "|", boolean, float, identifier, integer, string or whitespace but "\" found.
With MaximaPool is (incorrectly) "CAS failed to return any data due to timeout." - that happens instantly.
Worse, if you add this question to a quiz, start an attempt, input x². Not only do you get the error in STACK's validation, but this also causes fatal errors when Moodle's quiz autosave tries to save the response after a minute or so. leading to the warning "Network connection lost. Anything entered on this page in the last minute might not be saved. ..." being displayed.
This unit test might show the problem.
Here is the CAS session that is sent:
Which causes: