WeBWorK Problems

issue with contextArbitraryString

issue with contextArbitraryString

by Alex Jordan -
Number of replies: 11
On a 2.17 server, something is broken with contextArbitraryString.pl. In the following minimal example, there are MathJax "Math input error"s if you view the correct answer or type in any answer.

If you uncomment the line about 'noLaTeXresults', then there is a different issue. Now no matter what you type, you see \longleftarrow in the Answer Preview.

```
DOCUMENT();

loadMacros('PGstandard.pl', 'PGML.pl', 'contextArbitraryString.pl');

Context("ArbitraryString");
#Context()->flags->set(noLaTeXresults => 1);
$answer = Compute('a')->cmp( checker => sub {return 1;} );

BEGIN_PGML
Enter [|a|]*.  
[_]{$answer}
END_PGML

ENDDOCUMENT();
```

In reply to Alex Jordan

Re: issue with contextArbitraryString

by Glenn Rice -

I can not reproduce this on the develop branch or on my production 2.17 server.

Note that if "noLaTeXresults" is set to 1, then you should see \longleftarrow in the answer preview (although typeset by MathJax).  That is what the setting is supposed to do.  I assume it is meant to be an arrow pointing to the "Entered" column of the results table.

In reply to Glenn Rice

Re: issue with contextArbitraryString

by Alex Jordan -
OK, thanks for explaining the left arrow. I'll just talk about the other issue I am having.

If I submit an answer like "abcd", I get the MathJax processing error I mentioned. And when I use the MathJax menu to view the LaTeX source, I get this:
{\verbabcd}
Not sure if you can see the 001F characters being used as delimiters. I can paste that into the MathJax demo site and it renders fine. Any ideas why my MathJax (v3.2.2, just like the demo site) would be having trouble with this?

OK, I just found something. I get this issue if MJ is using CHTML, but not if it is using SVG rendering. But only when it is using CHTML when the page first loads. If It is using SVG, and I toggle to CHTML then I see what I should see. But then if it had been CHTML (showing the error) and I toggle to SVG, I still see the error.
In reply to Alex Jordan

Re: issue with contextArbitraryString

by Alex Jordan -
On this test page I made
https://spot.pcc.edu/~ajordan/temp/mathjaxtest.html

It is reversed. I get the error if MJ is using SVG rendering, but not CHTML....
In reply to Alex Jordan

Re: issue with contextArbitraryString

by Glenn Rice -
When I tested this it was with SVG rendering for both develop and 2.17 since that is the default.

When I load your test page, I also get no errors. I see that you have it set to start with CHTML. I switched it to SVG and still have no errors. However, I can't make it start with SVG.

This may be a browser/platform issue. What browser are you using, and what OS? I tested with both Firefox and Chrome on Ubuntu 22.04.
In reply to Glenn Rice

Re: issue with contextArbitraryString

by Alex Jordan -
I posted my small page to the MathJax group to see if it's ultimately an issue for MathJax. I'm having this issue with various MacBookPros. One with (old) OS 10.14, FF 111, and Chrome 111. Another with OS 12 and Chrome 109.

Also now with Chrome on Android after changing the rendering method to SVG. (I could change the page to load SVG from the start, but I'm not messing with it since I asked MJ people to look into it already.)

Looks like moving to use character 1F is my doing:
https://github.com/openwebwork/pg/commit/49eb0c9bfeb2bb166fc669d6a2decba35521debd
In reply to Alex Jordan

Re: issue with contextArbitraryString

by Glenn Rice -
I forgot that MathJax saves the settings to local storage. This means that if I change the renderer on the page to SVG, and then reload, it does start with SVG. So when I did that with your test page, I do get an error.

However, doing this same sort of thing on both develop and 2.17 with your test problem, and now I am getting errors with CHTML, but not with SVG.
In reply to Alex Jordan

Re: issue with contextArbitraryString

by Glenn Rice -
I just noticed your comment about the 1F and looked closer. So this may be something that needs to be reviewed more carefully. This is also now used in PGstringevaluators.pl and parserCheckboxList.pl as well.
In reply to Alex Jordan

Re: issue with contextArbitraryString

by Alex Jordan -
Davide Cervone replied on the MathJax forum to a post I made there. If I understand right, this is not about character 1F, and changing that to something else would not help. If I understand correctly, the issue is when the page itself originally loads with one rendering method, but a user's local menu settings then direct the rendering method to change. The way verbatim is handled, it's not switching rendering methods properly. This explains why I experienced the issue in the opposite way in WeBWorK compared with that small test page.

So at least for users who have not used the MathJax menu to change the rendering method, things should be OK. And it sounds like there is nothing we could do on the WeBWorK side to fix the issue, short of not using \verb in the first place. Hopefully Davide et al will see how to patch MathJax.
In reply to Alex Jordan

Re: issue with contextArbitraryString

by Alex Jordan -

Davide provided a patch for MathJax v3, and submitted a PR to v4. Details here:
https://groups.google.com/g/mathjax-users/c/9bhqmYfNGws/m/bISQTzO9AQAJ

I'm not sure what is best for WeBWorK 2.18. Or a possible hotfix to 2.17.

When did we move to MJ3? Not sure if this is an issue for MJ2.

In reply to Alex Jordan

Re: issue with contextArbitraryString

by Glenn Rice -

We switched to MJ3 with WeBWorK 2.16.  We don't want to go back to MJ2.  It is much slower, and quite out of date.

In reply to Glenn Rice

Re: issue with contextArbitraryString

by Alex Jordan -

I wasn't suggesting going back to MJ2. I was musing over providing hotfixes for people with older versions of WW. (And wondering if this issue even exists for those with WW so old it is using MJ2).

For 2.18 we could either apply the patch or try MJ4.

For 2.17, it would be a hotfix patch or nothing. I know the issue is not a big one.