I have an issue with trying to generate custom axis labels in JSXGraph which, whilst my code appears to work fine when I refresh the page with F5, fails every time I click 'Try another question like this' in Numbas.
The gist of what I'm trying to do is on the codepen below. I basically want a variable axis label that can be a fraction of pi, eg pi, pi/2, pi/3 etc. This version appears to work as I want, every time I refresh the page the label updates.
With the same question in Numbas however, refreshing the page with F5 works fine but 'Try another question like this one' gives errors. It gives a [Math Processing Error] at the first retry followed by what looks like raw Latex on the second and any subsequent retries.
I'm guessing it's to do with the way the lambda function returns generateLabelText but the solution is beyond me.