For proofreading purposes, to circulate a draft to a teaching assistant, I would like to generate an answer key. I generate draft exams using either exams2html()
or exams2pandoc()
, but these don't have a key. I looked at the arguments for these two functions, but didn't see anything clearly related to showing answers on outputs. The closest I could find was the solution
argument that seems to alter the presentation of the question rather than displaying the answer.
exams2pandoc(e, solution = "Answer")
: This changes the output question format to list "Answer" rather than the default "Solution".
exams2html(e, solution = "Answer")
: This does not show an "Answer" but the default does not seem to show "Solution" so I suppose that's no surprise.
I searched in the R/exams documentation, R-Forge, and here on StackOverflow. However, I was unable to locate instructions or guidance on this. Any help generating a key for a draft exam would be much appreciated. Sorry in advance if I missed something obvious.
As the main purpose of R/exams is to generate large numbers of randomized questions, a classical answer key is typically of limited use (because you wouldn't want to go through dozens or hundreds of random variations of answer keys). That's why there is not so much emphasis on answer keys in R/exams.
However, there are tools you can use. On the command line there is exams_metainfo()
, e.g.:
exm <- c("capitals.Rmd", "swisscapital.Rmd", "switzerland.Rmd")
set.seed(0)
res <- exams2html(exm)
exams_metainfo(res)
## exam1
## 1. Capitals: 1, 5
## 2. Swiss Capital: 1
## 3. About Switzerland: 1, 2
The print()
method for the meta-information can also be tweaked a little bit, see http://www.R-exams.org/general/tamiu_finance/ for some practical examples.
If you want to display the answer key with check boxes, then the package ships with a suitable template for exams2pdf()
:
set.seed(0)
exams2pdf(exm, template = "solution.tex")
This includes the following on the title page:
Of course, you can also tweak the "solution.tex"
template further to adapt it to your specific needs. To get started with this look at demo-pdf.R
produced by
exams_skeleton(writer = "exams2pdf")
Finally, a quick clarification regarding the solution
argument in exams2pandoc()
and exams2html()
, taken from the corresponding help pages.
question
: character or logical. Should the question be included in the output? If 'question' is a character it will be used as a header for resulting questions.
solution
: character or logical, see argument 'question'.