What I would like to do is setup something similar for the imported questions in moodle . I have parsed out the mathml, but would like to render this as an image server side to avoid having to require the users to setup their browsers to properly render mathml.
Can anybody inform me on how to go about doing this? I am not opposed to converting to TeX first (or some other format) if necessary.
If it is even more simple than this and I have just missed some moodle setting please educate me
regards,
Jeff
http://cvs.sourceforge.net/viewcvs.py/moodle/contrib/mathml/
It worked quite well, once I got it working - I used it to render Jacques Distler's theoretical physics blog at http://golem.ph.utexas.edu/~distler/blog/, some of whose pages contain heavy-duty MathML.
The only trouble with it is that the MathML->TeX part uses XSL transformations using the Xalan XSLT processor. Unfortunately Xalan is Linux only and even on Linux quite a challenge to install, since it has some nonstandard dependencies. In particular it depends on a library which is part of Intel's C-compiler suite. It took me quite some time to figure out to identify that library and then to find the place I could download it off Intel's site. [It is available for free download, with some strings attached, but you have to jump through a few hoops to get the download.]
I haven't played around with it for more than a year, so perhaps the situation with respect to Xalan has changed in the meantime.
Thanks for the response. I've been taking a look at the xerces/xalan options. It looks like java versions are available for both xerces and xalan that can be called from CLI, or an applet. Have you had any success or tried to get this working? If we were able to get this working I imagine they could be included along with the Moodle distribution so that the administrator would only need to turn the mathml filter on. That would be pretty cool
Regardless I'm in the painful process of compiling xerces/xalan. I'm assuming this is the method you have used previously?
The documentation is rather poor and it appears you can't do the usual ./configure && make && make install
I would suggest that your quiz conversion script just convert all the mathml markup in the Blackboard quiz into corresponding LaTeX markup in the converted Moodle quiz. Then the Moodle quiz could just be displayed using the Moodle TeX filter. Thus you would just be using the mathml->tex conversion code in the mathml filter rather than the mathml filter itself.
I think this is better than requiring that Moodle installations activate yet another filter. For one thing, it would be more efficient. The mathml->tex conversion (which is kind of slow) would be done just once, during the conversion process rather than repeatedly every time a student took a quiz.
Also running an extra filter, even if it doesn't do anything to most pages, slows down a Moodle server. Finally having the mathml filter active would create more support issues both locally and here on moodle.org, since people would try to use it for other things besides imported Blackboard quizzes and run into trouble with it. The most serious issue is that mathml is incompatible with the HTML editor (at least the last time I checked - Janne, correct me if I'm wrong). Also when I set up a public demo of the mathml filter on my site, I found that a lot of people were pasting in badly malformed mathml (apparently generated by some kind of Windows software) and then complaining that it would not display in the filter.
Zig
Zig,
Thanks again for the response. I agree with you about filtering and storing as TeX makes much more sense. I've jumped over to a PC so I can try the binary distribution. I have it up and running, however I am getting the following upon trying to filter a string containing matml.
Xalan error: Fatal Error.Occurred at unknown file , line 1 , column 1. Invalid document structure SAXParseException: Invalid document structure (, line 1, column 1)
The mathml that was sent to xalan appears to be formatted correctlly for each opening tag there is a closing one. Attached is one of the offending mathml strings. Any ideas as to what is going on?
$mathml = str_replace("ⅆ","ⅆ",$mathml);
Thanks!
I suspected that may be the culprit and that I would have to add a special handler as you mentioned. Is this just mapping the mathml to the unicode equivalent?
I will try this out tomorrow.
Jeff
Zbigniew,
Thanks again for all of your help. I updated the filter file as suggested and I am still recieving the same error. If you don't mind could you look at the attached mathml that it choked on? It was all on one line, but I indented it for readability. The &DifferenialD; was translated fine. Do you think the empty tags maybe causing this problem? ie. the mi tag
Any ideas appreciated.
https://webwork2.math.ohio-state.edu/xalan/index.php
you will get a correct TeX translation.
I am attaching the source of the file xalan/index.php that I am using to do the translation.
#include <stdio.h>
int main(int argc, char *argv[]) {
fputs(argv[1],stdout);
}
Hi Zbigniew,
Thanks for all your time.
I tried compiling the source and also using your executable. Same error.
I tried calling xalan from the command line to see if I could get anymore information. I get the following extra information "The filename or extension is too long." The cmd session is attached.
any ideas?
You've been a great help. comparing your example and my broken one I found that something is clobbering the escaped quotes in the opening <math> tag they get replaced with what appears to be a space.
If I replace those and run it from the command line it works fine, but I can't figure out how to get those to not be clobbered. I commented out the escapeshellargs() call to make sure that it wasn't the culprit. I also looked for any obvious " or similar tags in the replace_str lines. I didn't see anything obivious, and all I tried failed.
Once I get this fixed I think we are there!
Your help has been greatly appreciated.
- Instead of \", pass some other distinctive string to your echo.exe and have echo.exe replace this by ".
- Instead of passing the mathml into stdin, write it to a file and pass the file as an argument to xalan.
My mistake it actually was the escapeshellargs() clobbering the quotes. I just commented that line and escaped it manually with a couple replace_str's. It's working now!
Thanks for all the help and ideas.
https://webwork.math.ohio-state.edu/xalan/index.php
Upload an html file containing MathML. The output will be an html file with TeX expressions enclosed by double $. These in turn can be converted to images using the Moodle TeX filter.
we have a Formula editor based on MathML that might be usefull for you. It is called WIRIS Editor and you can find a Plugin to integrated into Moodle at http://moodle.org/mod/data/view.php?d=13&rid=927 .
Changes in MathML
For tehcnical reasons the tag symbols '<' and '>' in our mnathml code have been changed for '«' and '»'.
For example, the mathml code for 2+3 that is
<math><mrow><mn>2</mn><mo>+</mo><mn>3</mn></mrow></math>
but be stored as
«math»«mrow»«mn»2«/mn»«mo»+«/mo»«mn»3«/mn»«/mrow»«/math»
Our editor has not been designed to import MathML created from tools, it may not work for all your formulas.