Forums | Mahara Community

Developers /
Math on Mahara


Geoff Rowland's profile picture
Posts: 108

06 July 2011, 15:43

Malcolm et al.

Unfortunately, WIRIS is not really an option for us.

MathJax, however works rather well for rendering mathematical notation (particularly with Iñaki's one line integration!).

So, it would be really neat to combine this with DragMath to provide a simple GUI for maths equations (as per the first post of this forum!).

Has anyone made any progress with this? I'll be prepared to have a go at 'reverse engineering' things from the Moodle-Dragmath integration, though suspect it won't be a quick job. Frown

Cheers

Geoff

Geoff Rowland's profile picture
Posts: 108

15 August 2011, 16:18

Hi

I have just added a DragMath equation editor bundle for Mahara to Gitorious

https://gitorious.org/mahara-dragmath/mahara-dragmath/trees/master

This adds the open source DragMath equation editor (the equation editor built-in to Moodle 2) to the Mahara TinyMCE toolbar. DragMath is a Java applet, so will need a local Java installation and won't work on all (e.g. some mobile) platforms.

The bundled Dragmath is configered to output TeX/LaTeX in one of two formats

Inline - the default - equations are delimited by \( and \)

Display - equations are delimited by %% and %% (like MoodleTeX)

To display equations correctly, you also need the open source MathJax JavaScript library to be installed, as outlined earlier in this thread.

See the bundled README for installation instructions. Apart from adding two new folders (and contents) /lib/dragmath and /js/tinymce/plugins/dragmath, only minor edits of /lib/web.php are required. For initial testing it is conveneient to link to the MathJax CDN, though you may wish to install a local copy of MathJax (in, say, /js/MathJax) for better performance.

http://www.mathjax.org/download/

The aim of all this is to provide a 'minimal' equation editor for Mahara. For inspiration about what else may be possible, check out  Mauno Korpelainen's work with Moodle:

http://moodle.org/mod/forum/discuss.php?d=182627

The usual warnings apply. So, do test before deploying on a production Mahara Wink

Enjoy

Geoff

Klaus Steitz's profile picture
Posts: 18

18 January 2014, 0:07

Hi all,

because i didn´t find new information about DragMath in Mahara i am using that old topic. DragMath apparently isn´t working anymore inside Mahara with modern browsers. See: http://docs.mathjax.org/en/latest/installation.html
(at the bottom: "Firefox and local fonts" and "IE9 and remote fonts")

DragMath ist still displayed in the editor and it is possible to use the Java-Frontend. But the latex-code isn´t displayed as "translated" picture like before. It just shows the source code and looks like this example:

\( \sqrt[3]{27} \)

\( \int_{n}^{1}x\,dx\)

 

That behaviour occurs in both of our Mahara-Installation, old one (1.3.7) and the new one (1.7.2). Using MathJax in combination with DragMath as described in the posts above.

Does somebody know workarounds? Exists a new version of "mahara-dragmath" (topic and git are last updated in 2011!)?

Are there plans to integrate Dragmath into core like in Moodle 2.x?

 

Thanks and kind regardsKlaus

Geoff Rowland's profile picture
Posts: 108

20 January 2014, 8:56

Hi Klaus

Sounds as if the Java DragMath editor plugin *is* working (but see note of caution later) but that the display of Maths by MathJax JavaScript is not.

Are you loading the MathJax libraries? The simplest way to set this up is to link to the MathJax CDN by adding the following to your Mahara's lib/web.php file

$javascript_array[] = 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML';

immediately before the line:

$javascript_array[] = $jsroot . 'keyboardNavigation.js';

If there is any issue access ing the MathaJax CDN (e.g. blocked by institutional firewall), then you can also download and deploy MathJax to your server, and link to that instead.

This has continued to work for me with recent Mahara versions (currently version 1.8.1), though with upgrades it is easy to forget to add the MathJax link to the new web.php.

Be aware that changes in security policies in recent Java versions may also cause issues with the use of DragMath. In the Moodle forums, there has been some interest in developing a new open source JavaScript alternative to DragMath for maths equations. May be something for the Mahara community to collaborate with.

https://moodle.org/mod/forum/discuss.php?d=251627#p1091002

Hope that helps

Geoff

Klaus Steitz's profile picture
Posts: 18

07 February 2014, 4:23

Hi Geoff,

thank you very much for your answer. I just read it today. Now i solved the problem. It was a strange combination of two error sources: external MathJax and case sensitiv link. That means that it is now working using a local copy of the MathJax-files and the spelling "mathjax" istead "MathJax" in the directory-link.

Hint for everyone: use the folowing link for testing the local mathjax

/js/mathjax/test/index.html

 

kind regards
Klaus

Geoff Rowland's profile picture
Posts: 108

09 February 2014, 6:41

You may also find it useful to display chemistry equations in Mahara by using the MathJax mhchem extension.

http://docs.mathjax.org/en/latest/tex.html#mhchem

To do this, immediately after:

$headers[] = '<script type="text/javascript">$j=jQuery;</script>';

in lib/web.php, add the following lines:

$headers[] = '<script>
MathJax.Hub.Config({
TeX: {
extensions: ["mhchem.js"]}
});
MathJax.Hub.Configured();
</script>';

Also, modify the MathJax link as follows (or equivalent for local install):

$javascript_array[] = 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&delayStartupUntil=configured';

You can then use the mhchem extension to TeX syntax to add chemistry reactions, equilibia, ions, formulae, isotopes etc to your Mahara pages.

Currently, no DragMath-like GUI for this, though the mhchem syntax is relatively straight-forward to add directly via the editor.

http://www.ce4csb.org/equations/mhchem.pdf

 

Geoff Rowland's profile picture
Posts: 108

25 February 2015, 1:31

The MathSlate for TinyMCE4 plugin works nicely with MathJax for adding equations to Mahara. It was authored by Daniel Thies, originally as a Moodle plugin, so has a good 'provenance'. Daniel has made significant developer contributions to TeX, MathJax and editor integrations in Moodle.

MathSlate uses JavaScript, so should work cross-platform. Provides a viable open source (GPLv3) alternative to the DragMath Java applet, given issues with Java applet security and that browser NSAPI support is 'on the wane'.

There is a demonstration site and code is available on GitHub.

To install on Mahara:

1. Add MathJax to lib/web.php as detailed in earlier postings to this thread.

2. Copy plugins/mathslate (downloaded and unpacked from GitHub) to js/tinymce/plugins/mathslate.

3. Add mathslate to the TinyMCE toolbar configuration in lib/web.php. For example, search for emoticons (2 instances) and add mathslate as below:

Around line 161 (I have tweaked my web.php elsewhere, so your line numbers may be slightly different)

'"fontselect | fontsizeselect | mathslate emoticons nonbreaking charmap ' . $spellchecker_toolbar . ' | table | removeformat pastetext | code"',

Around line 175  

plugins: "tooltoggle,textcolor,link,image,table,mathslate,emoticons{$spellchecker},paste,code,fullscreen,directionality,searchreplace,nonbreaking,charmap",

MathSlate is currently version 1.0rc1. So, has a few rough edges. However, in my hands, works well on Mahara 1.10 and should work (though not tested) on earlier versions using TinyMCE 4.

17 results