I use both Moodle
and latex
to write all my quizzes. but, I use latex
to generate formula rich questions in moodle
. The latex package Moodle
can do this. Then I import it as XML file to moodle
. This works perfectly. Before import the quiz the latex compile the code and produce a PDF so can make sure everything ok. It works well for the close quiz question as well. But, when I have the all the question in the close quiz the 'multichoice' then when I import it as an xml then I get error message although latex compile it without any error.
appreciate any help
Latex code:
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{moodle}
\begin{document}
\begin{quiz}{MRTS}
\begin{cloze}{MRTS Q1}\\
A production function is given as $ Q=15\sqrt{KL}$. Q=quantity of output, L = the units of labour, K = the units of capital. The marginal product of labour, $MP_L$ of this function is:
\begin{multi}[horizontal]
\item*$7.5K^{0.5}L^{-0.5}$
\item $7.5K^{-0.5}L^{0.5}$
\item $K^{0.5}L^{-0.5}$
\item $K^{-0.5}L^{0.5}$
\item $15K^{0.5}L^{-0.5}$
\item $15K^{-0.5}L^{0.5}$
\end{multi}
A production function is given as $ Q=15\sqrt{KL}$. Q=quantity of output, L = the units of labour, K = the units of capital. The marginal product of labour, $MP_K$ of this function is:?
\begin{multi}[horizontal]
\item $7.5K^{0.5}L^{-0.5}$
\item *$7.5K^{-0.5}L^{0.5}$
\item $K^{0.5}L^{-0.5}$
\item $K^{-0.5}L^{0.5}$
\item $15K^{0.5}L^{-0.5}$
\item $15K^{-0.5}L^{0.5}$
\end{multi}
A production function is given as $ Q=15\sqrt{KL}$. Q=quantity of output, L = the units of labour, K = the units of capital.The marginal rate of technical substitution associated with this production function is?\\ Note: $MRTS=\displaystyle -\frac{\frac{\partial Q}{\partial L}}{\frac{\partial Q}{\partial K}}$
\begin{multi}[horizontal]
\item $\frac{K}{L}$
\item*$-\frac{K}{L}$
\item $\sqrt{\frac{K}{L}}$
\item $\sqrt{\frac{L}{K}}$
\item $-\sqrt{\frac{K}{L}}$
\item $-\sqrt{\frac{L}{K}}$
\end{multi}
\end{cloze}
\end{quiz}
\end{document}
Best Answer
Unfortunately, I suspect it is a bug/limitation of the Cloze type of questions. This MWE
works ok, and give the expected result in Moodle:
But if you add braces around the exponent:
Moodle fails importing it with:
Now, the only difference between the two XML files generated is this one:
and so it seems that the parser of Moodle get confused by the closing brace in the formula. I really do not know how to escape it, and even if the problem is recognized in the Moodle doc, it seems that simply it will not work:
So basically my takeout is that you can't use formulas in answers in cloze questions. The manual says you can:
...but I didn't manage to get it going. Notice that if you go in the XML file and escape the
{
}
with\{
and\}
then the XML file is accepted, but the formula is broken.This does not happen in normal (no
cloze
)multi
questions, fortunately.So my stopgap solution would be to use Unicode formulas directly typed there, and switch to
lualatex
for the compilation.Another stopgap solution is to use images for your formulas:
will render as:
Not ideal (can be probably made better with a bit of transparency or whatever) but if you need it...