Reputation: 33
I am currently looking into r-exam for generating PDF exams. A single question consists of several subquestions, and is written in Rmd, as in the example below:
Question
========
Calculate the following:
Answerlist
----------
* 1+1
* 2+2
Solution
========
Answerlist
----------
* 2
* 4
Meta-information
================
extype: cloze
exclozetype: num|num
exsolution: 2|4
exname: test
The exam is then generated using exams2pdf
(which combines several Rmd files).
Is there a way to only include the first subquestion (1+1) in the exam, but include both subquestions and their answers in the solution?
Might be a strange question, but this exam will be used as preparation for an oral exam. The first subquestion is with preparation (so therefore it should be included in the exam PDF). The second subquestion is without preparation (asked during oral exam), so it should not be in the exam PDF, but it would be handy if I could include these additional questions in the solution PDF somehow?
Upvotes: 1
Views: 175
Reputation: 17183
If the subquestion are in the same cloze question, I don't see an easy how to do what you want. However, if you put them into separate exercises it's "relatively" straightforward via custom templates.
Say you have two items item1.Rmd
(num with the 1+1 exercise) and item2.Rmd
(num with the 2+2 exercise). Then you need three templates: preparation.tex
, oral.tex
, and combined_solution.tex
. The first two generally hide the solution environment while the latter shows it. Additionally, the first two do not show all exercises while the latter does. More details are below and in Section 3 of vignette("exams", package = "exams")
. Then you can do
`exams2pdf(c("item1.Rmd", "item2.Rmd"), n = 3,
template = c("preparation.tex", "oral.tex", "combined_solution.tex"))
The combined_solution.tex
template shows both question and solution and all exercises:
\documentclass[a4paper]{article}
...
\newenvironment{question}{\item \textbf{Problem}\newline}{}
\newenvironment{solution}{\textbf{Solution}\newline}{}
...
\begin{document}
\begin{enumerate}
%% \exinput{exercises}
\end{enumerate}
\end{document}
The preparation.tex
only shows the first exercise (but not the second) and hides the solution environment:
\documentclass[a4paper]{article}
...
\newenvironment{question}{\item \textbf{Problem}\newline}{}
\newenvironment{solution}{\comment}{\endcomment}
...
\begin{document}
\begin{enumerate}
\input{exercise1.tex}
\item \emph{Oral part.}
\end{enumerate}
\end{document}
Conversely, the oral.tex
only shows the second exercise (but not the first) and hides the solution environment:
\documentclass[a4paper]{article}
...
\newenvironment{question}{\item \textbf{Problem}\newline}{}
\newenvironment{solution}{\comment}{\endcomment}
...
\begin{document}
\begin{enumerate}
\item \emph{Preparation part.}
\input{exercise2.tex}
\end{enumerate}
\end{document}
Instead of including \item \emph{...}
for the hidden exercises you can also increase the counter or use nested {enumerate}
environments or something like that.
Upvotes: 0