Difference of displaying same "code" in different settings

5 views
Skip to first unread message

Julia Goedecke

unread,
Mar 9, 2021, 2:06:06 PMMar 9
to Numbas Users
Hello,
I have discovered that a variable string with some maths in it is
displayed differently in the statement of a question than as one of the
choices of a multiple select part. Any ideas why this would be?

Minimal example:
https://numbas.mathcentre.ac.uk/question/share/view/f981e11b-7d29-451a-b9e5-b75ff828c8ba

I can make either display the curly braces, but not both with the same
code.

Julia
--

Dr Julia Goedecke
Teaching Fellow in Mathematics
University of Leicester


https://www.ipetitions.com/petition/mathematics-is-not-redundant

Christian Lawson-Perfect

unread,
Mar 18, 2021, 10:23:17 AMMar 18
to numbas...@googlegroups.com
Thanks for spotting this. Curly braces in LaTeX in string variables caused me a lot of headaches years ago, before we had "safe" strings. The routine to substitute variables into content areas would strip the first slash before a curly brace, so you'd have to put double slashes in the string in order to end up with \{. In fact, since you need to escape slashes in the JME code, this meant that you'd need four slashes! This was all so that the substitution routine doesn't interpret the curly braces as delimiting another substitution when the string was evaluated.
The 'safe' function works much better: it marks a string so that the substitution routine doesn't modify it, no matter when or where the string is evaluated. I've changed the substitution-into-content-area routine so it doesn't modify 'safe' strings, so now you get the same behaviour in the statement as for the choices, if the string is marked as 'safe'.

--
You received this message because you are subscribed to the Google Groups "Numbas Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numbas-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/numbas-users/e9e5fb57-a252-5454-b9d9-9e5f965f1d01%40cantab.net.
Reply all
Reply to author
Forward
0 new messages