Moodle 2.X math plugins

Re: Moodle 2.X math plugins - new developments...

by Mauno Korpelainen -
Number of replies: 9

In mathjax syntax you can can add colors (text, background or border, in fact any css elements) by selecting the mathematical notations you have written and then using Select text color and Select background color buttons/palettes in editor toolbar (or html). Mathjax also supports colors in mathml but only \color in latex expressions.

In my asciimathml script latexmathml was written to give full color support and it works nicely with combination mathml & mathtex fallback with \textcolor and \colorbox syntax but requires \usepackage[usenames]{color} or \usepackage{color} either in tex filter tex preamble or in fallback tags if color package is installed in that existing latex distribution. Again if I set asciimathml script to use mathjax fallback it can use in latexmathml (latex) syntax colors with all other browsers than IE6-8 that would require mathtex fallback...

Even if mimetex supports only a few named colors with custom syntax like \red, \blue or \green google chart api tex (that otherwise is using mimetex syntax) can use all colors + gradient & striped fills with chart api syntax and you can change both textcolor and background color in editor googletex plugin with color tools at the top of plugin - background is set to transparent by default.

Mathtran does not support colors at all - here some background from year 2009: http://moodle.org/mod/forum/discuss.php?d=133132#p587630

More about this kind of issues in the coming docs - it may take some time to get the docs finished...

Average of ratings: Useful (1)
In reply to Mauno Korpelainen

Re: Moodle 2.X math plugins - new developments...

by Mauno Korpelainen -

In fact MathJax has a much wider color and other style support than I knew before weekend when I visited an excellent test page by Dr. Carol J.V. Fisher in

http://www.onemathematicalcat.org/MathJaxDocumentation/TeXSyntax.htm

It is a huge page and gives much detailed information about special features of MathJax that are not all documented on main pages of MathJax.

I wonder if core developers and site administrators of moodle.org could allow adding mathjax script tags with some acceptable tokens to Moodle Docs - I was testing yesterday documentation with mediawiki (not with mathjax extension but with mathjax script tags in mediawiki theme) and it works fine using CDN mathjax. Here an example page:

http://korpelainen.net/m2mathwiki/index.php/Style

One more good point in using mediawiki is that it has printable pages available and if output of mathjax is set to HTML-CSS printing should give good quality output in all browsers - example

http://korpelainen.net/m2mathwiki/index.php?title=Style&printable=yes

The other option to add some more documentation to moodle docs might of course be to use current latex which can render most example as images.

Average of ratings: Useful (1)
In reply to Mauno Korpelainen

Re: Moodle 2.X math plugins - new developments...

by Marc Grober -

Seems to me discussions along those lines with respect to ASCIIMathML went, well, nowhere. Seems to me that you and I, Mauno, were demonstrating use of maths in mediawiki for some time and are arguably lucky to have what we have now in Moodle docs (Blahtex,as I recall?)  as Maths is not central to Moodle, to paraphrase one Moodle dev.....  Even the suggestion that a separate space in the docs for use of math fell on deaf ears and tracker items litter the tracker system.

In reply to Marc Grober

Re: Moodle 2.X math plugins - new developments...

by Mauno Korpelainen -

Well...  asciimathml was just not crossbrowser compatible then and still today official scripts aren't and we are talking about "our files", "Peter's files", "David's files"...

On the other hand MathJax is today both production ready and well documented in http://www.mathjax.org/ , it has great sponsors (supporters) and adding support of MathJax to moodle docs would require just adding a couple of lines to moodle docs skin (moodledocs). Mediawiki of moodle docs seems to be in version 1.16.5 and my examples are in mediawiki version 1.17.0 so modification of skins may have some differences but in my case I have in skin file Vector.php and function initPage lines

