What to do with tex filter if your host does not allow executable scripts or custom plugins?

What to do with tex filter if your host does not allow executable scripts or custom plugins?

by Mauno Korpelainen -
Number of replies: 13

Many people have had difficulties with Tex filter. In most cases it is possible to give executable permissions to mimetex file in filter/tex/ but on shared hosts even this can be impossible.

If php has disabled functions or some security modules/settings do not allow executable permissions (mimetex) or if your shared host does not allow you to use local distribution of latex or you are not allowed to install extra filters or packages (for example mathtran filter or math plugins) moodle 2 has still one option left to render maths with cdn MathJax:

Step 1: As an administrator of your site go to Site administration > Appearance > Additional HTML > Within HEAD and add tags from attached file mathjaxcdn.txt and press Save changes button.

Your moodle 2 is now using MathJax from a cloud server in cdn.mathjax.org with given delimiters (in this example double dollars for inlineMaths and @d for displayMaths). You can choose to use other delimiters in configuration if you want.
Make sure that Tex filter and Algebra filter are disabled in Site administration > Plugins > Filters > Manage filters

Step 2: Since default configuration of tinymce (editor) requires that tex filter needs to be enabled before Dragmath plugin can be used you need to edit file lib/editor/tinymce/lib.php

Take a copy of that file first to make sure that you can revert changes. Find lines 107-111:

if (array_key_exists('filter/tex', $filters)) {
$xdragmath = 'dragmath,';
} else {
$xdragmath = '';
}

and replace them with

$xdragmath = 'dragmath,';

Save the file / replace the original file lib/editor/tinymce/lib.php with this modified file.
Now your editor has Dragmath plugin and cdn mathjax renders the maths that you add with Dragmath (within default delimiters = doubledollars)

Note: this example configuration is using

TeX-AMS_HTML

that is much lighter and faster than for example the more advanced  mathjax configuration "TeX-AMS-MML_HTMLorMML" used elsewhere (math plugins) - TeX-AMS_HTML does not use MathML, only latex with AMS.

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

Re: What to do with tex filter if your host does not allow executable scripts or custom plugins?

by Suneetha Prasad -

Mauno,

Thank you very much!

This approach is the best for those working with shared hosting related constraints. It resolved the challenge I was facing.

Regards,

Suneetha Prasad

In reply to Mauno Korpelainen

Απάντηση: What to do with tex filter if your host does not allow executable scripts or custom plugins?

by Vasilis Palilis -

I have the same problem on Moodle 2.4+.

The file lib/editor/tinymce/lib.php is different from whitch you reffer.

The piece of code

if (array_key_exists('filter/tex', $filters)) {
$xdragmath = 'dragmath,';
} else {
$xdragmath = '';
}

does not exist!

What can I do?

Best Regards

Vasilis

 

In reply to Vasilis Palilis

Re: Απάντηση: What to do with tex filter if your host does not allow executable scripts or custom plugins?

by Colin Fraser -
Picture of Documentation writers Picture of Testers

Vasilis, have a think about this document, and what it can do for you.  

In reply to Colin Fraser

Απάντηση: Re: Απάντηση: What to do with tex filter if your host does not allow executable scripts or custom plugins?

by Vasilis Palilis -

Hi Colin

I would like to test this project, om my local Moodle 2.2 running on Windows7. Is that possible?

Thank's

 

In reply to Vasilis Palilis

Re: Απάντηση: Re: Απάντηση: What to do with tex filter if your host does not allow executable scripts or custom plugins?

by Mauno Korpelainen -

You can TEST those files with local moodle 2.2 but don't use them with moodle 2.4 - like Jean-Michel said moodle 2.4 has a different way to use editor plugins and book module in core moodle 2.4 should not be overwritten by the "mathbook" version in mpluga.zip

And notice also that the files in math plugin package have not been upgraded since the 1st of April 2012...

In reply to Vasilis Palilis

Re: Απάντηση: What to do with tex filter if your host does not allow executable scripts or custom plugins?

by Jean-Michel Védrine -

Hello Vasilis,

Moodle 2.4 is completely different for TinYMCE plugins.

Now there is no need to edit any file to enable Dragmath even if the teX filter is not enabled.

Go to Site Administration -> Plugins -> Text editors -> TinyMCE HTML editor -> Insert equation

You will see a new setting : Require TeX filter (Default Yes)

With the help text: If enabled the Dragmath button is visible only when the TeX filter is enabled in the editor context. Disable if you have a custom TeX filter that is enabled in global scope.

As you can guess you need to uncheck it so that Dragmath is available even if the TeX filter is not enabled.

Require TeX filter

This new setting is diplayed during upgrade to 2.4 but unfortunately most users miss it or don't realize if they need to change it or not.

In reply to Jean-Michel Védrine

