Search code examples
dropdownmoodler-exams

Dropdown menu for multiple-choice questions with exams2moodle


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")

Solution

  • 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}