$out->addHeadItem( 'mathjax','<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js">
MathJax.Hub.Config({config:["TeX-AMS-MML_HTMLorMML.js"],jax:["input/TeX","input/MathML","output/HTML-CSS"],extensions:["tex2jax.js","mml2jax.js","MathMenu.js","MathZoom.js"],tex2jax:{displayMath: [ ['."'XX','XX'] ],  inlineMath: [ ['Y','Y'".'] ]},TeX:{extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"]}});
</script>'
);

to output cdn mathjax script tags in mediawiki. The mediawiki extension option is also available.

In the place of XX I use double dollars and in the place of Y tokens single dollars (did not want to output latex here).

On the other hand we see in moodle 2 (compared to moodle 1.9) what happens when lots of new features are added, number of lines of code doubles,... so I will use a compromise option and add some things to moodle docs with the tools that are in current mediawiki and use links to my personal wiki and demo site tools in such cases where moodle docs can't be used. One good point in Petr's book module is that it can be used to demonstrate also geogebra mobile examples so we will be able to show some things from the future tools... wink

In reply to Mauno Korpelainen

Re: Moodle 2.X math plugins - new developments...

by Marc Grober -

No, I agree that MathJax will be good for the web and great for Moodle. I am just not going to hold my breath....  As far as Moodle Docs, I am thinking that it would be much better to try to agree on a public mediawiki which could be by design focused on supporting Math in Moodle and the like along the lines of what you, I, and other have done.  It sems to me rather foolish to discuss using geogebra, geonext, jsxgraph etc in an  environment that can't support their illustration. I tried to do something of the sort through the University here and they are simply not interested in getting involved with supporting computer aided Math instruction (I guess that in part explains why so many kids in Alaska can't do Math....)

In reply to Marc Grober

Re: Moodle 2.X math plugins - new developments...

by Mauno Korpelainen -

I was a little suprised to see that most of the things we have in this package can be seen (both maths and graphs) also in mobile devices. Just tested with mymobile theme (with script tags in layout files / extras.php and $CFG->texteditors = 'textarea'; in theme config.php since mobile devices do not yet support editing of content with tinymce and therefore can't use editor / plugins) .

Here some screenshots from Opera Mini simulator:

Mobiles

In reply to Mauno Korpelainen

Re: Moodle 2.X math plugins - new developments...

by Hilary Lai -

Mauno, Thanks your everything you did. It just is so good.

I followed your method described in the post trying to turn mymobile theme to be friendly to your tools. I find that Mathjax can only be displayed properly if I refresh the page after it is loaded. For other things like google chart and jsxgraph, they just do not load. It happened on my 3Gs iphone and android phones.

Could you give me some hints to make it work?

In reply to Hilary Lai

Re: Moodle 2.X math plugins - new developments...

by Mauno Korpelainen -
I have been really busy with my actual work - teaching - so I have not tested mobile themes or upgraded these files lately... or a couple of months... Anyway mymobile is not a typical moodle 2 theme - it is using jQuery and some custom elements and not loading all javascripts like other moodle 2 themes do. When I tested mobiles before last Christmas I was using stylist theme as a "prototype theme" for mobiles and those screenshots in previous post were taken from my test site running stylist theme in opera mini browser. Most javascripts seemed to work ok even in simple mobiles if those javascripts were rendered in theme layout files - but I never did a large scale testing with all sorts of mobiles. Thinking about myMobile theme javascripts should probably be initialized before jQuery or some other timing issue could explain this behaviour you described. I could try to check these issues and upgrade the files you mentioned in another post (jsxgraph etc) next week during our short skiing holiday. The asciimathml files in the package were very experimental and asciimathml extension for mathjax 1.X (modified version of David Lippman's asciimathml extension) was included only to local files but did not exist in cdn files so adding configuration for asciimathml with cdn files could not work as those files did not exist in cloud server. And if MathJax 2 is going to have a fully functional asciimathjax extension it makes using asciimathml with MathJax much simpler. At the same time the whole configuration of these plugin files might need some rewriting to make changing configurations and different settings of configurations more user friendly and to avoid conflicting settings. If days were just longer... smile
In reply to Marc Grober

Re: Moodle 2.X math plugins - new developments...

by Mauno Korpelainen -

As a proof of concept that opinions of core developers can change check http://tracker.moodle.org/browse/MDL-27622 where Martin D says:

 (In related news I hope that sometime soon we might even switch from YUI to jquery even for all the other core stuff).

This kind of news are sensational - even inside parentheses - core moodle using jQuery !!! And it's not April!

For several years jQuery has been a "bad word" here in moodle.org - if you have mentioned that you like jQuery more than YUI since jQuery can do some things in a much quicker, shorter and simpler way than YUI you may have gotten "freezing feedback" since YUI is the choice that we use... wink

Times change like we do.

In reply to Mauno Korpelainen

Re: Moodle 2.X math plugins - new developments...

by Marc Grober -

Well, that is good news.....  but I am  not going to be holding my breath wink