TransWikia.com

Problems using moodle package in Latex with TexShop. The XML file generated is not accepted by MoodleCloud

TeX - LaTeX Asked by veronica on January 22, 2021

I don’t known where is the problem:

File

documentclass[12pt]{article}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{amsmath}
usepackage{amsfonts}
usepackage{amssymb}
usepackage{graphicx}
   usepackage{moodle}
   begin{document}
   begin{quiz}{My first quiz}
    % begin{numerical}[points=2]{Basic addition}
       %What is $8+3$?
       %item 11
     %end{numerical}
     begin{shortanswer}[case sensitive=true]{Newton’s name}
       What was Newton’s first name?
       item Isaac
       item[fraction=0, feedback={No, silly!}] Fig
       item{fraction=0} Sir
     end{shortanswer}
     begin{multi}[points=3]{A first derivative}
       What is the first derivative of $x^3$?
       item  $frac{1}{4} x^4+C$
       item* $3x^2$
       item  $51$
     end{multi}
   end{quiz}
   end{document}

mooddle.sty was downloaded from CTAN

error in moddlecloud isenter image description here

3 Answers

As a freshman here I cannot comment, that is why I made an "answer".

In my workplace using moodle for online testing is the only possibility, so I wrote a simple stuff in julia (https://github.com/czylabsonasa/texjulia) , that generates a random instance of an exercise, which is "compiled" with pdflatex to an xml and pdf file. It was stopped to produce the right xml with accented characters (hungarian) after an upgrade of my system (ubuntu 18.04->20.04). I tried my best to resolve the problem - w/o success.

But @Rmano suggestion to use luatex or xelatex solved my problem. Now everything works fine with accented (utf8) chars, even without including the usual usepackage stuff for utf8 and fontenc.

Thanks a lot!!!

Answered by Czylabson Asa on January 22, 2021

I notice that this package is not compatible with UTF-8 source files. Even if you use a latin1 inputenc environment, the XML generates has UTF-8 declared as its encoding. You may manually change it to ISO-8859-1 or use some script I wrote:

#! /bin/bash

for i in *.xml; do sed -i 's/UTF-8/ISO-8859-1/g' $i; done

exit 0;

Be aware that it will act on any XML file in that folder. After converting XML files thjing workd fine here.

Hope it helps.

Best, Alexandre

Answered by Alexandre Lymberopoulos on January 22, 2021

The problems here are the following:

  1. moodle.sty does not work with mainly any package. I left the amsmath packages here, for the sake of the PDF, but notice that the rendering of math formulas in Moodle is made by MathJax, not LaTeX itself; for simple formula there are no problem, but you need to check them.

  2. Your apostrophe in "Newton’s name" is not an ASCII apostrophe, but Unicode Character 'RIGHT SINGLE QUOTATION MARK' (U+2019). moodle.sty is unable to process this with pdflatex; especially in the name of the quiz the resulting XML is confusing the (frankly poor) Moodle parser.

This file (still with your fancy apostrophe):

documentclass[12pt]{article}
usepackage{amsmath}
usepackage{amsfonts}
usepackage{amssymb}
usepackage{graphicx}
usepackage{moodle}
begin{document}
begin{quiz}{My first quiz}
   begin{shortanswer}[case sensitive=true]{Newton’s name}
       What was Newton’s first name?
   item Isaac
   item[fraction=0, feedback={No, silly!}] Fig
   item{fraction=0} Sir
   end{shortanswer}
   begin{multi}[points=3]{A first derivative}
       What is the first derivative of $x^3$?
   item  $frac{1}{4} x^4+C$
   item* $3x^2$
   item  $51$
end{multi}
end{quiz}
end{document}

if compiled with lualatex (probably with xelatex also, didn't check), gives a correct XML:

enter image description here

Answered by Rmano on January 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP