Cloze exercises
Such questions are supported in R/exams and are called cloze
exercises. For worked examples see
boxhist,
boxhist2,
fourfold,
fourfold2,
lm, among others.
The caveat is that such exercises are not supported by all exams2xyz
interfaces. Most importantly, they are supported by exams2moodle
and exams2openolat
, though.
Illustrative example: German capital (Rmd version)
To turn your illustrative example into an Rmd exercise you need:
Question
========
What is the capital of Germany? \#\#ANSWER1\#\#
What is the population of Germany's capital (in millions)? \#\#ANSWER2\#\#
Answerlist
----------
* Bonn
* Berlin
* Munich
* Hamburg
*
Meta-information
================
exname: German capital
extype: cloze
exclozetype: schoice|num
exsolution: 0100|3.669495
extol: 0.1
exshuffle: TRUE
Rendered in Moodle the exercise looks like this:

Details and variations
The \#\#ANSWERi\#\#
placeholders are replaced by the corresponding interaction elements in the final exercise. The answer list in combination with the exclozetype
then provide the information that is necessary to build the interaction elements. Note that the fifth answer list element, corresponding to the population size, is empty.
It is also possible to write cloze
exercises without \#\#ANSWERi\#\#
placeholders but these are then somewhat more limited in how the interaction elements can be controlled. See boxhist vs. boxhist2 and fourfold vs. fourfold2.
Rnw version
The Rnw version of the same exercise is as follows:
\begin{question}
What is the capital of Germany? ##ANSWER1##
What is the population of Germany's capital (in millions)? ##ANSWER2##
\begin{answerlist}
\item Bonn
\item Berlin
\item Munich
\item Hamburg
\item
\end{answerlist}
\end{question}
\exname{German capital}
\extype{cloze}
\exclozetype{schoice|num}
\exsolution{0100|3.669495}
\extol{0.1}
\exshuffle{TRUE}