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.
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.
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/