Mathematics tools

Moodle.org MathJax Status Under Moodle 2.7

 
 
Picture of Marc Grober
Moodle.org MathJax Status Under Moodle 2.7
 

The following courtesy of Aparup....

 
Aparup Banerjee added a comment - Today 1:50 PM

I had a chat with Damyon after getting up to speed on what was happening with Mathjax, summarising what i understand here for implications on moodle.org upgrade:

[10:37:27] <aparup> particularly - 'change in TeX display' -- we've changed it? or is it BC?
[10:45:47] <Damyon Wiese> Well there is now a MathJAX filter
[10:45:58] <Damyon Wiese> but it's only enabled by default for new installs
[10:48:34] <Damyon Wiese> in order to 100% preserve the formatting of texts that were previously rendered with the tex filter and now are rendered with the math jax filter
[10:48:43] <Damyon Wiese> there is a BC setting that must be switched on
[10:50:06] <Damyon Wiese> the setting is "texfiltercompatibility"

10:55:18] <aparup> hm ok. so there is actually one trade off for the formatting.. that all previously tex-rendered stuff (that was all/always inline) will be maintained by 'texfiltercompatibility' being turned on (default for upgrades) BUT that denies anyone ever using 'display'... so 'display' is a new feature for 27?
[10:55:46] <Damyon Wiese> yep - that's correct

[11:00:38] <Damyon Wiese> all of the old syntaxes are only supported if that setting is turned on
[11:00:53] <Damyon Wiese> the old syntaxes are: 
[11:00:57] <Damyon Wiese> <tex>fds</tex>
[11:01:08] <Damyon Wiese> [tex]dfsa[/tex]

[11:02:11] <aparup> Ok. so for moodle.org - i'm gathering that we should turn it on.. but we'll make a call (possible later on?) on allowing the new features some how too.
[11:04:50] <Damyon Wiese> yep - the new stuff can be turned on later
[11:05:40] <Damyon Wiese> maybe some queries of the DB looking for the crappy tex syntax might help
 
Average of ratings: -
Picture of Marc Grober
Re: Moodle.org MathJax Status Under Moodle 2.7
 

Algebra filter not turned on? @@x^2@@

This is supposed to be in display mode and is inline \[x^2\]

This is supposed to be in inline mode \(x^2\) and is inline mode

This is old Tex filter which is really inline mode $$x^2$$

Apparently MathJax filter is not running????

 
Average of ratings: -
Picture of Mauno Korpelainen
Re: Moodle.org MathJax Status Under Moodle 2.7
 

MathJax filter seems to be enabled now with default settings and double dollars are rendered as DisplayMath - they probably should be InlineMath.

 
Average of ratings: -
Picture of Mauno Korpelainen
Re: Moodle.org MathJax Status Under Moodle 2.7
 

On the other hand the equation editor does create inlineMath \( \left| \begin{matrix} a_1 & a_2 \\\\ a_3 & a_4 \end{matrix} \right| \) and changing the inlineMath delimiters \ ( ... \ ) to default displayMath delimiters \ [ ... \ ]  or doubledollars isn't a big issue \[ \left| \begin{matrix} a_1 & a_2 \\\\ a_3 & a_4 \end{matrix} \right| \]

Of course Moodle Docs, help files and tabs of equation editor can be improved in the long run but this is again a big step forward  smile

 
Average of ratings: -
Picture of Marc Grober
Re: Moodle.org MathJax Status Under Moodle 2.7
 

I can confirm that behavior has changed since I initially posted, which was some hours after the update was flagged as having been completed.

Apparently ASCIIMathML was NOT implemented. Algebra notation is not available either.

 
Average of ratings: -
MD shot of me from his iphone4
Re: Moodle.org MathJax Status Under Moodle 2.7
Group DevelopersGroup Moodle Course Creator Certificate holdersGroup Moodle HQGroup Testers

Thanks for checking Marc.

