WeBWorK Main Forum

MathQuill and brackets

MathQuill and brackets

by Sean Fitzpatrick -
Number of replies: 13
A brief report one month into using MathQuill in a class of roughly 300.

-Students like it, of course. We had to turn it off briefly and there was much grumbling.

-As an instructor, I have some pedagogical concerns. The reason students like it is that they no longer have to pay attention to properly formatting their answers: MathQuill does a lot of the thinking for them.

I still want my students to have to think.
For example, with MQ on, I can enter e^9-2x+x^2 and everything is up in the exponent. Previously students were forced to use parentheses: e^(9-2x+x^2).

Others might disagree, but I think it was a good thing that they were forced to use parentheses. Even in written work, students are careless about this, and don't understand why they get marked wrong for omitting parentheses.

An example is using logarithmic differentiation. Many, many students will take the derivative of something like x^x and write their answer (on paper) as
x^x ln(x) + 1, which of course is not the same as x^x(ln(x)+1).

We're doing these problems now, and I've noticed a surprising detail:
if the student leaves out the parentheses in a problem like this, MathQuill will insert them on their behalf, and so they fail to get corrected on a significant error.
Perhaps in some cases students are entering the parentheses, but they definitely don't get displayed in the answer box. See the attached screenshot.

I don't want my students thinking that parentheses don't matter! Thoughts?
Attachment MQ-brackets.png
In reply to Sean Fitzpatrick

Re: MathQuill and brackets

