How to make exercises with LaTeX or MathJax in presented answers? (in moodle 3.0 or 3.1 or 3.2)

How to make exercises with LaTeX or MathJax in presented answers? (in moodle 3.0 or 3.1 or 3.2)

by Fernando Carpani -
Number of replies: 5

Hello.

We are trying to create exercises for a Mathematical Logic course.

We have a lot of latex documentation (texts, exercises sheets, etc.).

I think that we need both filters, latex and MathJax. This is because we use some packages (like proof) that are not supported by mathJax, but to use in single formulas, mathJax is better (I think) than Latex filter.

But, we have a lot of problems to really enter the exercises.

We can't do things like:

  • Use mathjax in drag items in any form of drag and drop.
  • Use mathjax in some kind of multiple option exercise. (I understand why we can't use in a option tag... there is an alternative?
Has anybody some configuration tip to do this things? Or perhaps, a specific module?
Thanks,
Fdo.


Average of ratings: -
In reply to Fernando Carpani

Re: How to make exercises with LaTeX or MathJax in presented answers? (in moodle 3.0 or 3.1 or 3.2)

by Daniel Thies -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hello Ferdinand,

MathJax does work with the Drag and Drop matching question type that is an additional plugin. The included question types normally do not use  filters in the responses although there are ways that MathJax might still be configured to work apart from the filter. Drop down selection is not really a good idea with MathJax because the HTML specification says that only text is suppose to be in the options. Consequently, MathJax will not work here in many browsers.

In reply to Daniel Thies

Re: How to make exercises with LaTeX or MathJax in presented answers? (in moodle 3.0 or 3.1 or 3.2)

by Fernando Carpani -

I'll try that !!!!

Thanks!

FDO.

In reply to Fernando Carpani

Re: How to make exercises with LaTeX or MathJax in presented answers? (in moodle 3.0 or 3.1 or 3.2)

by Fernando Carpani -

Hello.... I think that it's valid autoanswer smile so... I'm here.

In this message there are two things: some things that I believe that I've learned and a question.

Things that I've learned (or not smile ).

1) Drop Accesible.js from MathJax configuration: this file contains some bugs.

2) There's no link to Mathjax.js if the MathJax code only is inside answers. To force the link, some MathJax code must be in the text of que question. Also works with an HTML comment in the question text including mathJax markup inside.

3) If you want to make some configurations on tex2jax (like change delimiters), you need to add tex2jax as extension the core of mathjax configuration.

At the end of this message, I include my configuration.

The question

I want to use simultaneously TeX Filter and MathJax. This might be possible if we change the delimiters. But, if I do that, MathJax also process some content in the TeX Filter content. The tex filter content looks like this:

<![CDATA[αβ]]>

<!CDATA[α→β]>

How can I controll that? I want to see the TeX Filter image.

My current configuration

MathJax.Hub.Config({
config: [ "Safe.js","TeX-AMS_HTML-full.js"],
extensions: ["TeX/tex2jax"],
errorSettings: { message: ["!"] },
skipStartupTypeset: false,
tex2jax: {
    inlineMath: '@#','#@',
    displayMath: \[','\\]'">'\\[','\\]',
preview:"none",
ignoreClass: "editor_atto_content|forTexFilter",
    skipTags: ["script","noscript","style","textarea","pre","code","a"],
    processClass: "tex2jax_process|markertext|drag"
  }
});

 Thanks

FDO.

In reply to Fernando Carpani

Re: How to make exercises with LaTeX or MathJax in presented answers? (in moodle 3.0 or 3.1 or 3.2)

by Daniel Thies -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hello Fernando,

I just noticed your last question about using different delimiters to choose filters. The Tex filter processes expression initially on the server and places them in script tags (jax) before it is sent to the browser. MathJax usually does this with tex2jax after it is configured. Configuring tex2jax will not affect the expressions that pass through the Tex filter.  One could change the PHP code, but that may interfere with upgrades.

A better method may be to remove the jax after page is loaded and before MathJax is configured with some javascript. Try the following configuration in the MathJax filter.

var texpreviews = document
.getElementsByClassName('MathJax_Preview');
while (0 < texpreviews.length) {
texpreviews.item(0).nextSibling.textContent = '';
texpreviews.item(0).className = '';
}
MathJax.Hub.Config({
config: [ "Safe.js","TeX-AMS_HTML-full.js"],
extensions: ["TeX/tex2jax"],
errorSettings: { message: ["!"] },
skipStartupTypeset: false,
tex2jax: {
    inlineMath: [ ['@#','#@'] ],
    displayMath: [ ['\\[','\\]'] ]
}
});

A more sophisticated script could be written if you want to be more selective about which expressions are processed by a particular method.

Daniel

In reply to Fernando Carpani

Re: How to make exercises with LaTeX or MathJax in presented answers? (in moodle 3.0 or 3.1 or 3.2)

by Christopher Sangwin -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Fernando,

Using your LaTeX with existing Moodle question types is certainly a good start.  You might like to consider going a little further.

There are a variety of question types which enable you to randomly generate exercises, and accept answers which are mathematical expressions (in linear syntax, e.g. sin(n*pi), not asking students to type LaTeX).  One I wrote and support, and which is a dedicated question type for Moodle, is STACK.  A demo site is here:  https://stack.maths.ed.ac.uk/demo/ 

The full docs are linked from this basic description.  https://stack.maths.ed.ac.uk/demo/question/type/stack/doc/doc.php/About/The_philosophy_of_STACK.md

I've posted a lot about this in the forum, so I'm happy to talk offline if you'd like to know more.

Chris


Average of ratings: Useful (1)