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
207 stars 122 forks source link

Mathematical expression with logical negation #657

Closed ugonj closed 4 years ago

ugonj commented 4 years ago

There seems to be a bug that prevents the expressions "not (p and q)" and "not (p or q)" as correct answers to a "mathematical expression" question. Numbas seems to expect (not p) and q (or (not p) or q) instead of the requested answer.

To reproduce: 1) Create a new part with a mathematical expression; 2) Enter the expression "not (p and q)" in the Correct Answer settings 3) Test run and enter not (p and q) and submit the answer: it will show the solution is incorrect; 4) Test run and enter (not p) and q; submit the answer: it will accept the solution. 5) Reveal answers: it shows the wrong expression.

Here's a link to an example question exhibiting this problem: https://numbas.mathcentre.ac.uk/question/52550/propositional-algebra/preview/

christianp commented 4 years ago

Thanks for this comprehensive bug report. The logic to decide when to put brackets around an argument didn't consider prefix operators. I've now fixed it.