WeBWorK Problems

Problems with NAMED_ANS_RADIO in PGbasicmacros.pl

Problems with NAMED_ANS_RADIO in PGbasicmacros.pl

by Andrew Parker -
Number of replies: 1
I found an error in generating TeX code when using parserRadioButtons.pl

The problem arises when attempting to use answers that containing "$" - both from using contextCurrency.pl or by including $DOLLAR in the multiple choice responses. (The latter is not recommended, as the correct answer will still return incorrect to the student - which is a separate problematic issue, though fixed by using "Currency".)

When WeBWorK attempts to generate the TeX file for an assignment containing such a problem, the code for the multiple choice responses gets converted to a double-escaped "\\$" instead of "\$" as one would expect. I'm not sure where the extra escape character is coming from either.

I hacked the problem by inserting "$tag =~ s/\\\$/\$/; into the code for NAMED_ANS_RADIO and NAMED_ANS_RADIO_EXTENSION in PGbasicmacros.pl, which had the result of producing a properly functioning TeX file. 

I would have used s/\\\\\$/\\\$/; but this had no effect - suggesting that the additional escape character is being added further down the line somewhere? So, I suspect that this is an inappropriate place for this hack and perhaps some code elsewhere should be checking whether or not this "$" is already escaped...


In reply to Andrew Parker

Re: Problems with NAMED_ANS_RADIO in PGbasicmacros.pl

by Davide Cervone -
The parserRadioButtons.pl file has been substantially rewritten for v2.11, and the changes should resolve the issue you are having.

See the pull request for more details. Unfortunately, you can't just upgrade the parserRadioButtons.pl file, as there are other changes that are needed to support the new version (see the "changed files" tab in the pull request lined above). You would have to upgrade to the develop branch (or the release-2.11 branch) to get access to the new code.