I suspect the delay in observable changes may be due to cloudflare caching particularly image files more aggressively then other files in its network. (Edit: i'm not sure anymore.. there was a config change)

ASCIIMathML is supported by further configuration with Damyon's work on core however we only have 'filter_mathjaxloader | mathjaxconfig ' set to default at the moment.

 
Average of ratings: -
Picture of Marc Grober
Re: Moodle.org MathJax Status Under Moodle 2.7
 

Note that the display of my initial post is now no longer as it was described when posted (some hours after the update was supposedly completed and MathJax already running and that your post was put up some additional hours after my post.

 
Average of ratings: -
moi!!! it is what is is...
Re: Moodle.org MathJax Status Under Moodle 2.7
Group Documentation writersGroup Particularly helpful Moodlers

\( \sqrt{4}=2 \)

$ \sqrt{4} = 2 $

$$ \sqrt{4} = 2 $$

\( \sqrt{4} = 2 \)

\[ \sqrt{4} = 2 \]

Well... I am getting 4 out of 5 - or are these already cached? The first is the equation editor  Nos 3 and 5 are centred, 3 uses the double $, 4 uses the slash(, as the equation editor does, and 5 uses the slash[ if you can't see the coding... 

This is better than it was anyway- let's hope it stays that way. And Marc, I don't see the point of continuing with the Algebra filter anyway, I suggest it is passed its use-by date and should be dropped. One day, the TeX filter may also, I suspect, but not for a while yet. 

 
Average of ratings: -
Picture of Marc Grober
Re: Moodle.org MathJax Status Under Moodle 2.7
 

Clearly something took place after the upgrade finished that resulted in the MathJax filter eventually coming on line, and as Mauno notes, inline doubledollars is being presented as display math, which I think is probably a more appropriate default. 

However, I thought that double$ was going to be left to be parsed by the TeX filter, and it is not (right click on the doubledollar equation and you will see that the MathJax menu appears, not the tex filter popup from displaytex.php,  e.g. /$/$x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}/$/$ (note that while this should be rendered inline, it is in fact rendered as display math,  which is what I think most using Math in Moodle would really expect to happen: $$x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}$$

So, something is happening,  but I am not sure what is happening, there are no docs to explain exactly what is happening and someone (Damyon?) is expected to be changing things.

As far as the Algebra filter, I once made a similar suggestion about retiring it and was amazed at the uproar that ensued....  a cleverer approach would be to develop a MathJax preprocessor for Algebra notation.  The notation is borrowed from WebworKs and frankly I don't know if Michael et al would be interested in even considering that.

 
Average of ratings: -
Picture of Daniel Thies
Re: Moodle.org MathJax Status Under Moodle 2.7
Group DevelopersGroup Particularly helpful MoodlersGroup Testers

Yes, it seems like a team of developers should be able to look at the algebra filter (filter/algebra/filter.php) and remove the part that does the TeX rendering. Then MathJax or whatever could render it more neatly than what it has been using which is apparently Mimetex.  It should not take more than six months to do.  So if we hurry it might just be ready for 2.8. Maybe I am dreaming.  It must be more complicated than that.

 
Average of ratings: -
Picture of Marc Grober
Re: Moodle.org MathJax Status Under Moodle 2.7
 

As I mentioned, the Algebra filter uses the parser from WebworKs to convert to TeX, and the TeX is passed to the TeX filter (the reason the Algebra filter requires the TeX filter.) 

Essentially creating the MathJax preprocessor for WebworKs would be no more difficult (and arguably much less difficult) than the effort expended by David Lippman to create the current asciimathml preprocessor, and if the folk at WebworKs (like Michael) are interested in using MathJax I imagine something could be offered to Davide in short order.


 
Average of ratings: -
Picture of Daniel Thies
Re: Moodle.org MathJax Status Under Moodle 2.7
Group DevelopersGroup Particularly helpful MoodlersGroup Testers

Actually, the current algebra filter does not seem to utilize the TeX filter directly.  It sources the library files from the TeX notation filter, and renders the TeX mysteriously with the mimetex binaries from the TeX notation filter. I assume this is for some historical reason.  The attachment I include above does the more straight forward hand of to TeX filter, and produces better results. 

 
Average of ratings: -
Picture of Marc Grober
Re: Moodle.org MathJax Status Under Moodle 2.7
 

Daniel,

I don't know what may have happened to the Algebra filter that is not documented, but historically the filter would not work unless you turned the TeX filter on because the algebra filter was simply parsing double@s and converting them to TeX, and then passing the TeX to the TeX filter (which falls back to mimetex.) I think Zbigniew Fiedorowicz originally set it up to use mimetex directly but this was tweaked to use the filter so that mimetex would only be sourced if TeX (technically the TeX and ImageMagick binaries) were not available, which was why the TeX filter had to be enabled (it would not have to be enabled if the Algebra filter were directly sourcing the mimetex binary.)

So, the php filter script calls the algebra2tex.pl script, which parses the Algebra notation, converts to TeX and passes the results to the TeX filter (you can see in Webworks that it now uses MathJax as well to render the tex.)

What I was suggesting was that rather than using algebra2tex.pl, if WebworKs was interested, or perhaps even had done the work,  the role of algebra2tex.pl could be assumed by a MathJax preprocessor.  This would eliminate the need for the TeX filter for almost all users, as TeX rendering for almost everyone would be managed through MathJax.  That would leave only those who really wanted to use the full features of TeXLive (for example, because they wanted to invoke macros.)

Frankly I did not notice any attachment above, and in looking now I see a php file which I assume is the wrapper for algebra2tex.pl.  If I am wrong, and you actually rewrote algebra2tex.pl in php,  then you should obviously file a tracker item to replace the current algebra filter.

I note also that you mention that you have done some work on the Tex filter,  but I did not see that the MDL that I had created (which initially was intended to drop the ImageMagick binary since it has been decades since Tex shipped without the binaries necessary to eliminate the convert binary) was the target for your work,  so perhaps you should create a new MDL for your work if you have not done so already?


 
Average of ratings: -
Picture of Daniel Thies
Re: Moodle.org MathJax Status Under Moodle 2.7
Group DevelopersGroup Particularly helpful MoodlersGroup Testers

I have code in MDL-44925 for a minor revision to the TeX filter to use dvisvgm instead of convert. This is a similar to your idea of using dvipng, but as an adding a display option. The filter.php attachment only makes it change the algebra to TeX.  I did not rewrite the perl module to PHP although that probably would not be that involved.

I have been working with another prototype that uses David Lippman's ASCIIMath2TeX to generate images, and is compatible with MathJax.  It is a total rewrite of TeX notation to make it more MathJax friendly.  I have not added a new MDL, but plan to when semester grades are done.

 
Average of ratings: -
Picture of Marc Grober
Re: Moodle.org MathJax Status Under Moodle 2.7
 

I took a look at what shows up in SOURCEXref for algebra2tex.pl ( http://www.sourcexref.com/xref/moodle/nav.html?filter/algebra/algebra2tex.pl.html ) and you will note that around line 80 the script calls displaytex.php - displaytex.php is part of the TeX filter which though initially created by Z to just use mimetex, was expanded so as to be able to use TeX binaries if they are available as you know.

Z left the forums around 2007 I think and I think Petr then was working it in to the form we have now,  but it is largely 10 year old code that has been tweaked here and there.

As you are by now aware, David used the Algebra filter as a model for his ASCIIMathML filter, which you have been playing with,  but I should warn you that that filter was guilty of some misbehavior that we document half a dozen years or so ago.

 
Average of ratings: -
Picture of Daniel Thies
Re: Moodle.org MathJax Status Under Moodle 2.7
Group DevelopersGroup Particularly helpful MoodlersGroup Testers

displaytex.php does not handle image generation.  It is simply generates the response to the request to display the original source when one clicks on the image. The TeX binaries are called from pix.php in the TeX filter by including the latex class from latex.php.  filter.php inserts this url for algebra/pix.php in lines 67-74. The pix.php file in algebra does not include latex.php, but only filter/tex/lib.php (line 17) from which it retrieves the mimetex binary (line 45).

 
Average of ratings: -
Picture of Marc Grober
Re: Moodle.org MathJax Status Under Moodle 2.7
 

yes, you are correct (that's what I get for not paying attention, lol) , which means there is no reason to check if the TeX filter is enabled or use the TeX filter for the Algebra filter and (I never realized this because I never used the Algebra filter) the Algebra filter has always relied only on mimetex, lol.  I had I think assumed based on what I had seen from I think Isner thatthe Algebra filter had been tweaked to employ the same fallback  that the TeX filter uses.

So perhaps the best course of action is delete the if_enabled test for TeX and provide a config setting that allows the user to set the utility which the filter would use to display the TeX that algebra2tex.pl produces (with an error thrown that it is not properly configured if setting not appropriate)?  This would allow usage of MathJax or TeX w/ fallback or even other options.


 
Average of ratings: -
Picture of Daniel Thies
Re: Moodle.org MathJax Status Under Moodle 2.7
Group DevelopersGroup Particularly helpful MoodlersGroup Testers

I have to confess that was surprised when I first looked at it because I had never really utilized it either. The attachment I had simply converts the algebra to TeX with inline delimiters. It does not seem to test for TeX filter as we have always assumed. It renders correctly with either MathJax or  TeX filter following it in sequence.

 
Average of ratings: -
Picture of Marc Grober
Re: Moodle.org MathJax Status Under Moodle 2.7
 
I am sorry if I was a bit confused. I have been away from the code awhile.  I recall that there were at least a couple of spots where there were if_enabled clauses,  but that most users with problems were not getting an error message that the TeX filter was not on,  but would get no output if it were not on. This may be the inverse(?) of what we say with the asciimath filter, where it would not really turn off (as I recall if it found a js lib it ran, whether turned on or off,  which made things interesting. ) If the Algebra filter did not actually require the TeX filter to be on, then why would it not work unless it was turned on, after all, mimetex has shipped with Moodle for a decade?

I think you should create two new tracker items (though I may have missed them if you already did this) and a new thread here to address the discussion of that generally, as typically people will not know what is in the tracker unless it is discussed in the forum.  One tracker item to focus on replacing the old ALgebra filter with a new one (MDL), and then post your code and your ideas there.  A second tracker item (MDLSITE) to address turning on that filter at Moodle.org so that folk who want to discuss Algebra Notation have access to same, with a link to the other tracker item.  And then the thread here, with links to the tracker items and vice versa.  Solicit forum participants to VOTE for your tracker item.  Then, demonstrate that the path you suggest is the only logical way to go and have a couple of dozen folk agree, and in 6 years or so I think we will see changes (though one could hope for less, lol)

Critical to the success of such a move would be to get all the closet Algebra filter users to test, comment and approve on the replacement (which should be a no brainer providing that the TeX display function can be set by the user..)

On the issue of a new TeX filter, I think it also needs to be able to do what MathJax does, i.e. in the past you got mimetex or you got gif/png....  No reason a TeX filter should not produce all the various outputs MathJax produces, and arguably should be able to take advantage of MathTex and other  tools (where they are available - added to make the WIndows crowd happy, lol.)

In sum, this is the kind of thing Mauno and I chatted about years ago - a more universal architecture that could automagically detect the math syntax in use, and then render it appropriately based on the tools selected by SA and user. In a very real sense that is in part what MathJax does (i.e. it is the framework that makes it such an exciting tool.)

 
Average of ratings: -
Picture of Daniel Thies
Re: Moodle.org MathJax Status Under Moodle 2.7
Group DevelopersGroup Particularly helpful MoodlersGroup Testers

I added MDL-45600 to add a more universal math filter. I think it is realistic for this to be included in 2.8.  Unless there is a large user base of the Algebra filter that wants to upgrade to 2.7, I don't think the integrators are going to be eager to make changes currently in the Algebra filter in 2.7.  How big is the closet?

 
Average of ratings: -
Picture of Marc Grober
Re: Moodle.org MathJax Status Under Moodle 2.7
 

One of the reasons I think that any notation supported by core should be supported by Moodle.org is to keep such users involved in the community.  Many involved here simply ignore the fact that countless folk have simply decided not to use this resource for a variety of reasons (I suppose I might be one, lol.) How big the closet is is difficult to assess - certainly there are more doing Math with Moodle than I think Martin supposes, and the uproar when I suggested doing away with the Algebra filter a few years ago suggests that they are elementary and publish school teachers who just want to be able to "do Math" without any "trouble."  The critical bit is to be able increase functionality without losing anyone. I think that woujld be easy enough to do but for the folk in Oz.

 
Average of ratings: -
moi!!! it is what is is...
Re: Moodle.org MathJax Status Under Moodle 2.7
Group Documentation writersGroup Particularly helpful Moodlers

I don't know what you are referring to here Marc..thoughtful  

  

 
Average of ratings: -
Picture of Marc Grober
Re: Moodle.org MathJax Status Under Moodle 2.7
 

I was referring to a Tracker comment posted by MD in which he disposed of the possibility of making ASCIIMathML available on Moodle.org -  he eventually argued that he didn't know that ASCIIMATHML is now core, and edited that to say "he forgot" ....

Sorry didn't mean to besmirch ALL Aussies.....

 
Average of ratings: -
moi!!! it is what is is...
Re: Moodle.org MathJax Status Under Moodle 2.7
Group Documentation writersGroup Particularly helpful Moodlers

You realize of course, that we are one of the world's leading nations in the number of cases of... um... um, you know that one where we forget things, Seems endemic to politicians, bankers, economists, teachers and other tradesmen, like, accountants, billionaires... must be in the water... or wine!

 
Average of ratings: -
Picture of Marc Grober
Re: Moodle.org MathJax Status Under Moodle 2.7
 

By the way, WebworKs already uses MathJax (in fact Davide is active in their forums, which are in a Moodle.)  I have not looked at the architecture for webworks for several years, ans for all I know this may be advanced enough that the Algebra filter just needs a bit of a tweak.  

I don;t think the ALgebra filter was coded to check for the TeX filter being on,  so I am wondering if someone running 2.7 could determine whether with the MathJax filter and the Algebra filter on and the TeX filter off whether ALgebra filter will parse and display??

 
Average of ratings: -
moi!!! it is what is is...
Re: Moodle.org MathJax Status Under Moodle 2.7
Group Documentation writersGroup Particularly helpful Moodlers

Seems like a lot of work developing a preprocessor for a minimal return though, Marc. As best as I can tell, I don't know anyone who is consistently using Algebra Notation, but, to be fair, I only know a few people are using the TeX Filter consistently - not many. 

The thing that strikes me about the equation builder is that it is still largely dependent upon the user's knowledge of TeX anyway. It may have a use for seriously advanced Maths but I would suspect that the number of people using that level of Maths as opposed to your usual high school Maths, is seriously disproportionate to the effort put into adapting the equation builder. If the equation builder had the basic symbols like \sqrt in a tab, as the operators symbols etc. are, then it would have a lot more appeal I think. (But I am still not that familiar with the equation builder.)  Is there opportunity to add symbols, use other (say physics and chemistry, statistics and so on) symbols without having to deconstruct the equation editor? That would be very useful I suggest. 

But then another thought, could all this be made moot by the universal adoption of HTML5 standards? (No idea here, have not kept up with it - so only asking.)

 
Average of ratings: -
Picture of Marc Grober
Re: Moodle.org MathJax Status Under Moodle 2.7
 

First thing to note is that I argue that the forum should be able to support all core notation, but of course the forum doesn't, so you won't see examples. But there are quite a few users with substantial investments in Algebra notation, and killing it off will be horribly frustrating as that means years of development in their local noodles might go up in smoke.

So, eventually the link between TeX filter and Algebra filter will need addressing, as well as rewrite of TeX filter itself (MathJax is not the ultimate solution for many.)

The key then is to convert the perl of the Algebra parser to the js of a MathJax preprocessor, and to cleverly have the guys at Rochester do it

html5? Might as well wonder when browsers will fully support MathML, lol

Equation Builder? My time in the hot seat is past... If it exceeds the functionality and ease of use of dragMath we will hopefully be moving in the right direction. At some point keyboards will be obsolete; that is the divide.

 
Average of ratings: -