WeBWorK Problems

Hiding the code for an input box from students

Hiding the code for an input box from students

by Darwyn Cook -
Number of replies: 5
I am writing change of variables in integrals problems. I thought I would be clever and put the answer boxes as limits using code similar to:
\[\int_\mbox{\{ans_rule(10)\}}^\mbox{\{ans_rule(10)\}}\mbox{\{ans_rule(10)\}}dx\]

The code works fine, but if you double click on the displayed formula it shows the formula for the code in a pop up window along with values the student has put in: for example if I put in a lower limit of -1, an upper limit of 1, and the integrand as x then the pop up box contains:

\int_\mbox{<INPUT TYPE=TEXT SIZE=10 NAME="AnSwEr1" VALUE="-1"><INPUT TYPE=HIDDEN NAME="previous_AnSwEr1" VALUE="-1">}^\mbox{<INPUT TYPE=TEXT SIZE=10 NAME="AnSwEr2" VALUE="1"><INPUT TYPE=HIDDEN NAME="previous_AnSwEr2" VALUE="1">}\mbox{<INPUT TYPE=TEXT SIZE=10 NAME="AnSwEr3" VALUE="x"><INPUT TYPE=HIDDEN NAME="previous_AnSwEr3" VALUE="x">}dx

This happens in Firefox, I have not tried it in IE. Is there a way to prevent this from happening?
In reply to Darwyn Cook

Re: Hiding the code for an input box from students

by Davide Cervone -
Note that what you have done will work ONLY in jsMath mode. if you switch to images or one of the other modes, it will not show the answer rules properly.

The usual way to do this is via a table. See my earlier post for an example of how to do that.

If you are forcing everyone to use jsMath mode, then you can use the code that you have given, but you are right that double-clicking the equation does produce the display that you indicated in your message. The best way I can think of to handle this is to disable jsMath's double-click function. You can do that by adding

    TEXT(MODES(
        TeX => "",
        HTML => "<SCRIPT>if (window.jsMath) {jsMath.Click.DblClick = function () {}}</SCRIPT>"
    ));
to your problem file. It is also possible to disable double-click on a global basis by changing the setting of processDoubleClicks in the $pg{displayModeOptions}{jsMath} variable (search for it in global.conf. You can change this setting on a course-by-course basis by adding
    $pg{displaModeOptions}{jsMath}{processDoubleClicks} = 0;
to the course.conf file for the course you want to change.

Hope that helps.

Davide

In reply to Davide Cervone

Re: Hiding the code for an input box from students

by Darwyn Cook -
Thanks Davide, that did the trick. I am forcing everyone into JS Math mode. Originally I was using the table approach, for the problems I am writing this seemed cleaner.
In reply to Darwyn Cook

Re: Hiding the code for an input box from students

by Davide Cervone -
OK. If you ever distribute your problem library, you will need to make a note of that so that other people trying to use it will know. It might be wise to put comments into the files now as you make them that indicate that. It would also be possible to put some code in that puts up a warning jsMode needs to be use if it isn't the current mode. Something like (untested):
    TEXT(MODES(
        TeX=>'', 
        HTML_jsMath => '',
        HTML=>$HR."Warning: to use this problem, you need to ".
                  "select jsMath mode in the Options panel at the left".$HR,
    ));
It might even be possible to use CSS styles to prevent the rest of the problem from being displayed at all outside of jsMath mode.

You could put this (and the code to turn off double clicks) into a macro file and use loadMacros() to load it and have the code executed automatically. That would make it easier to adjust the error message for all files at once, for example. You can put the macro file in the same directory as the problem files, or in your course templates/macros directory, or make your own macro library directory and include it in the search path by changing the path variable in global.conf.

Good luck with the problems.

Davide

In reply to Davide Cervone

Re: Hiding the code for an input box from students

by Darwyn Cook -
I had not given much thought to the problem library, certainly it would be appropriate to give back. Am I correct that jsmath is not available in older versions of webwork?
In reply to Darwyn Cook

Re: Hiding the code for an input box from students

by Davide Cervone -
Am I correct that jsmath is not available in older versions of webwork?
No, jsMath has been around since the beginning of WeBWorK2. JsMath was added in early 2004. It is not in WeBWorK 1.x, but there's really no reason to be running that at this point.

Davide