Mathjax problems with quiz activity

Mathjax problems with quiz activity

by George Panagiotakopoulos -
Number of replies: 14

Hi to all,

I am experiencing a problem with Tex equations using Mathjax in quiz activity. 
I only use additional HTML code for putting Mathjax into my pages. Alterations to themes concerning Mathjax haven't been made. The additional HTML code is:

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
MMLorHTML: { prefer: "HTML" },
tex2jax: {displayMath: '@d','@d', inlineMath: $$','$$'">'$$','$$' }
});
</script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>

 

If I use Tex equations into a multiple choice equation, when the answer of the quiz appears to the student, there is an unrendered extra piece of the Tex code after the Mathjax properly rendered equation (It can be seen to the next picture). This code appears when I use chrome browser and there aren't any another significant issues.

With firefox browser the problem is worse because the code inputs large gaps into the page (look at the next image)

Is there any solution to that mysterious behaviour? I use Mathjax into other pages with no problem.

Average of ratings: -
In reply to George Panagiotakopoulos

Re: Mathjax problems with quiz activity

by Marc Grober -
I am on an iPhone so am not sure where it is an artifact of how I am viewing it, but I looks like your inline delimiters are the problem.
In reply to Marc Grober

Απάντηση: Re: Mathjax problems with quiz activity

by George Panagiotakopoulos -

Hi Mark. Thank you for your reply. 

The inline delimeters I use is the double dollar ($$). Could I use two cases of inline delimeters simultaneously? I have widely used the double dollar delimeter for many inline equations and it is very hard to change it.

In reply to George Panagiotakopoulos

Re: Απάντηση: Re: Mathjax problems with quiz activity

by Marc Grober -
But this tex2jax: {displayMath: '@d','@d', inlineMath: '">'' } is what you are using per what you posted earlier wink You can do almost whatever you want for tokens and of course have different tokens for inline va display. Review the mathjax docs regarding the various default configurations and how to modify same, then adjust your additionalHtml
In reply to George Panagiotakopoulos

Re: Απάντηση: Re: Mathjax problems with quiz activity

by Marc Grober -
Again, I am on iPhone so difficult to be more expansive, but your MathHub statement can be smaller if you are willing to accept defaults. Issue with moodle is it anticipates doubledollar tokens, but won't parse single dollar, which is why Mauno suggested @d or @i. Also, you can use replace.php to change doubledollar signs in the db to something else.
In reply to George Panagiotakopoulos

Re: Mathjax problems with quiz activity

by Marc Grober -

OK - on a larger machine, lol....

George, read this over: http://docs.mathjax.org/en/latest/configuration.html

Note that you DO NOT NEED to use any inline parameters if you invoke a default config that meets your requirements,  such as

<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script>


So

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX", "output/HTML-CSS"],
    tex2jax: {
      inlineMath: [ ['@i','@i'], ["\\(","\\)"] ],
      displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
      processEscapes: true
    },
    "HTML-CSS": { availableFonts: ["TeX"] }
  });
</script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script>

invokes a pre-defined configuration file, as well as sets other options, as explained in the configuration page:

Note that you can combine in-line configuration with file-based configuration; simply include text/x-mathjax-config scripts as above, but also include config=filename when you load the MathJax.js file. For example, the tex2jax preprocessor does not enable the TeX single-dollar in-line math delimiters by default. You can load one of the pre-defined configuration files that includes the TeX preprocessor, and use an in-line configuration block to enable the single-dollar signs, as in this example:

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      processEscapes: true
    }
  });
</script>
<script type="text/javascript" src="path-to-MathJax/MathJax.js?config=TeX-AMS_HTML">
</script>
In reply to George Panagiotakopoulos

Re: Mathjax problems with quiz activity

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
This is bug MDL-35343.
In reply to Tim Hunt

Re: Mathjax problems with quiz activity

by Marc Grober -
Lol, now that I look back at thread and note the obvious results of failing to escape tokens in preformatted text I suppose that your hub statement may have been fine and Tim correct, though it is unclear that you were using multichoice as opposed to multiple choice in an effected version. In any event you should check the default configs to determine the whether one will work for you, add such additional delimiters as you need for display and inline as I am still concerned re your tokens
In reply to Marc Grober

Απάντηση: Re: Mathjax problems with quiz activity

by George Panagiotakopoulos -

Marc and Tim thank you very much for your replies. I will read more carefully the configuration docs for mathjax and I will update my moodle installation. I will post again if I have questions. 
Thanks again

George

In reply to George Panagiotakopoulos

Απάντηση: Re: Mathjax problems with quiz activity

by George Panagiotakopoulos -

I am using Moodle 2.3.2+ (Build: 20120927). Because I am not very familiar with the MDL bug fix system, I would like to ask you if this version includes the bug fix.

In reply to George Panagiotakopoulos

Re: Απάντηση: Re: Mathjax problems with quiz activity

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

On MDL-35343, it says Resolved: 14/Sep/12 7:38 PM, so that should be in the 20120927 build.

In reply to Tim Hunt

Απάντηση: Re: Απάντηση: Re: Mathjax problems with quiz activity

by George Panagiotakopoulos -

Posting after one month, the problem persists. Mathjax code in right-answer feedback causes the same messy effects. I have upgraded my Moodle code to the latest one (Moodle 2.3.3 (Build: 20121112) but the problem hasn't been solved.

Any newer idea? Tim, Mark?

The additional code I use for Mathjax is:


 

In reply to George Panagiotakopoulos

Απάντηση: Re: Απάντηση: Re: Mathjax problems with quiz activity

by George Panagiotakopoulos -

Hi to all,

I have done almost everything to cope with that problem but no luck. 
The strange thing is that in Firefox there is a problematic behaviour of Mathjax (It seems corrupted) inside the rightanswer feedback (which appears when the user have finished the quiz). I can't understand why this happens. The Mathjax code works fine at every other page or at the main part of the question (the choices in a multichoice question). Tim said that the MDL-35343 has been solved. Maybe there is another bug at the same point which appeared with the new version 2.3.3. Should I report a bug to the Moodle Tracker?

I found that if I enable Tex notation filter the problem dissapears. So it is propably the way the Moodle scripts render the Mathjax code at this very particular point (at the right answer feedback).


The corrupted Mathjax equation and the tex notation of that equation appears in the image below:

 

 

In reply to George Panagiotakopoulos

Re: Απάντηση: Re: Απάντηση: Re: Mathjax problems with quiz activity

by Gunnar Restorff -

Hi,

Did you ever manage to find a solution. I have the same problem, and I have no idea how to solve it. The rendering is quite different in Firefox than Chromium but both are quite incorrect.

This is really a problem for me, because I am going to use this as an online exam in two weeks. To enable TeX filter is a very bad idea for me because then there are many, many question bank that wont work anymore. I just found out of this yesterday, and it is driving my crazy (I had all my focus on ensuring that the questions and options were correct displayed - I never thought that I would need to check whether the feedback alsi was correct)

Please help, somebody smile

 

Best regards,

Gunnar

In reply to Gunnar Restorff

Re: Απάντηση: Re: Απάντηση: Re: Mathjax problems with quiz activity

by Gunnar Restorff -

UPDATE: I have filed this as bug MDL-37845 (https://tracker.moodle.org/browse/MDL-37845).

Preliminary workaround: If I in "question/type/multichoice/styles.css" remove/comment out the code

.que.multichoice .feedback .rightanswer
*{
display:inline
}

and add the code

.que.multichoice .feedback .rightanswer
script{
display:none
}

then it works fine. - But of course then the right answer will start one line under 'Correct answer:' - but that is a minor issue for me.