4

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.

Here is an screenshot of the error in moodlecloud:enter image description here

4
  • 2
    Well it looks like this is a Moodle problem rather than a TeX problem, so it's unlikely that anyone here can help ... unless ... I note that the example in the package documentation is not identical to yours. It loads no packages except moodle.sty. What happens if you delete all the packages you added (you will also need to replace the apostrophes with ordinary single right quotes)? Jun 19 '20 at 20:10
  • ... my experience is that if you have non-ascii chars at all, you need to remove all the font encoding packages and use lualatex to compile.
    – Rmano
    Jun 19 '20 at 23:30
  • Thank you so much for your help!
    – veronica
    Jun 21 '20 at 12:14
  • I am having problems to download Luatex from luatex.org/download.html
    – veronica
    Jun 21 '20 at 12:14
1

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

6
  • Thank you so much!
    – veronica
    Jun 21 '20 at 22:33
  • So after this I started downloading the TEX LIVE to have Xelaex. I am really giving my first steps to solve an issues on my own with your help! please be patients since I am really not used to things here. In fact I am confused why I need to install Mactex since I already have Texshop installed and it seems it came form same place. But indeed what happens is that doing this download didn't work since I have El Capitan system 10.11.6. So I did like for Unix I think and now I have the messages
    – veronica
    Jun 21 '20 at 22:37
  • Add /usr/local/texlive/2020/texmf-dist/doc/man to MANPATH. Add /usr/local/texlive/2020/texmf-dist/doc/info to INFOPATH. Most importantly, add /usr/local/texlive/2020/bin/x86_64-darwinlegacy to your PATH for current and future sessions.
    – veronica
    Jun 21 '20 at 22:37
  • And i really don't know what to do with this
    – veronica
    Jun 21 '20 at 22:37
  • 1
    I also recommend the use of a UTF8 native TeX engine (XeLaTeX, LuaLaTeX). If pdflatex is required, there is a version of the moodle package that is still in development. With this version, the encoding of the XML file is properly declared as iso-8859-1 (latin1), such that the moodle import sometimes works (some characters given with UTF8 encoding will still lead to trouble). But in addition, support for more accented characters was added, the LaTeX way of writing. Development happens here.
    – mgk
    Nov 12 '20 at 13:52
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.