2

I use Sweave (Rnw) questions using exams2moodle() from R/exams. All works fine except when I'm trying to use dropdown question for schoice or mchoice questions. Following the manual I try to use the option cloze_mchoice_display = "MULTICHOICE", but that does not work.

I include an example Rnw exercise along with my R code below.

\begin{question}
Which is a parameter?
\begin{answerlist}
\item population mean.
\item sample mean.
\item sample variance.
\item sample mode.
\item sample standard deviation.
\item population mode
\end{answerlist}
\end{question}

%% \expoints{5}
%% \extype{mchoice}
%% \exsolution{100001}
%% \exshuffle{5}

Replication code:

library("exams")
exams2moodle("cloze_dropdown.Rnw", n=3, name = "dropdown")
make_question_moodle(cloze_mchoice_display = "MULTICHOICE")

1 Answer 1

1

There are a couple of issues here:

  1. If you want to set the cloze_mchoice_display option you need to do so via

    exams2moodle(..., cloze = list(cloze_mchoice_display = "..."))
    

    Internally, this calls the make_question_moodle() code. You don't have to do that yourself.

  2. As the name conveys, the cloze_mchoice_display is only used for mchoice elements within cloze exercises (and not standalone mchoice questions). So in the meta-information you need to set the extype tag to cloze (rather than mchoice) and additionally set the exclozetype tag to mchoice. In Rnw exercises:

    \extype{cloze}
    \exclozetype{mchoice}
    
  3. The dropdown menu just lets you select a single answer so this is really intended for schoice elments (where it's actually the default inside cloze questions). So you can only use MULTIRESPONSE displays for mchoice elements and MULTICHOICE displays only for schoice elements.

Thus, you need to decide whether you want:

  • An mchoice question. Then I would keep it as it is in your question but then you cannot have a dropdown menu.

  • A dropdown menu. Then you need to turn it into an schoice question with only a single correct answer. If put into a cloze the dropdown menu is the default display in exams2moodle(...).

As an example, when you use the Rnw exercise below you will get a dropdown menu in Moodle by default.

<<echo=FALSE, results=hide>>=
stat <- sample(c("mean", "mode"), 1)
@

\begin{question}
Which is a parameter?
\begin{answerlist}
\item population \Sexpr{stat}.
\item sample mean.
\item sample variance.
\item sample mode.
\item sample standard deviation.
\end{answerlist}
\end{question}

%% \expoints{5}
%% \extype{cloze}
%% \exclozetype{schoice}
%% \exsolution{10000}
%% \exshuffle{5}
Sign up to request clarification or add additional context in comments.

5 Comments

Thank you for your reply. After adding the code in No 1 in the .R file and No 2 in the .Rnw file I am getting the following error message: Error in split.default(solutionlist, gr) : first argument must be a vector
Sorry, I forgot to say that you need at least R/exams 2.4-0 (currently the development version on R-Forge) for this: install.packages("exams", repos = "https://R-Forge.R-project.org"). See also: stackoverflow.com/questions/64654616/…
I've updated my answer with a few more concrete comments for your setup. Hopefully, this gets your example working now.
Awesome!.You are great. It works. Thank you so much for your time and the help. Much appreciated.
You're very welcome. Please accept the answer by clicking the checkmark on the left. That way your question is flagged as answered here on StackOverflow.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.