1

I'm compiling this simple quiz under LaTex TexShop 4.27

\documentclass[12pt]{article}
\usepackage{moodle}
\def\EN{{\bf A}}
\def\XV{3}
\def\YV{4}
%---------------------------
\begin{document}
\begin{quiz}{MyQuiz}
\begin{essay}{Question A}
Report on study case \EN\  with numerical values:
\begin{center}
\begin{tabular}{|c|c|} \hline
     $x$ & $y$  \\ \hline
     \XV & \YV  \\ \hline
\end{tabular}
\end{center}
  \item Case \EN\  with numerical values \XV,\YV
\end{essay}
\end{quiz}
\end{document}

and I get a nice pdf file. But inside the moodle.xml file the defined values don't appear anywhere and the body of the question is:

<text><![CDATA[<p>Report on study case \EN  with numerical values: <CENTER>\begin {tabular}{|c|c|} \hline \(x\) & \(y\) <BR/> \hline \XV & \YV <BR/> \hline \end {tabular}</CENTER> </p>]]></text>

producing this ugly result inside moodle:

enter image description here

What is happening with my definitions and the tabular environment ?.

2
  • change all the \def to \newcommand and it all compiles fine.
    – oliversm
    May 14 '20 at 12:52
  • 2
    Section 4 of the manual lists the commands and environments that get translated into HTML; tabular is not among them, neither are, of course, your personal commands.
    – egreg
    May 14 '20 at 15:16
3

This is what the package moodle documentation says; in particular, neither tabular nor your personal commands are supported.

enter image description here

1
  • Thanks for the clarifying remark. I get confused since environments like \begin{array} work flawlessly and also in the introduction I read: "Users of LaTeX are also accustomed to the speed and flexibility that comes from defininf their own macros, which may be as brief as writting \R instead of \mathbb{R} or as complex as macros that generate entire paragraphs of text. The Moodel editor, by constrast, requires you to type \mathbb{R} every single time you want R"
    – JMS
    May 17 '20 at 7:18
0

If you really need a tabular, the best solution I can see is to pack it into an image. For instance, see this answer.

However, for your macros, I figured out there is an undocumented utility to declare them for expansion by the package before writing in the XML file : \htmlregister. In your case, just place at the end of the preamble:

\def\EN{{\bf A}}
\def\XV{3}
\def\YV{4}
\htmlregister{\EN}
\htmlregister{\XV}
\htmlregister{\YV}

In a development version of the package, I introduced the command \moodleregisternewcommands which triggers the expansion of all macros subsequently defined using \newcommand (and the likes). See this fixed issue. In this case, the use is:

\moodleregisternewcommands
\newcommand{\EN}{{\bf A}}
\newcommand{\XV}{3}
\newcommand{\YV}{4}

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.