maths / moodle-qtype_stack

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

Nouns appearing as options in multiple choice questions are evaluated when displaying MCQ choices #1189

Open mrseanman opened 1 month ago

mrseanman commented 1 month ago

STACK evaluates all nouns when displaying multiple choice question (MCQ) options. My use case is specifically the noun 'diff, so I will concentrate on that. When 'diff is part of a choice in a MCQ, it is evaluated before the tex to display the option is generated. This is a problem when you want to display things like 'diff(f,x) as options in an MCQ. Instead of displaying the derivative, it evaluates and displays 0. Specific to diff, declaring depends(f,x) makes no difference to the display of 'diff(f,x) or diff(f,x). The non-action of depends is probably a completely different issue (or intended behavior). I intend to concentrate on the noun issue.

This problem forces the use of diff(f(x),x) in MCQs, which would be nice to avoid as this does not typeset as neatly. Also you cannot have, for example 'diff(x^2,x) as an option in an MCQ. It would display as $2x$.

Minimal example

Question variables

depends(f, x);
disp1: 'diff(f,x);
disp2: diff(f,x);

MCQ: [
   [disp1, true],
    /* using the display option makes no difference */
   [2, false, disp2]
];

Question text

These both (correctly) display as \(\frac{\mathrm{d}f}{\mathrm{d}x}\): {@disp1@}, {@disp2@}.
But the MCQ options are both displayed as 0.
[[input:ans1]] [[validation:ans1]]

Notes

mrseanman commented 1 month ago

This problem appears to extend to all nouns, so have edited title and body text accordingly.

sangwinc commented 1 month ago

Thanks for reporting this. We did have a problem in the past, and I'm sorry about that.

The logic noun issue ("all nouns" you mention) has a test case which passes and is here https://github.com/maths/moodle-qtype_stack/blob/master/tests/input_checkbox_test.php#L324

I've tested your example in the "dev" branch (soon to be 4.6.0) and can't reproduce the problem.

Which version are you using? (see https://docs.stack-assessment.org/en/Authoring/Author_FAQ/ )

mrseanman commented 1 month ago

Thanks for the quick response. The version on my server appears to be 2023060500.

sangwinc commented 1 month ago

I've investigated this further. The display issue is working, but there is another noun-related issue which I'll try to fix in a future release.