I am using Moodle to make my subjects exams. I would like to mix a numerical cloze question, with a single-choice or a multiple-choice question. And each question should have different percentages on the final mark of the question, for example: first numerical question 5%, second numerical question 15%, third multichoice question 20% and so on. I made a cloze_mchoice.Rnw
file:
<<echo=FALSE, results=hide>>=
@
\usepackage{Sweave}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\SweaveOpts{pdf=false}
\begin{question}
%
%
This is the question. This is the question
\begin{answerlist}
\item Numerical answer 1. %Solution: 10
\item Numerical answer 2. %Solution: 20
\item Multiple choice answer 1. %true
\item Multiple choice answer 2. %true
\item Multiple choice answer 3. %false
\item Multiple choice answer 4. %false
\item Numerical answer 3. %Solution: 30
\item Numerical answer 4. %Solution: 35
\end{answerlist}
%
\end{question}
\exname{cloze_mchoice}
\extype{cloze}
\exclozetype{num|num|mchoice|num|num}
%percentage of rigth answer:
% (5%-15%-20%-25%-35%)
\exsolution{10|20|1100|30|35|}
\extol{0.1*10|0.1*20|0.1*30|0.1*35} %Numerical Answer Tolerance
First I use to compile in HTML but I receive this warning:
exams2html("cloze_mchoice.Rnw", encoding = "UTF-8", template = "plain8")
## Warning message:
## In do.call(paste("as", type, sep = "."), list(rval)) :
## NAs introduced by coercion
I have been trying to compile into xml
using
rmx <- exams2moodle("cloze_mchoice.Rnw", n = 1, name = "p_cloze_mchoice",
mchoice = list(abstention = "No answer."))
but I received the same warning message shown above. The p_cloze_mchoice.xml
file is not reading by Moodle.
The file Rnw is a template, I will use a csv file to import input data and output data.
Main problem: The error has got nothing to do with the specific question, it's just due to expoints
being set to something that is not numeric. For example, instead of 0.1 * 10
you should use 1
. When you want to compute expoints
dynamically, you need to do that in an R code chunk and then insert it with \Sexpr{}
into \expoints{}
.
Further aspects:
Multiple-choice items within cloze questions have been added relatively recently in Moodle XML. They do not offer all features, though, that are available for single-choice items or some of them do not work reliably, see: Cloze question combining mchoice and num import in Moodle
R/exams has been improved recently to adapt to the behavior of Moodle. To make use of these features, please install at least version 2.4-0 of the package.
Currently you cannot add an abstention option to multiple-choice questions within a cloze, at least not reliably to the best of my knowledge.
The percentages for the cloze items cannot be specified like that in Moodle. Moodle wants integer "weights". Hence, exams2moodle()
multiplies fractions with a suitable constant (here 100). However, Moodle does not always scale the default grade with these weights. We suspect that this is a problem in Moodle and recommend to use integer expoints
instead.
The extol
has to be the same length as exclozetype
(and not just the same as the number of num
items). Here, you could insert a 0
for the mchoice
itemm.
The LaTeX \usepackage{}
are completely ignored by R/exams. For conversion to HTML (as for Moodle) they wouldn't have any effect on the HTML converter anyway. And for producing PDF output, these commands should be in the LaTeX master template as opposed to the individual exercises.
Jargon: You had used "multichoice" in your original question to refer to multiple-choice questions (mchoice
in R/exams). I changed this because in Moodle "multichoice" refers to single-choice questions (with dropdown menu). Jargon simply isn't unified across systems here and I tried to avoid confusion.
The best version of your exercise I could come up with is included below. Note that the fractional expoints
lead to a warning in R/exams and do not work correctly in Moodle (as explained above).
\begin{question}
This is the question. This is the question
\begin{answerlist}
\item Numerical answer 1.
\item Numerical answer 2.
\item Multiple choice answer 1.
\item Multiple choice answer 2.
\item Multiple choice answer 3.
\item Multiple choice answer 4.
\item Numerical answer 3.
\item Numerical answer 4.
\end{answerlist}
\end{question}
\exname{cloze_mchoice}
\extype{cloze}
\exclozetype{num|num|mchoice|num|num}
\exsolution{10|20|1100|30|35|}
\extol{1|2|0|3|3.5}
\expoints{0.05|0.15|0.2|0.25|0.35}