opts_chunk[["set"]](error = FALSE)
library("stringr")

Examiner

An lightweight, flexible R package for generating multiple choice exams.

This package is still alpha. It came out of code I used to write multiple-choice exams for a course I was teaching. It could change at any time, but I thought it may be useful to others, so I packaged it and put it here.

Usage

Questions are written and stored in a yaml file,

cat(paste0(readLines(system.file("yaml/questions.yaml", 
                                package = "examiner")),
    collapse = "\n"))

Problems can then be loaded and formatted into LaTeX code. This is intended to be used with knitr or Sweave.

library("examiner")
problems <- 
    problemset_from_yaml(system.file("yaml/questions.yaml", 
                                     package = "examiner"))
cat(format(problems))

There are options to shuffle problems, and answers, and to show the solutions. The appearance can be customized by redefining the LaTeX environments. See the package vignettes for more examples.

examiner uses templates to format the questions, which allows flexibility in the formatting. For example, to produce markdown,

tpl_problem <-
    str_c("{{{text}}}", "\n",
          "{{{answers}}}", 
          sep = "\n")

tpl_answerlist <-
    str_c("{{#answers}}",
          "1. {{{text}}}",
          "{{/answers}}",
          sep = "\n")

tpl_problemset <-
    str_c("{{{pretext}}}\n",
          "{{#problems}}",
          "{{{.}}}",
          "{{/problems}}",
          "\n{{{posttext}}}",
          sep = "\n")

tpl_problemblock <-
    str_c("{{{pretext}}}\n",
          "{{#problems}}",
          "{{{.}}}",
          "{{/problems}}",
          "{{{posttext}}}\n",
          sep = "\n")

problems <- 
    problemset_from_yaml(system.file("yaml/questions.yaml", 
                                     package = "examiner"))
cat(format(problems,
    tpl_answerlist = tpl_answerlist,
    tpl_problemset = tpl_problemset,
    tpl_problemblock = tpl_problemblock,
    tpl_problem = tpl_problem))

Comparison to Alternatives

The package exams is a more mature and full featured package that uses R to generate exams. exams handles more question types and also allows output into HTML. examiner is lighter weight, more flexible due to its use of templates, and uses some newer features like knitr. In general, I'd probably recommend using exams for now; examiner is something of a personal project that has been extended into a package. However, in the future examiner may be developed into a more full featured exam generation package.

There are several exam packages in LaTeX, some of which allow for randomization and shuffling of questions; see the CTAN topic exams. For whatever reason, I found them more complicated to deal with than using another language and templates to generate the output. It was easier to customize and extend using R, than writing LaTeX macros. Most importantly, a templating approach allows for non-LaTeX output.



jrnold/examiner documentation built on May 20, 2019, 1 a.m.