maths / moodle-qtype_stack

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

latex rendering of radio button options does not respect texup definitions #679

Open timlowe opened 3 years ago

timlowe commented 3 years ago

In an attempt to be clever and construct items in Maxima, rather than with complicated latex, I used texup to define a texup function to render intervals with non-matching brackets, eg olcr(1,2) [open-left-closed-right] to represent (1,2].

This works fine when rendered in the question text.

But when trying to render it as a (latex) radio button option, the variable numbers are processed correctly, but the texup definitions are not acted upon. (The function name olcr gets shown instead)

Brief example XML (with disguised extension) attached

questions-MATHS-WS-OSEP-DROP DOWN LATEX TEXT-20210122-1747.xml.txt

shinuito commented 3 years ago

There is already a syntax for real intervals https://docs.stack-assessment.org/en/CAS/Real_Intervals/ that you might already be aware of (but just in case and maybe it'll help someone else).

This syntax for open and closed intervals seem to work fine in radio options for example oo(a,b) give (a,b), oc(1,2) gives (1,2] etc. In your example using instead say

Opt1: oc(-inf,aa) or co(bb,cc);

seems to work okay for me (of course the cc might not work with cc being defined as a variable). Then one wouldn't have to define custom syntax and tex rules.

I'm sure though there's other situations though where one would want to do a similar idea of rendering custom objects. I need to learn exactly how this works first to test it out myself.

(I think it was mentioned that latex wouldn't work too well with the dropdown options, so radio probably is the better option)

timlowe commented 3 years ago

Thanks shinuito. Brilliant. Why have never noticed that section before! (Note: must read the manual more!)

However, despite having an alternative approach for this particular issue, the general issue of texput definitions not resolving in radio lists remains I think.

timlowe commented 3 years ago

Well, nearly brilliant.

Opt1: oc(-inf,aa) or co(bb,cc);

works fine when included as the displayed value in a radio button list, but I really want a union, not or, so tried Opt1: %union(oc(-inf,aa), co(bb,cc));

which produced a run-time error: "The input has generated the following runtime error which prevents you from answering. Please contact your teacher. "$union": argument must be a set; found: co(2,4) "

I read the documentation (this time!) and used %union. It displays fine as CASText (so I assume the required to_poly_solve package is working at a system level), but it does not work in the radio button display field?

sangwinc commented 3 years ago

I'll leave this issue open to sort out unions of intervals. The current loose concept of "type" is bursting, and I think we need some more nuanced types here (e.g. things to which union applies includes {1,2}, x>1, oo(-1,1), x<1 and x>0, is quite a complex list.).