problems with rendering mathml

problems with rendering mathml

by Eugene Vandyshev -
Number of replies: 16

Hello, could you please help me with the following issue:

When im adding math equation with MathML export using DragMath, code is not rendered, i just have the pure code after saving and viewing a course.

 

I tried creating an equation exporting it to Latex and it works fine, so it seems like im missing a plugin or maybe something is wrong with setups (speaking about MathML).

Im using MAC OS X 10.6, lastest Opera (also tried on latest chrome, firefox and safari).

Could you please tell me what do i need to install and if possible a detailed tutorial is would be really welcome.

any advice is welcome.

Average of ratings: -
In reply to Eugene Vandyshev

Re: problems with rendering mathml

by Marc Grober -

My apologies, but what seem obvious to you may not seem so obvious to me wink

You indicate that you are using DragMath to place Mathml in Moodle resources. This would mean that your mathml is notinserted in the markup of the web resource, but on top of it, if you will. You then indicate that the code is not interpreted. Why do you think the code should be interpreted?  That is to say,  on what basis do you believe that MathML inserted via the editor (like so)

<math xmlns="http://www.w3.org/1998/Math/MathML"> a n ⋅ a m = a n + m

is interpreted by Moodle? Now, if proper MathML is made available to compliant browsers, those browsers can parse and display MathML, but that is not what you are doing....

To put it another way, if you wish to use DragMath then why are you converting to MathML, as opposed to exporting in ASCIIMathML format, or using the Moodle Latex format and then using MathJax?

I am at a bit of a loss as to what you are in fact trying to acomplish, in as much as you indicated that at least the obvious goal (having marth expressions displayed) is acomplsihed, aparently by way of inserting tex expressions with the core Tex filter or some surrogate in place.

So,  perhaps if you could explain what your secondary goals ar it would be clearer,  though if your secondary goal is to rovide a variety of ways to view the expressions,  than I would have to say that MathJax,  though not a complete Tek implementatin,  does an extraordinary job,  while ASCIIMathML is wonderfully easy tool to use as well.

 

 

In reply to Marc Grober

Re: problems with rendering mathml

by Eugene Vandyshev -

Well, i thought that exporting to MathML should work the same as to TeX. Like im composing an equation, then press insert and after saving i can see the equation as it is and not in TeX markup.

Yes, as you say i thought that there should have been an extra plugin that would interpret MathML im moodle, because when it comes to viewing MathML examples on different sites, formulas are interpreted.

Im exprerimenting with MathML because i was said to do that at university to prepare a math course using MathML.

So, what should i do? how then i should insert mathml code inside the whole html and not on top of it?

In reply to Eugene Vandyshev

Re: problems with rendering mathml

by Mauno Korpelainen -

If yo need to use pure MathML the best option is to create separate files for those examples. Turn editing on and select from "Add a resource..." drop down list option "Link to a file or web site".

Links

Now you have an option to add links to any external or internal files using all kinds of doc types, scripts etc. If you want to keep your MathML files inside moodledata upload your files to course files and Choose & Save and display your examples - test for example attached xml file.

In forum posts and other resourses attachments are not automatically opened by a browser that understands MathML (=Firefox) and what your students usually do not know is that only Mozilla browsers have native support for MathML - all the other browsers need some plugin like MathPlayer separately installed - and therefore it may be more user friendly to use scripts like MathJax that give image fallback for such browsers that do not render MathML. Or to use Latex.

In reply to Mauno Korpelainen

Re: problems with rendering mathml

by Eugene Vandyshev -

is there any way to display the file without clicking on a link to display it?

i mean, i want formulas to appear in the text and don't bother with extra clicking.

thanks for understanding

In reply to Eugene Vandyshev

Re: problems with rendering mathml

by Eugene Vandyshev -

 

could you please give me a tutorial of how to isntall mathJax.

what i did so far was: i downloaded a mathjax archive, unzipped it to lib folder, then i added script to general.php on my current theme, but still mathml is not rendered.

In reply to Eugene Vandyshev

Re: problems with rendering mathml

by Mauno Korpelainen -

So it's moodle 2 - usually the problem is in configuration of MathJax.

