Reputation: 6027
I want create questions with R-exams to Moodle. In my case I want use cloze
type and embed answers into math mode:
<<echo=FALSE,hide=TRUE>>=
@
\exname{foo}
\exsection{bar}
\extype{cloze}
\exclozetype{num|num}
\exsolution{1|1}
\begin{question}
What are the answers?
\[x_1=\frac{##ANSWER1##}{##ANSWER2##}\]
\end{question}
I can build Moodle-compatible XML but when I import it into Moodle it goes wrong:
I tried \text{##ANSWER1##}
but same result. I think the MathJax wants parse it too.
How can I use ##ANSWERx##
in math mode?
Upvotes: 1
Views: 1030
Reputation: 17193
I didn't find a solution that works inside LaTeX math when rendered by MathJax. My impression is that when the numerical fill-in-the-blank fields are inserted to the mathematical formula, the MathJax rendering does not work.
I see two possible workarounds: (1) Use a {table} with math markup for certain elements. (2) Use MathML rather than MathJax (i.e., works in Firefox and Safari but not Chrome).
\begin{question}
What are the answers?
\begin{tabular}{rc}
& ##ANSWER1## \\
$x_1 =$ & \rule{\linewidth}{2\linethickness} \\
& ##ANSWER2##
\end{tabular}
\end{question}
\exname{frac}
\extype{cloze}
\exclozetype{num|num}
\exsolution{1|1}
If you store the exercise code above in a file called frac.Rnw
then using
exams2moodle("frac.Rnw")
and importing it into Moodle yields:
\begin{question}
What are the answers?
\[ x_1 = \frac{\text{##ANSWER1##}}{\text{##ANSWER2##}} \]
\end{question}
\exname{frac}
\extype{cloze}
\exclozetype{num|num}
\exsolution{1|1}
If you store this exercise code above in frac.Rnw
and then use
exams2moodle("frac.Rnw", converter = "ttm")
the resulting Moodle import looks like this in Firefox:
Upvotes: 1