Math Filters

Math Filters

by d morte -
Number of replies: 17
I've posted previously, and have found some success, but still encountering some difficulties. Originally, I was successful in installing Dragmath, but couldn't view the images that were output.

After installing ASCIIMATH into /lib, and changing the meta.php in /theme/mytheme, I am now able to have the output of Dragmath as viewable, but only in Firefox - not in IE.

Furthermore, when I export in moodletex, the image does not display correctly in either browser. Some possibly pertinent information: I have access to the server (it is down the hall), but am not very familiar with how to set permissions (I'm not the IT guru). A step by step would be helpful. It is a Windows server. We are running Moodle 1.9.7

I have several questions:

1. How do I go about getting the base tex filter to work properly? (Thus, not needing asciimath or latex)

2. How can I correct for the improper display in IE without requiring Mathplayer to be installed on every client machine? Will this be corrected with the base tex filter?

3. What filters/files/other should I be downloading and installing on the server to accomplish this task?

Any help would be appreciated. Thank you!
Average of ratings: -
In reply to d morte

Re: Math Filters

by Marc Grober -
First off, it's always handy to read the manual ;)
Dragmath moodletex output outputs for the moodle tex filter and asciimath output for asciimath. Since you indicate you don't have Tex filter on, Tex expressions in moodle Tex delimiters won't work.

IE does not follow w3c standards via mathml, do it does not display mathml without plugin, but asciimath has fallback that addresses this which you need to configure. There are now more options than ever for fallback, including the google chart API .

If you want to get moodle Tex filter running you can. You can also install jsMath or mathjax. But there is no reason what you are doing now won't satisfy your needs with a bit of configuration.

BTW, you can also output from dragmath with latex tokens for asciimath, which will insert Tex text expressions, but with the correct number of dollar signs for asciimath
In reply to Marc Grober

Re: Math Filters

by d morte -
Marc,
Thank you for responding. smile It is helpful to have someone to bounce ideas off of, and to talk it through.

I've read the documentation on Dragmath, Tex Notation Filter, filters, and asciimath.
Unfortunately, I'm still missing some key piece of information to get it all working smoothly.

1. I do have the Tex filter on, at least in the sense that I have the eyeball open in the Site Administration > Filters (see attached pic)... Other than this, I don't know how to get the moodle Tex filter running.

2. Fallback: I tried installing the replacement file, but received a giant red banner at the top of IE, and no joy.

3. I'm at a loss as to where to go from here.

Again, thank you!
In reply to d morte

Re: Math Filters

by Marc Grober -
OK, let's see what we can do...

First off, re fallback, please provide details of what you actually did so that I can determine what file you are using (or you can send me a message with your URL and I can poke at it) Fallback relies on a variable setting in asciimathml.js that is described in the docs. Frankly I don't recall what it is set to by default, but the first thing would be to double check and make sure that the fallback is indeed working. Once fallback is up and running you should be able to manage without the banner and without the plugin and without tex.

As far as tex is concerned you need to look at the docs: http://docs.moodle.org/en/TeX_filter#Debugging_TeX_filter Your problem will be compounded by the fact that you are using WIndows as a server (I am allergic, don't you know) though Mauno runs a windows server and has played with the windows perms. But first thing is to run the texdebug and report the results. if the binaries are not there then you probably want to install texLive. If they are there but there are perm options then you need to set thenm correctly, and I think there is info on that in the forums (which should likely get included in the tex filter docs if it is not already....)

Now, you need not use tex and asciimath. Asciimath provides quite a few extra benefits over the moodle tex filter for many uers, especially if you are not pushing the limits of what tex can otherwise do, including asciisvg, calculators, chatmath, etc and it is extensible and works without a server. Asciimathml also provides a simpler syntax, which is why Peter says he started fiddling with it in the first place

As I mentioned, you can set dragmath to do single or double dollars and asciimathml will do latex based upon its inclusion in v2 (the version posted) of much of latexmathml.

Frankly, I would resolve the asciimathml fallback issues first and see if that satisfies you, and if so, turn off tex filter so that does not slow down display of pages, and if you are happy, set dragmath to a default output that you want.
In reply to d morte

Re: Math Filters

by Mauno Korpelainen -

In addition to those things that Marc mentioned:

1) If you use IIS you need to check (in IIS manager) that IUSER (IIS_USER) has permission to execute file filter/tex/mimetex.exe and write to moodledata - Sunil had some problems with IIS7 in http://moodle.org/mod/forum/discuss.php?d=141710
If you use Apache (XAMPP) try in Resource manager mouse right click over mimetex.exe - Properties and add from Security tab Full permissions for users of that file...