Απάντηση: Re: Απάντηση: What to do with tex filter if your host does not allow executable scripts or custom plugins?

by Vasilis Palilis -

Thanks Jean-Michel,

For the right rendering of the maths in my site http://learn-era.gr/moodle (It is under construction):

  1. The required TeX filter is not enabled
  2. The TeX notation filter is not enabled
  3. The tag of mathjaxcdn.txt is added to Appearance > Additional HTML > Within HEAD

Is That a good solution?

Thank's again!

 

In reply to Vasilis Palilis

Re: Απάντηση: Re: Απάντηση: What to do with tex filter if your host does not allow executable scripts or custom plugins?

by Jean-Michel Védrine -

Hello Vasilis,

This is exactly the settings I will use once I finish migrating my production server from 2.3 to  2.4. So definitely for me I would say this is a good solution.

It will be an even better solution when we will have versions of all Mauno's math plugins adapted for Moodle 2.4

Unfortunately I still have troubles with the geonext plugin and I don't understand why it's not working.

 

In reply to Jean-Michel Védrine

Re: Απάντηση: Re: Απάντηση: What to do with tex filter if your host does not allow executable scripts or custom plugins?

by Mauno Korpelainen -

Jean-Michel,

I started finally testing these moodle 2.4 plugins this morning (after reading your post) and it looks like geonext applet has some problems with batik & localisation.

I was able to create a functional geonext/jsxgraph plugin that is using external geonext codebase ( codebase='http://geonext.uni-bayreuth.de/data/download/' ) but not with a local geonext.jar

I could check/update the other plugins during the coming week (using 2.4 tinymce plugin coding) and ask some feedback next week. Most javascript files included with script tags in the old math plugin package have today newer versions and ideally we could use external/cloud scripts as default values and give administrators a setting for using local scripts if they wish.

In reply to Mauno Korpelainen

Re: Απάντηση: Re: Απάντηση: What to do with tex filter if your host does not allow executable scripts or custom plugins?

by Jean-Michel Védrine -

Hello Mauno,

Glad you are working on some 2.4 math plugins.

If you think it would be useful I can send you what I have done. The asciisvg one seems to work fine, but as I said the geonext one has problems. I would be happy if I can save you some work.

I also did a version of the ASCIIMath Plugin for TinyMCE editor made by David Lippman because this is the one I use. I don't use the one included in your files because I am accustomed to David's one so I never changed. But if you want to have a look at it, I can send it too.

I have not done Googlecharts or Googletex plugins as I don't use them (maybe I should ? Never had time to look at them seriously sad)

The great benefit of Moodle 2.4 for math plugins is that you will not have to do a new release of the tinymath editor each time TinyMCE is upgraded in moodle !!

Also it is possible to customize the editor's toolbar a lot more easily.

If you need some help, I can spend some time on math plugins in January 2013 because new courses only start after january 15th smile

In reply to Jean-Michel Védrine

Re: Απάντηση: Re: Απάντηση: What to do with tex filter if your host does not allow executable scripts or custom plugins?

by Mauno Korpelainen -

If you could send your moodle 2.4 plugin versions as a zip package to mauno.korpelainen@hyvinkaa.fi or mauno.korpelainen@hotmail.fi it would be very helpful.

I added some tiny changes to asciisvg script last summer for mobiles that can render svg but were not allowed to render it and for example latest version of FMath plugin can now import formulas from Microsoft Word (files saved as docx).

Both Google Chart Wizard and "Google Tex" as a part of Image charts are officially deprecated as of April 20, 2012 - see https://developers.google.com/chart/image/ and https://google-developers.appspot.com/chart/infographics/docs/formulas - and even if they are "cool" it may be better to forget those tools.

Our courses continue on 7th of January so we have now plenty of time to get this done smile

In reply to Mauno Korpelainen

Re: Απάντηση: Re: Απάντηση: What to do with tex filter if your host does not allow executable scripts or custom plugins?

by Marc Grober -

Thanks you, Mauno and Jean-Michel,

I think math plugins with Moodle 2.4 needs a new thread, and the docs for Math Tools need some tweaking so that the changes in 2.4 are clear (the use of different docs for different Moodle versions is nice on the one hand,  but problematic when docs for older versions are brought forward and are inaccurate or misleading....  which presents a real issue for anyone contributing to the docs as we have seen numerous times over the last few months with regard to DragMath, plugins etc.

It is somewhat exciting that Moodle is getting closer and closer to providing universal and transparent support for Math!

In reply to Vasilis Palilis

Re: Απάντηση: Re: Απάντηση: What to do with tex filter if your host does not allow executable scripts or custom plugins?

by Marc Grober -

Not sure what you are referencing vis-a-vis the txt file,   but please note that you may have to update your mathjax reference depending on how old your reference is, and that you should tweak your default config and your tokens depending on what suits you the best....