WeBWorK Problems

A bug in Moodle webwork question type

A bug in Moodle webwork question type

by Steven McKay -
Number of replies: 3
This is probably a bug in the MWQT not the question server, but since I am still not clear about the symbiotic relationship between the two, it could be the question server.

In some cases, when text is typeset by latex, the last two characters of the latex typesetting are visible on the screen. For example, the problem in the Union problem set, subset setFunctionBasics problem srw2_1_23.pg renders like this:

The interesting part is that when I click to edit the problem, the question is rendered *correctly* there. It's just when the quiz is previewed or used by the student that the extra characters show.


It also seems to happen when latex expressions along with answers are stored in an array like structure: I haven't looked at that one carefully yet.

So, is this a bug with MWQT or a bug in the question or something else?

Thanks,
S.M.


In reply to Steven McKay

Re: A bug in Moodle webwork question type

by Davide Cervone -
It looks to me like there is an unquoted greater-than sign in the ALT tag for the image for the function definition. That could cause the IMG tag to end prematurely, leaving the rest of the math string as plain text within the page. The problem correctly uses $GT to try to avoid such problems, but the definition of $GT is to use $GTS, which is defined to produce > in TeX mode. Changing that to \gt (followed by a space) would fix the problem, but it is probably better to modify the image generator (which adds the ALT tag) to properly escape the HTML special characters in the string used for the ALT tag.

Davide
In reply to Davide Cervone

Re: A bug in Moodle webwork question type

by Steven McKay -
Ah. Thank you. I don't really know who adds the ALT tag - if that's in moodle or in the webwork question server. Hopefully Matthew Leventi can figure this out. In the meantime, I'll try changing $GT to \gt to get me around it.

Thanks again,

S.M.
In reply to Steven McKay

Re: A bug in Moodle webwork question type

by Davide Cervone -
The ALT tag is added by WeBWorK. I wasn't suggesting that you make the change (I was recommending it to the other developers who read this list). The file that does it is pg/lib/WeBWorK/PG/ImageGenerator.pm, and I'll add the escaping when I get the chance.

If you plan to change $GT you should instead change $GTS in pg/macros/PGbasicmacros.pl by changing the subroutine definition of GTS around line 1244.

The browsers I used to test the PG problem file you site showed the IMG tag fine even with the unescaped >, so perhaps there is something within the WeBWorK/Moodle connection that does it. I suspect a bad regular expression somewhere that doesn't properly detect the end of the IMG tag while altering the output of the WeBWorK problem.

Davide