Try to add the tags attached to example.txt to you theme genaral.php (are there other layout files used too?

And test in some topic of your course the following examples copied from MathJax site source (press in editor HTML button before adding them or disable editor from your user profile first):

<p>@i \alpha @i is inline maths</p>
<div class="math-header">The Quadratic Formula</div>
<p><math display="block"><mrow><mi>x</mi><mo>=</mo><mfrac><mrow><mo>−</mo><mi>b</mi><mo>±</mo><msqrt><mrow><msup><mi>b</mi><mn>2</mn></msup><mo>−</mo><mn>4</mn><mi>a</mi><mi>c</mi></mrow></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac></mrow></math></p>
<div class="math-header">Cauchy's Integral Formula</div>
<p><math display="block"><mrow><mi>f</mi><mrow><mo>(</mo><mi>a</mi><mo>)</mo></mrow><mo>=</mo><msub><mo>∮</mo><mrow><mi>γ</mi></mrow></msub><mfrac><mrow><mi>f</mi><mo>(</mo><mi>z</mi><mo>)</mo></mrow><mrow><mi>z</mi><mo>−</mo><mi>a</mi></mrow></mfrac><mi>d</mi><mi>z</mi></mrow></math></p>
<div class="math-header">Double angle formula for Cosines</div>
<p><math display="block"><mrow><mi>cos</mi><mo>⁡</mo><mrow><mo>(</mo><mi>θ</mi><mo>+</mo><mi>φ</mi><mo>)</mo></mrow><mo>=</mo><mi>cos</mi><mo>⁡</mo><mrow><mo>(</mo><mi>θ</mi><mo>)</mo></mrow><mi>cos</mi><mo>⁡</mo><mrow><mo>(</mo><mi>φ</mi><mo>)</mo></mrow><mo>−</mo><mi>sin</mi><mo>⁡</mo><mrow><mo>(</mo><mi>θ</mi><mo>)</mo></mrow><mi>sin</mi><mo>⁡</mo><mrow><mo>(</mo><mi>φ</mi><mo>)</mo></mrow></mrow></math></p>
<div class="math-header">Gauss' Divergence Theorem</div>
<p><math display="block"><mrow><mrow><msub><mo>∫</mo><mrow><mi>D</mi></mrow></msub><mrow><mo>(</mo><mo>∇⋅</mo><mi>F</mi><mo>)</mo></mrow><mi>d</mi><mrow><mi>V</mi></mrow></mrow><mo>=</mo><mrow><msub><mo>∫</mo><mrow><mo>∂</mo><mi>D</mi></mrow></msub><mrow><mtext> </mtext><mi>F</mi><mo>⋅</mo><mi>n</mi></mrow><mi>d</mi><mi>S</mi></mrow></mrow></math></p>
<div class="math-header">Curl of a Vector Field</div>
<p><math display="block"><mrow><mover accent="true"><mrow><mo>∇</mo></mrow><mrow><mo>→</mo></mrow></mover><mo>×</mo><mover accent="true"><mrow><mi>F</mi></mrow><mrow><mo>→</mo></mrow></mover><mo>=</mo><mrow><mo>(</mo><mfrac><mrow><mo>∂</mo><msub><mrow><mi>F</mi></mrow><mrow><mi>z</mi></mrow></msub></mrow><mrow><mo>∂</mo><mi>y</mi></mrow></mfrac><mo>−</mo><mfrac><mrow><mo>∂</mo><msub><mrow><mi>F</mi></mrow><mrow><mi>y</mi></mrow></msub></mrow><mrow><mo>∂</mo><mi>z</mi></mrow></mfrac><mo>)</mo></mrow><mstyle mathvariant="bold" mathsize="normal"><mrow><mi>i</mi></mrow></mstyle><mo>+</mo><mrow><mo>(</mo><mfrac><mrow><mo>∂</mo><msub><mrow><mi>F</mi></mrow><mrow><mi>x</mi></mrow></msub></mrow><mrow><mo>∂</mo><mi>z</mi></mrow></mfrac><mo>−</mo><mfrac><mrow><mo>∂</mo><msub><mrow><mi>F</mi></mrow><mrow><mi>z</mi></mrow></msub></mrow><mrow><mo>∂</mo><mi>x</mi></mrow></mfrac><mo>)</mo></mrow><mstyle mathvariant="bold" mathsize="normal"><mrow><mi>j</mi></mrow></mstyle><mo>+</mo><mrow><mo>(</mo><mfrac><mrow><mo>∂</mo><msub><mrow><mi>F</mi></mrow><mrow><mi>y</mi></mrow></msub></mrow><mrow><mo>∂</mo><mi>x</mi></mrow></mfrac><mo>−</mo><mfrac><mrow><mo>∂</mo><msub><mrow><mi>F</mi></mrow><mrow><mi>x</mi></mrow></msub></mrow><mrow><mo>∂</mo><mi>y</mi></mrow></mfrac><mo>)</mo></mrow><mstyle mathvariant="bold" mathsize="normal"><mrow><mi>k</mi></mrow></mstyle></mrow></math></p>
<div class="math-header">Standard Deviation</div>
<p><math display="block"><mrow><mi>σ</mi><mo>=</mo><msqrt><mrow><mfrac><mrow><mn>1</mn></mrow><mrow><mi>N</mi></mrow></mfrac><mstyle displaystyle="true"><mrow><munderover><mrow><mo>∑</mo></mrow><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mrow><mi>N</mi></mrow></munderover><mrow><msup><mrow><mo stretchy="false">(</mo><msub><mrow><mi>x</mi></mrow><mrow><mi>i</mi></mrow></msub><mo>−</mo><mi>μ</mi><mo stretchy="false">)</mo></mrow><mrow><mn>2</mn></mrow></msup></mrow></mrow></mstyle></mrow></msqrt><mo>.</mo></mrow></math></p>

Works as MathML in FF and as Tex with other browsers.

In reply to Mauno Korpelainen

Re: problems with rendering mathml

by Mauno Korpelainen -

Forgot the example.txt file ... here

In reply to Mauno Korpelainen

Re: problems with rendering mathml

by Mauno Korpelainen -

And using this same configuration you can add both displaymath/inlinemath Latex tags and MathML tags. You can also use normal

<math xmlns="http://www.w3.org/1998/Math/MathML">

The examples from my previous post look like this in a topic section with MathJax

Example 2

Attached file Example2.txt has the previous xml file example without <html>,<head> and <body> tags that moodle strips anyway from the content.

In reply to Mauno Korpelainen

Re: problems with rendering mathml

by Mauno Korpelainen -

The main benefit of using mathJax is that it is 99.99% cross browser compatible and does not require any extra plugins for non-mozilla browsers.

On the other hand MathJax is javascript so browsers need to have javascript enabled - and 99.99% of current browsers have javascript enabled smile

In reply to Mauno Korpelainen

Re: problems with rendering mathml

by Mauno Korpelainen -

I just tested mathml with MathJax in a forum post and it looks like rendering of pasted MathML tags do not work in such activities that students can use (forums etc) - so the option there is to use latex within delimiters.

In reply to Mauno Korpelainen

Re: problems with rendering mathml

by Eugene Vandyshev -

neither mathml nor latex rendered.

im kinda 99.99% sure that i am doing something wrong, thats why it's not working.

I think the best way of using mathml is just publishing using a file, that worked pretty fine, i just created some content in amaya, saved it in .xml and added as a file in a course.

If its not hard, could you please write a step by step tutrorial on implementing mathjax from the start, eg if i had just downloaded moodle, maybe that will help me to make it work.

thanks in advance.

In reply to Eugene Vandyshev

Re: problems with rendering mathml

by Mauno Korpelainen -

We discussed some issues before in http://moodle.org/mod/forum/discuss.php?d=155977

The first thing to check is that is your test site using Eaccelarator or some php cache - if your php.ini has a line

eaccelerator.enable = "1"

no changes to your php files (like general.php) will take effect.

The next thing to check is the path of your MathJax.js - in example.txt configuration I used

<?php echo $CFG->httpswwwroot ?>/lib/MathJax/MathJax.js

which supposes to find a file MathJax.js from your moodle install subfolder /lib/MathJax

Check next that configuration of MathJax is not broken - moodle.org forums change double square parentheses to links to Wiki pages (double parentheses vanish from posts) and code in those previous configuration examples was not always correct - check the attached txt file example code (array double parentheses around delimiters).

Next you could check the place where you have added the script tags with configuration - they can be added to all themes (to header tags) as Tim informed here or to each layout file of your custom theme before </head> tag. It is also possible that some other (java)script is breaking your MathJax configuration or source (check error console in Firefox)

Finally check the source - do you see the script tags there?

If script tags are seen in source try a simple example:

@i \alpha @i for inline maths
@d \beta @d for display maths

In reply to Mauno Korpelainen

Re: problems with rendering mathml

by Eugene Vandyshev -

after i changed eaccelerator.enable = "1" to "0" it started working correct, same with TeX and MathML

Mauno, thank you very much for your help! smile

In reply to Marc Grober

Re: problems with rendering mathml

by vijaykanth dondapati -
hii i am new to moodle



i am inserted some math quiz questions to database (mysql) in moodle by using wiris editor 

when i am fetching the questions from database its displaying like below image plzz help me.


In reply to vijaykanth dondapati

Re: problems with rendering mathml

by Mauno Korpelainen -

Could you explain first what exactly are you trying to do and how did you use database & wiris quizzes?

If you want to use commercial Wiris tools you need to download and install them - copying wiris quizzes to database won't render any mathematical things.

If the question is about Wiris try http://www.wiris.com/en/contact

In reply to Mauno Korpelainen

Re: problems with rendering mathml

by Ramon Eixarch -
WIRIS components have a test page. Please visit the page

http://[your moodle url]/filter/wiris/info.php

Have you activated WIRIS filter after installing it?