TeX, MathJax and Offline Quiz

TeX, MathJax and Offline Quiz

by Olivier Valentin -
Number of replies: 4
Picture of Particularly helpful Moodlers Picture of Plugin developers

Dear all,

I'm running Moodle 3.5.7+.
I encounter problem with the activity Offline Quiz when I try to use mathematical elements.

I import questions from my bank, where the title or responses contain LateX formulas to create my forms. When I use the question in a classical quiz, or just preview the lists of questions in Offline Quiz, there are no problem. All formulas are ok.

But when I generate the forms in Offline Quiz, the pictures of formulas are all disappeared ! When I activate the debug mode, these are the messages that appear :


Warning: copy(/var/www/moodledata/filter/tex/5c1b97d101d6c6d340f12f5af617cb37.gif): failed to open stream: No such file or directory in /var/www/moodle/mod/offlinequiz/html2text.php on line 161

Notice: Undefined index: extension in /var/www/moodle/mod/offlinequiz/lib/PHPWord/Section/Image.php on line 77

Notice: Source does not exist or unsupported image type. in /var/www/moodle/mod/offlinequiz/lib/PHPWord/Section.php on line 244

I understand that sources don't exist, but I try to undestand how all this works :

  • first, the filter generates a .gif image in moodledata/filter/tex, is that correct ?
  • Tex Notation and MathJax are both activated. But if i desactivate Tex Notation, it doesn't work anymore. Could this be the problem ?
  • When I generate the PDF form, Offline Quiz tries to copy it from the /filter/tex folder. Is that right ?
I asked the server administrator, he confirmed me that both folders (/filter/tex and temp/offlinequiz) are opened for writing (777).

The filter is ok... my temp forlders seem to be ok... Offline Quiz is ok... so what's going wrong ??

Note : I know that Offline Quiz can generate forms in LateX. But I try to avoid this, beacause all our teachers are not able to open it with TeXworks to generate a PDF.

Thanks for all the help you can provide !

Olivier
Average of ratings: -
In reply to Olivier Valentin

Re: TeX, MathJax and Offline Quiz

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

Hi Olivier,

I tried offline quiz on a recent installation (Ubuntu 18.04.03 LTS), and I reproduced the problem, but was able to resolve it. On the server I had installed texlive package for TeX distribution. This enabled the TeX filter to produce SVG images so it worked in a browser, but the pdf conversion for offline quiz seems to require GIF images in the way it is implemented. To generate the GIF images the filter needs ImageMagick package installed on the server. You can see whether that is installed on the TeX notation filter settings page. There needs to be a green check on the path for convert. If that is okay select GIF for the format and save.

After that I tried a the filter and found that it was not producing images. I looked at the filter debug output, and the convert step was throwing an error. I ran the command manually on the command line, and it reported that the security policy was preventing access to postscript. Apparently the default install in recent distributions disables converting postscript to images because of potential security issues. I found the file policy.xml in the ImageMagick configuration directory and removed the last few lines of the file where it says it is disabling postscirpt. After that retested filter, deleted and recreated offline quiz form, and everything worked as expected.

Daniel

Average of ratings: Useful (2)
In reply to Daniel Thies

Re: TeX, MathJax and Offline Quiz

by Olivier Valentin -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi Daniel,
thank you for your answer ! We are trying to change the policy.xml file in ImageMagick, but according to my server administrator, the file doesn't contain lines concerning postscript... Through technical forums, it seems it can be changed in different ways. Which changes did you exactly bring in your file ? Could you give me your version too ?
Thank you !
Olivier
In reply to Olivier Valentin

Re: TeX, MathJax and Offline Quiz

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

I removed the lines

  <!-- disable ghostscript format types -->
  <policy domain="coder" rights="none" pattern="PS" />.
  <policy domain="coder" rights="none" pattern="EPS" />.
  <policy domain="coder" rights="none" pattern="PDF" />
  <policy domain="coder" rights="none" pattern="XPS" />.

from the file. My ImageMagick version is 6.9.10.

Average of ratings: Useful (1)
In reply to Daniel Thies

Re: TeX, MathJax and Offline Quiz

by Olivier Valentin -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi Daniel,
thanks again for your help ! And finally... the problem was somewhere else (like the truth probably... sourire ).
We discovered that the server was unable to bring back the picture generated in the moodledata folder /temp/offlinequiz. Very strange, especially as our moodledata is well opened and have the good permissions 777.
To resolve the problem, we juste changed the folder where the html2text.php creates the image, and bring it from dataroot to dirroot. And everything is ok. We will investigate a few more about permissions on moodledata later.
Thanks again !
Olivier
Average of ratings: Useful (1)