2) There are many versions of fallback files available and most of them have needed settings at the beginning of file itself - you can edit ASCIIMathML.js with some text editor. If you want to try a file that has some working fallback already functional try to download for example http://korpelainen.net/plugindemo/lib/editor/common/AM.js (that is using Mathtex fallback) or http://korpelainen.net/gmoodle/lib/editor/common/AMgoogle.js  (that is using Google Chart API tex fallback) and rename the downloaded file to your ASCIIMathML.js

3) You can disable Algebra filter wink

PS. Installing some full distribution of Latex - for example Tex Live or MikTex together with GhostScript or ImageMagick may work with correct Windows installer files as soon as you find the correct paths (no "..." around windows paths) for latex, dvips and convert in administration of tex filter but sometimes you need to change environment variables (PATH) etc but basicly you should find info about installing those programs that are not part of moodle from the actual download sites of Tex Live etc.

In reply to Mauno Korpelainen

Re: Math Filters

by Marc Grober -
I did double check the fallback file I posted and referenced in the docs as well as the docs at http://docs.moodle.org/en/ASCIIMathML The file posted should provide the fallback features you need if properly configured. In order to avoid impacting anyone's server, the line for fallback was not pointed at a production mimetex binary and looks like this:
var AMTcgiloc = "http://www.mymimetexserver.com/cgi-bin/mimetex.cgi";
//path to CGI script that can render a TeX string

You need to put the url of the fallback script you want to use in place of the ersatz one provided. If mimetex is in fact present on your system and working things will be fine.

In some systems we can simply check to see if mimetex is working by doing something like this:

http://fqdn/pathtomimetex/mimetex.cgi?x^2

which would result in a web page with $$x^2$$ in the upper left corner. However, I am fairly certain that will not work in your situation, so the best test is to simply view a text expression in IE or Chrome and see if its rendered as an image. You can read some more about mimetex here http://www.forkosh.com/mimetexmanual.html and here http://docs.moodle.org/en/TeX_notation_filter

Mauno has done quite a bit of work on the files he mentions and the file referencing the google chart api is very nice as it eliminate the need to work about a local fallback renderer.

Mauno, are you going to consider either of the scripts "releasable" such that we can offer them on Moodle so as to avoid confusion if you do further edits? You had written about packaging things up and documenting but I am not sure what the status of that is. Since the version of the fallback I posted is now a bit dated and still relies on a sourceforge download, I do think it would be nice to include your full package on Moodle, at which point we could update the docs to address the changes you've made.

 
In reply to Marc Grober

Re: Math Filters

by Mauno Korpelainen -

Marc,

I have not changed my files since December just for one reason - moodle 2.0.

When Petr started to implement those latest theme changes many things in moodle 2.0 changed too (role of YUI3, the whole use of javascripts as a part of totally new theme system etc) and I wanted to avoid doing the same things over and over again. Editor plugins of TinyMCE will also use new code in moodle 2.0 & new code of jsxGraph / GeoNext, role of Microsoft in SVG group (IE9) may be interesting and so on.

About 100 moodle sites have downloaded and tested the plugins documented in http://korpelainen.net/mediawiki/index.php/Main_Page and I just checked yesterday my mathtex.cgi log file that was still reasonable small meaning that most sites that have tested the plugins have been able to set up own fallback renderer or use either Google Chart API tex or MathTran - or use some other math renderer like for example Wiris. Only about 5 sites are continuously using my site mathtex.cgi (which is of course mainly meant for testing, not for a long time use)

So I have not frozen my testing - January and February have been rather busy at my daily work (teaching) and I have mostly tried to relax and follow the coming features of moodle 2.0.  wink

According to Roadmap we will see in

March 2010: Moodle 2.0 Beta release
April, May, June 2010: intensive beta testing and bug fixing (freeze on new features)
1 July 2010: Moodle 2.0 production release

and on schedule I could create an up-to-date "math package" with all current features during this beta testing period both for moodle 2.0 and pre 2.0 releases.

In reply to Mauno Korpelainen

Re: Math Filters

by d morte -
Well, it has been a little over a week, but progress is being made. My tech department has been graciously giving me much of their time to help figure out this problem.

1. We have confirmed that none of the three binaries were installed. We have intentions on downloading and installing:

http://www.miktex.org/2.8/setup -This is the windows version of LaTeX

http://ghostscript.com/releases/gs871w32.exe - windows version of ghostscript



2. We have set the file permissions, and the IUSER can now access both the filter/tex/ directory, as well as /moodledata/


3. We turned on the debugging, and are receiving the following error:


Warning: system() [function.system]: Unable to fork [C:\moodle/filter/tex/mimetex.exe ++ -e "C:\moodledata/filter/tex/d1e56126337cd6e29b16fe759232ce90.gif" -- "\Large f(x)=\\Bigint_{-\\infty}^x~e^{-t^2}dt"] in C:\moodle\filter\tex\texdebug.php on line 139

Warning: shell_exec() [function.shell-exec]: Unable to execute 'C:\moodle/filter/tex/mimetex.exe ++ -e "C:\moodledata/filter/tex/d1e56126337cd6e29b16fe759232ce90.gif" -- "\Large f(x)=\\Bigint_{-\\infty}^x~e^{-t^2}dt" 2>&1' in C:\moodle\filter\tex\texdebug.php on line 150

The shell command
C:\moodle/filter/tex/mimetex.exe ++ -e "C:\moodledata/filter/tex/d1e56126337cd6e29b16fe759232ce90.gif" -- "\Large f(x)=\\Bigint_{-\\infty}^x~e^{-t^2}dt"
returned status = -1
File size of mimetex executable C:\moodle/filter/tex/mimetex.exe is 943027
The file permissions are: 100777
The md5 checksum of the file is 8bb2d0687c94dcecee38fc241db5f565
Image not found!

No text output available

In reply to d morte

Re: Math Filters

by d morte -
Quick question: Does mimetex work straight out of the box assuming that I turn it on in the administration panel?

I'm wondering if we did a fresh install of Moodle 1.9.7 if this should work?
In reply to d morte

Re: Math Filters

by Marc Grober -
Did you determine if mimetex will run from command line?
You get mimetex from forkosh for that matter, I'd spend a lttle time figuring out what the mimetex issue is and confirming that the are images being written to moodledata/filter/tex
You could also install on a real OS ....
In reply to Marc Grober

Re: Math Filters

by d morte -
Marc,
We did run mimetex from the command line - it gave us a nice little x^2 image in the command line. How to compile an image from there is a different story. We can't get anything to output to file.

With MikTex and GS 8.7.1 installed, we are still getting the following errors:


Warning: exec() [function.exec]: Unable to fork ["c:\moodle\MikTex\miktex\bin\latex.exe" --interaction=nonstopmode C:\moodledata/temp/latex/d1e56126337cd6e29b16fe759232ce90.tex] in C:\moodle\filter\tex\texdebug.php on line 254

Warning: exec() [function.exec]: Unable to fork ["c:\moodle\MiKTeX\miktex\bin\dvips.exe" -E C:\moodledata/temp/latex/d1e56126337cd6e29b16fe759232ce90.dvi -o C:\moodledata/temp/latex/d1e56126337cd6e29b16fe759232ce90.ps] in C:\moodle\filter\tex\texdebug.php on line 254

Warning: exec() [function.exec]: Unable to fork ["c:\moodle\gs\gs8.71\bin\gswin32.exe" -density 240 -trim C:\moodledata/temp/latex/d1e56126337cd6e29b16fe759232ce90.ps C:\moodledata/temp/latex/d1e56126337cd6e29b16fe759232ce90.gif ] in C:\moodle\filter\tex\texdebug.php on line 254

Checking executables

Error: latex executable ("c:\moodle\MikTex\miktex\bin\latex.exe") is not readable
Error: dvips executable ("c:\moodle\MiKTeX\miktex\bin\dvips.exe") is not readable
Error: convert executable ("c:\moodle\gs\gs8.71\bin\gswin32.exe") is not readable

base filename for expression is 'd1e56126337cd6e29b16fe759232ce90'

Processing TeX expression:

f(x)=\Bigint_{-\infty}^x~e^{-t^2}dt
$ "c:\moodle\MikTex\miktex\bin\latex.exe" --interaction=nonstopmode C:\moodledata/temp/latex/d1e56126337cd6e29b16fe759232ce90.tex
OUTPUT:
RETURN CODE: -1
$ "c:\moodle\MiKTeX\miktex\bin\dvips.exe" -E C:\moodledata/temp/latex/d1e56126337cd6e29b16fe759232ce90.dvi -o C:\moodledata/temp/latex/d1e56126337cd6e29b16fe759232ce90.ps
OUTPUT:
RETURN CODE: -1
$ "c:\moodle\gs\gs8.71\bin\gswin32.exe" -density 240 -trim C:\moodledata/temp/latex/d1e56126337cd6e29b16fe759232ce90.ps C:\moodledata/temp/latex/d1e56126337cd6e29b16fe759232ce90.gif
OUTPUT:
RETURN CODE: -1

