Reputation: 433
I would like to randomize a cloze question using \exshuffle{5}
as here:
<<echo=FALSE, results=hide>>=
questions <- solutions <- explanations <- list()
type <-rep("schoice", 2)
questions[[1]]<- letters[1:7]
solutions[[1]]<- c(TRUE, rep(FALSE, 6))
questions[[2]]<- LETTERS[1:7]
solutions[[2]]<- c(TRUE, rep(FALSE, 6))
explanations[type=="num"] <- solutions[type=="num"]
explanations[type=="schoice"] <- lapply(solutions[type=="schoice"],
function(x) ifelse(x, "True", "False"))
solutions[type=="schoice"] <- lapply(solutions[type=="schoice"], mchoice2string)
@
\begin{question}
What is the first letter of ``apple''? ##ANSWER1##
What is the first letter of ``Algeria''? ##ANSWER2##
<<echo=FALSE, results=tex>>=
answerlist(unlist(questions))
@
\end{question}
\begin{solution}
<<echo=FALSE, results=tex>>=
answerlist(unlist(explanations))
@
\end{solution}
%% META-INFORMATION
%% \extype{cloze}
%% \exsolution{\Sexpr{paste(solutions, collapse = "|")}}
%% \exclozetype{\Sexpr{paste(type, collapse = "|")}}
%% \exname{question}
%% \exshuffle{5}
but importing the question in Moodle I get an error (which I believe is due to \exshuffle{5}
at the end):
Error importing question Invalid embedded answers (Cloze) question (One of the answers should have a score of 100% so it is possible to get full marks for this question.).
I would like to understand how to use correctly \exshuffle{}
within a cloze question.
Upvotes: 1
Views: 110
Reputation: 17183
When using at least version 2.4-0 of R/exams, then exshuffle within cloze exercises works as intended. Some bugs were fixed to properly support this. In particular, no {solution} environment is necessary anymore to make it work. (In your case this could simply be dropped because it does not add much value in addition to the exsolution.)
Upvotes: 1