WeBWorK Problems

Answer boxes for limits of integration - with support for MathQuill

Re: Answer boxes for limits of integration - with support for MathQuill

by Nathan Wallach -
Number of replies: 2
Glenn - The use of the CSS descendant selector to handle the regular (non-MathQuill) formatting is a huge improvement over the original approach of manually determining and using the ids of the input boxes whose formatting needed to be modified. Thanks for helping improve this formatting approach.

I've adopted your selector in the attached sample (plain) PG file which should be considered a replacement for the file in the prior post of this thread.

Thanks also for providing the PGML sample - which makes this approach relevant for both styles of coding problems.

About use in Gateway quizzes - it could be that such uses would run into some "scope conflicts" if the same class names were used in different problems but with slight differences in the CSS setting used in different problems included in a single gateway quiz.  One setting I have found it useful to sometimes tweak a bit is the value of "left" in .divOnLineWithIntegrationLimits (also sometimes in .gridForPairOfIntegrationBounds) which helps reduce excess white-space in the lines being displayed by the browsers. Since there "scoped" property of the HTML style tag was deprecated and is not supported by most browsers, I'm not sure there is an easy approach to avoiding such potential issues. Maybe there is a better approach to keep the spacing reasonable without the use of negative values of "left" with "position: relative;".

Since openDiv() and openSpan() provide the ability to "wrap" any reasonable section of PG generated HTML code in a unit which can be assigned a class name, the use of such a wrapper and the type of descendant selector you used can make it easy to add formatting to input boxes without any need to add a new feature to PG to attach styling or an additional class name to input boxes directly.
In reply to Nathan Wallach

Re: Answer boxes for limits of integration - with support for MathQuill

by Larry Riddle -
I have used Nathan's coding for answer boxes with limits of integration in problems I wrote several years ago. As far as I recall, these problems had no issues until WeBWork version 2.17. We recently updated to 2.18 and the problems are are now generating a long list of non-fatal warnings. I haven't checked yet, but I assume I am seeing these warnings only in my role as admin, but that students will not see them. The problems are displaying fine and the correct answers are identified as such. But I would like to know if something has changed in 2.18 that is the cause of these warning messages. So I ran Nathan's simple01.pg code in the problem editor (hence the references to line xx of "undefined") and these are the warnings I got:

Warning messages
Non fatal warnings. These are only displayed for users with permission to view problem debugging info.
Use of uninitialized value $html_attribs in concatenation (.) or string at line 1794 of [PG]/macros/core/PGbasicmacros.pl
from within main::openDivSpan called at line 1835 of [PG]/macros/core/PGbasicmacros.pl
from within main::openDiv called at line 2 of (eval 2493)
from within main::EV3P called at line 163 of undefined
Use of uninitialized value $html_attribs in concatenation (.) or string at line 1794 of [PG]/macros/core/PGbasicmacros.pl
from within main::openDivSpan called at line 1835 of [PG]/macros/core/PGbasicmacros.pl
from within main::openDiv called at line 2 of (eval 2493)
from within main::EV3P called at line 163 of undefined
Use of uninitialized value $html_attribs in concatenation (.) or string at line 1794 of [PG]/macros/core/PGbasicmacros.pl
from within main::openDivSpan called at line 1835 of [PG]/macros/core/PGbasicmacros.pl
from within main::openDiv called at line 2 of (eval 2495)
from within main::EV3P called at line 163 of undefined
Use of uninitialized value $html_attribs in concatenation (.) or string at line 1794 of [PG]/macros/core/PGbasicmacros.pl
from within main::openDivSpan called at line 1835 of [PG]/macros/core/PGbasicmacros.pl
from within main::openDiv called at line 2 of (eval 2495)
from within main::EV3P called at line 163 of undefined

I also ran Glenn's code from IntegrationLimitsWMQ-PGML.pg mentioned above, and got a much longer list of warning messages.

Here is an example of a problem I wrote that is now giving warning messages.
In reply to Larry Riddle

Re: Answer boxes for limits of integration - with support for MathQuill

by Glenn Rice -

Those warnings are only shown for users with permission to view problem debugging info as stated in the message.  So your students will not see those.

We changed the way that those warnings are handled to make these warnings more visible so that problem authors will see issues with their code and start fixing them.  Previously these warnings only went to the apache2 error log.

In this case, you have discovered a minor issue with the openDivSpan method defined in PGbasicmacros.pl.  The $html_attribs is defined without a default value.  So if no html attributes are passed in the options, then it remains undefined, and when it is used later it gives the warnings.  I will open a pull request to fix the issue.