Math in Moodle

If you’re like me and interested in using math notation in Moodle, I believe you have 2 options. The first option is to use the TeX filter that is in Moodle. This is a LaTeX type editor. To enable, go to site administration -> plugins -> filters TeX in Moodle: http://docs.moodle.org/en/Using_TeX_Notation And more notation info: http://docs.moodle.org/en/Using_TeX_Notation_2

The big problem with TeX in my mind is that it is a bit awkward to use. However, if the range of notation that you want is narrow, you can quickly learn how to input what you need.

I think the better option is to use ASCIIMathML because it is easier to use, is more intuitive and also looks better. However, one of the big problems with ASCIIMathML is that it only works with Firefox. No other browsers are able to display its notation without other plugins. There are two workarounds for this. First, you can demand that users use Firefox. Secondly, you can use a version of ASCIIMathML that has a “fallback.” How the fallback works is if the browser does not display the ASCIIMathML correctly, it automatically switches to displaying LaTex images.

First let’s start with the ASCIIMathML. You can find a bit of information about it here, including a link to download: http://docs.moodle.org/en/ASCIIMathML I found this thread on the Moodle forums to be very helpful: http://moodle.org/mod/forum/discuss.php?d=153697 For my examples below you have to include a javascript file inside your Moodle installation. I am assuming that you are putting the ASCIIMathML.js file in the folder:

http://www.yourdomain.com/moodle/lib/asciimath/

Adjust this url with your own domain.

To get asciimath working in Moodle 2.0, go to site administration -> Appearance -> Additional HTML In the “Within HEAD” section, paste the text:

What this does is ensures that the ASCIIMathML javascript is inserted into the head of every html page. If you don’t have Moodle 2.0, you have to find your config.php file for your theme and insert the text there. For example, if you are using the theme FormFactor, go to the file: http://yourdomain.com/moodle/theme/formfactor/config.php

Open the config.php file in an appropriate editor (I use Codelobster) and somewhere between

insert the line: <mce:script type=“text/javascript” mce_src=“http://yourdomain.com/moodle/theme/formfactor/lib/asciimath/ASCIIMathML.js"></mce:script>

In firefox you should now be able to use ASCIIMathML notation. I had an additional problem and had to edit my asciimathml.js file. Somewhere around line 50 in this file I had to change

var avoidinnerHTML = false;

to var avoidinnerHTML = true;

Okay, now that it’s working you can try a fallback version. I used ASCIIMathMLwFallback2.js from http://dlippman.imathas.com/asciimathtex/AMT.html I edited the same “avoidinnerHTML” in the .js file, uploaded it to the same /lib/asciimath folder, and edited the “Within HEAD” section to use the new javascript file name. I now have ASCIIMathML working on all browsers. More info on fallback can be found at this Moodle forum link: http://moodle.org/mod/forum/discuss.php?d=134706