In reply to d morte

Re: Math Filters

by d morte -
My IT department is mentally gearing up for an Ubuntu install in three weeks, we were just hoping to get this working for some trainings over the next two weeks.
In reply to d morte

Re: Math Filters

by Mauno Korpelainen -

If you want to install Imagemagick instead of GhostScript the Windows installer files can be found from http://www.imagemagick.org/script/binary-releases.php#windows

In your previous post (image)

Image

you had double quote marks in paths. Check if path of latex binary should be written without double quote marks

C:\moodle\MikTex\miktex\bin\latex.exe

and path of dvips binary sould probably be

C:\moodle\MiKTeX\miktex\bin\dvips.exe

The same way path of convert binary might be C:\path_to_your_ImageMagick\convert.exe or in your case C:\moodle\gs\gs8.71\bin\gswin32.exe for GhostScript convert binary file. And those files should be executable by IUSER.

In reply to Mauno Korpelainen

Re: Math Filters

by d morte -
Mauno,
Good catch with the "double quotes "... I just made the change and now the debug error reads differently. Those binaries are now readable! Still no image, but I think this is progress.


Warning: exec() [function.exec]: Unable to fork [c:\moodle\MikTex\miktex\bin\latex.exe --interaction=nonstopmode C:\moodledata/temp/latex/d1e56126337cd6e29b16fe759232ce90.tex] in C:\moodle\filter\tex\texdebug.php on line 254

Warning: exec() [function.exec]: Unable to fork [c:\moodle\MiKTeX\miktex\bin\dvips.exe -E C:\moodledata/temp/latex/d1e56126337cd6e29b16fe759232ce90.dvi -o C:\moodledata/temp/latex/d1e56126337cd6e29b16fe759232ce90.ps] in C:\moodle\filter\tex\texdebug.php on line 254

Warning: exec() [function.exec]: Unable to fork [c:\moodle\gs\gs8.71\bin\gswin32.exe -density 240 -trim C:\moodledata/temp/latex/d1e56126337cd6e29b16fe759232ce90.ps C:\moodledata/temp/latex/d1e56126337cd6e29b16fe759232ce90.gif ] in C:\moodle\filter\tex\texdebug.php on line 254

Checking executables

latex executable (c:\moodle\MikTex\miktex\bin\latex.exe) is readable
dvips executable (c:\moodle\MiKTeX\miktex\bin\dvips.exe) is readable
convert executable (c:\moodle\gs\gs8.71\bin\gswin32.exe) is readable

base filename for expression is 'd1e56126337cd6e29b16fe759232ce90'

Processing TeX expression:

f(x)=\Bigint_{-\infty}^x~e^{-t^2}dt
$ c:\moodle\MikTex\miktex\bin\latex.exe --interaction=nonstopmode C:\moodledata/temp/latex/d1e56126337cd6e29b16fe759232ce90.tex
OUTPUT:
RETURN CODE: -1
$ c:\moodle\MiKTeX\miktex\bin\dvips.exe -E C:\moodledata/temp/latex/d1e56126337cd6e29b16fe759232ce90.dvi -o C:\moodledata/temp/latex/d1e56126337cd6e29b16fe759232ce90.ps
OUTPUT:
RETURN CODE: -1
$ c:\moodle\gs\gs8.71\bin\gswin32.exe -density 240 -trim C:\moodledata/temp/latex/d1e56126337cd6e29b16fe759232ce90.ps C:\moodledata/temp/latex/d1e56126337cd6e29b16fe759232ce90.gif
OUTPUT:
RETURN CODE: -1
In reply to d morte

Re: Math Filters

by Mauno Korpelainen -

Previous debugging told that php commands system() and shell_exec() could not be used with mimetex and here exec() does not work so php.ini might some restrictions (for example disabled functions exec(), system() and shell_exec()... ) or some extra server security settings might prevent executing files...

In reply to Mauno Korpelainen

Re: Math Filters

by d morte -
The guy I was working with just left the building. I'll seek his input on this tomorrow. He understands it far better than I - for which I am very thankful - as I am of the time and energy spent by You and Marc.
In reply to d morte

Re: Math Filters

by Marc Grober -
I think you are close to resolving your issues, but if things start going sideways on you again you can always install asciimath and use an open mimetex fallback, the google chart api* or the mimetex.dll I just posted about. I am pretty sure that will take all of about 15 minutes ;=} Remember, your fallback did not work because of your mimetex issue... not because of the text expression inserted or because of asciimath

* Mauno has posted regarding two asciimathml files he has been working with in another thread in this forum at least oen of which falls back to google chart api I believe.