2

I would like to use the R package 'exams' with my class and do automatic correction through scanning. For this reason, I have decided to consider only single-choice questions.

I would like to insert more than just one single-choice question in the same exercise. Apparently, this can be done only using \extype{cloze}. Is this right? I found out that only a unique begin/end pair for "question" is allowed and so is for "answerlist". So, I have created an Rnw file whose content is:

\begin{question}

Choose between:
\begin{aswerlist}
\item a
\item b
\item c
\item d 
\item e 
\item f
\item a1
\item b1
\item c1
\item d1
\item e1 
\item f1
\end{answerlist}
\end{question}

\begin{solution}
The right answers are:
<<echo=FALSE, results=tex>>=
soluz1 = c(1,rep(0,5)) 
soluz2 = c(1,rep(0,5))
soluz=c(soluz1,soluz2)
answerlist(ifelse(soluz, "True", "False"))
@

\end{solution}

%% \exname{prova}
%% \extype{cloze}
%% \exsolution{\Sexpr{mchoice2string(soluz1)}|mchoice2string(soluz2)}}
%% \exclozetype{schoice|schoice}
%% \exshuffle{5}

but I am delivered an error message:

Error in extract_environment(question, "answerlist", value = FALSE, markup = markup) : no unique begin/end pair for‘answerlist’found

Any help would be great!

4

1 回答 1

2

In principle, the question formatting is correct but there are two small glitches:

  1. In the third line the code says \begin{aswerlist} instead of \begin{answerlist}. Note the missing n! This is what triggers the error message about the begin/end pairs of answerlist not matching.
  2. The mchoice2string(soluz2) in the \exsolution{} lacks \Sexpr{} so that the code is evaluated in R.

Further comments:

  • In learning management systems like Moodle, such cloze exercises are easy to administer. Then using a combined cloze rather than separate schoice questions may be appealing.
  • However, some learning management systems (like Canvas or Blackboard) do not support cloze questions. Also, in written exams via the NOPS system schoice is easy to use but cloze is not supported.

Hence I would consider carefully which implementation strategy works better for you.

A final tip for debugging: Running xweave("myexercise.Rnw") produces a .tex file that might be useful to inspect for potential problems.

于 2020-01-13T23:34:34.880 回答