Open mijenner opened 4 months ago
Thanks, Michael for reaching out. I cannot reproduce that problem. The ^
operator is allowed in answer types Numeric, Numerical formula and Algebraic formula, along with **
. (There used to be an incorrect warning for that, but we fixed this in #108.) See the following screenshot:
Please note, however, that ^
will mean XOR
on the teacher side, i. e. when entering the model answers. There is only one exception: inside model answers for the answer type Algebraic formula, which are always entered as strings and enclosed in quotes, ^
will mean exponentiation.
Can you please clarify the problem and confirm that you are using the latest version?
We are using 5.3.3 for Moodle 3.9+ (2024042000).
I just ran into the problem again with Answer type = Numerical formula, trying to calculate rw^2 didn't work, changing it to rw**2 solved the issue.
Note: I'm talking about what the teacher writes in the Answer* field.
But that's on the teacher side, no?
Correct
So to be clear: my request is a change on teacher side.
On the teacher side, ^
means XOR
in every case except if you are using answer type "Algebraic formula". In that case, the answer is entered as a string, i. e. in quotes.
Changing this would break backwards compatibility for any question that actually uses XOR
in the calculation of the model answer. (I personally do not use it, but I don't know if other people do.)
I understand your request and if I started Formulas question from scratch, I would not do that as it currently is. I am actually rewriting the core part (it's almost done) and there are several things where we will be stuck with legacy syntax due to decisions that were taken a long time ago.
However, I can imagine it would help to add some sort of warning when a teacher uses the ^
operator in their model answer, e.g. "Please note that ^
means XOR
. If you want exponentiation, please use **
." I could even add a button to auto-fix it.
What do you think about that?
A warning is a lot better than nothing, it would be a great addition.
Where can the warning be displayed? Next to the Answer* field is obvious, but when saving a question we are led to the top and if nothing is displayed there it may go unnoticed?
By the way, what other boolean operators are available?
Found the other operators here: https://dynamiccourseware.org/course/view.php?id=100§ion=1
Where can the warning be displayed? Next to the Answer* field is obvious,
The warning would be displayed below the field while the user is typing.
but when saving a question we are led to the top and if nothing is displayed there it may go unnoticed?
If there are validation errors, the form is automatically scrolled to a position where the error message is visible. In this case, however, that would not be a validation error, but only a warning generated via Javascript. Otherwise, the form would always fail validation with a ^
in the model answer and thus that operation could not be used anymore. (AFAICS, Moodle's Form API does not support warnings, it only supports errors.)
While typing is a great moment!
Problem with ^ in answer fields
Formulas is THE best Moodle quiz question type for physics I've seen. Great work!
MathJax allows exponential notation to be written using hat notation by example x^2. However, this is not allowed in the answer fields were we are supposed to use double-star notation, e.g. x**2 or pow(x, 2), instead.
By mistake I used hat notation, and discovered that no warning is given. This is unfortunate as errors can go undetected.
Warn, disallow or translate
A warning, or directly disallowing hat notation in these fields would help the end user avoid doing mistakes.
It would be even better if ^ notation would be allowed, since it has become the defacto standard in LaTeX. If needed, ^ is translated internally to something useful for the underlying engine.
Kind regards, Michael