by Glenn Rice -
MathQuill does not add the parentheses that are appearing in your answer. Do you have some local modifications, or option overrides to MathQuill? You have spaces in your answers that are not generally allowed by the implementation. There are ways to enter spaces using text (or mobile devices that don't seem to obey the spaceBehavesLikeTab option), but even with the spaces the parentheses are not added. I have tested this and entering the answer you display in the MathQuill input in your screen shot does not result in the answers in the results table you show in your screenshot. It is also a bit odd that the results table and the problem that you show in your screenshot do not seem to match.

Generally, the arguments that you are making seem to be arguments that you should turn MathQuill off and use html text inputs.
In reply to Glenn Rice

Re: MathQuill and brackets

by Michael Gage -
an alternative to MathQuill, MathView at least for Chrome browsers:

https://github.com/spirography/webwork-helper

It gives an intermediate amount of help -- such as automatically extending answer blanks.

It can/must be installed by individual students as a Chrome extension. If it catches on we could make it part of the core WeBWorK javascript code.


In reply to Michael Gage

Re: MathQuill and brackets

by Sean Fitzpatrick -
After looking at what was recorded for the student answers, it appears as though MathQuill is just failing to render some brackets. I should not that I have an unmodified MathQuill, as far as I know.

The student answer was recorded as:
[((1/(x+1)))+((1/(x-1)))-((1/(x+2)))-((1/(x-2)))][(((x+1)(x-1))/((x+2)(x-2)))]

The corresponding MathQuill answer is recorded as:

\left[\left(\frac{1}{x+1}\right)+\left(\frac{1}{x-1}\right)-\left(\frac{1}{x+2}\right)-\left(\frac{1}{x-2}\right)\right]\left[\frac{\left(x+1\right)\left(x-1\right)}{\left(x+2\right)\left(x-2\right)}\right]

So the brackets are there. But all the brackets recorded using LaTeX \left and \right delimiters are not showing up in the MathQuill rendering.

(And yes, next time I might leave it turned off to force students to think carefully about things like parentheses and order of operations!)
In reply to Sean Fitzpatrick

Re: MathQuill and brackets

by Glenn Rice -
I see the problem here. I have known about this, and know how to fix it. In fact I use a modified scaffold.pl macro that has the fix for my classes. It requires adding a little more to the javascript added to the page by the scaffold.pl macro. The issue is that the problem has the scaffolding set to the defaults that have only the active section open when the page loads. In your problem the first part has already been answered and is correct, and so that scaffold is closed, and most importantly the MathQuill input in that section is not visible. MathQuill has trouble rendering when its defining span is not visible due to the span not having its size allocated. So when the scaffold is opened the MathQuill object associated with the span needs to have its reflow method called. The fix is to have the 'keypress click' handler of the scaffold (that is called when a scaffold is opened or closed) cycle through the MathQuill answers on the page and call the reflow method for each one.
In reply to Glenn Rice

Re: MathQuill and brackets

by Sean Fitzpatrick -
Ok, thanks. This sounds like a fix that might make its way into WeBWorK at some point, rather than something one should try to fix locally.
Most students will probably not notice.

Mike, the Math View you mention is presumably different from the Math View editor that's been available for some time, where there's a button that pops open an editor? The GitHub readme says access is restricted to Rochester students.
In reply to Sean Fitzpatrick

Re: MathQuill and brackets

by Michael Gage -
I think that comment might be out of date. In particular in manifest.json

"content_scripts": [
{
"matches": ["*://*/webwork2*"],
"js": ["inject.js"],
"css" : ["styles.css"]
}
],

I believe used to be ["http://math.webwork.rochester.edu/webwork2"] but with
the *'s in it I believe it will work for any site.
Experiment with it and see what works. You can also try it out on
webwork courses on demo.webwork.rochester.edu which are in the rochester domain. See what you think. Is it worth polishing further?

Jeremy Spiro was a freshman when he wrote it. He's now graduated.



In reply to Michael Gage

Re: MathQuill and brackets

by Danny Glin -
This code assumes that the WeBWorK path is /webwork2, which is (theoretically) configurable. We should either generalize this to match the variable that sets the path to WeBWorK, or we should mandate that the path going forward is /webwork2.
In reply to Danny Glin

Re: MathQuill and brackets

by Glenn Rice -
In general the concept of a Google Chrome extension for this purpose is not a good idea. The path is only used by the extension to determine which pages to act on. If we were to integrate this into WeBWorK as Mike is suggesting we wouldn't use the path as the javascript would only be loaded on the pages generated by WeBWorK, and it would work for all browsers. The webwork2 path should be configurable.
In reply to Glenn Rice

Re: MathQuill and brackets

by Michael Gage -
I wasn't necessarily suggesting a Google chrome extension. I was suggesting implementing the features in javaScript, although I haven't looked in to how hard that would be. There may be some chrome specific features that would be hard to duplicate.

Those students that have used it here at U. of Rochester have liked the features and they didn't seem to get in the way too much so I was suggesting that we look at them and see if there is anything we would like to adopt.

I agree the webwork2 path should be configurable. We have already run into one block with that which we need to fix -- it's in the javascript that runs the library browser. There is a hardwired reference to webwork2 that needs to be made so that it grabs that snippet of the url from site.conf file.
In reply to Michael Gage

Re: MathQuill and brackets

by Glenn Rice -
I didn't think that you were suggesting a Google Chrome extension. I assumed you meant rewriting the javascript to work cross browser. Although the code does use some chrome specific things, those could be reimplemented utilizing other methods. I haven't looked at the code in a lot of detail either though, so I also don't know how hard that would be.

Is the hardwired reference to webwork2 that you are referring to the webserviceURL that is in htdocs/js/apps/LibraryBrowser/config.js? If that is what you mean, that will be tricky to fix. Javascript won't have access to the site.conf file. That portion of the javascript would have to be generated by perl to get the setting.
In reply to Glenn Rice

Re: MathQuill and brackets

by Michael Gage -
That's the hardwired reference in LibraryBrowser/config.js. I've had a couple of ideas of how to fix it, but have put it off in favor of getting 2.15 out. I'd also like the advice of those with more modern javaScript experience than I have.
You could make the webserviceURL global and set it from perl. In general I don't like setting globals but this one and perhaps some other config constants might be ok.
In reply to Michael Gage

Re: MathQuill and brackets

by Glenn Rice -
I ran into the same problem when coding the MathQuill answers and toolbar, and ended up using a few globals. In fact the pull request that stems from this discussion utilizes one of them. The answerQuills object that stores all of the MathQuill answer boxes for the page. I also designed a method to set separate options for each answer that uses global variables. The variable is something like MaThQuIlL_AnSwEr0001_Opts, of course with AnSwEr0001 replaced with the answer rule name. I am still trying to figure out a better way to do this, and to get a MathObject context to set the option. For example, parserRoot should set the rootsAreExponents option to be false.

Globals of course can cause possible conflicts, but in the end it is impossible to avoid globals entirely. Any javascript library must have at least one global object. If designed correctly you can avoid other globals. Ideally any options for the library can be set when the library is first loaded.