Sinval
Sinval

Reputation: 1417

How to use a LaTeX alternative to {} in order to import R/exams cloze questions to Moodle with LaTeX code?

We are using the marvelous exams package to produce items to be imported to Moodle. Although we noticed that using LaTeX code (i.e. {}) creates conflict with the Moodle code when importing questions. As so, we would like to know alternatives to use all LaTeX functionalities within Moodle. E.g. the

$H_0: \mu_{males}=\mu_{females}$ won't be imported due to the "{}"

Upvotes: 1

Views: 486

Answers (2)

Achim Zeileis
Achim Zeileis

Reputation: 17183

I cannot replicate this problem. I just tested the import in my Moodle system and this looks ok:

Moodle screenshot

The content of my import.Rmd exercise is included below.

Possibly you have some extra filters enabled that prevent importing such content into your Moodle system?

[We've previously seen problems with rendering certain R/exams exercises in Moodle when the tidy XHTML filter was activated. However, these problems occured at the rendering stage not at the import stage (and then also just in very specific settings). So I suspect that your problem is not caused by this filter.]

Question
========
Is it possible to import questions with LaTeX code like
`$H_0: \mu_{males}=\mu_{females}$`
that should be rendered like
$H_0: \mu_{males}=\mu_{females}$?

Answerlist
----------
* Yes
* No

Meta-information
================
exname: LaTeX import
extype: schoice
exsolution: 10

Update

Prompted by the answer from Beatriz I was able to replicate the error. It only occurs if curly brackets are used in the answer alternatives for single-choice or multiple-choice elements of cloze questions. The reason is that Moodle's syntax for embedded answers relies on curly brackets ({1:MULTICHOICE:...}) and hence closing curly brackets have to be escaped. This has been implemented in version 2.4-0 of R/exams.

Moodle screenshot

The corresponding content of hypothesis.Rmd is:

Question
========
Consider a numeric response `outcome` and is a binary factor `gender`
with levels `male` and `female`. What is the alternative hypothesis
used in `t.test(outcome ~ gender)`?

Answerlist
----------
* $\mu_{male} \neq \mu_{female}$
* $\mu_{male} \leq \mu_{female}$
* $\mu_{male} \geq \mu_{female}$

Meta-information
================
exname: Alternative hypothesis
extype: cloze
exclozetype: schoice
exsolution: 100

Upvotes: 1

I have the same problem but when I only if I include {} in the answerlist options with something of length greater than 1, for example \sqrt{25} o t_{25}. \sqrt 2 and t_2, works ok. It works if it is included in question text.

Upvotes: 1

Related Questions