exams (version 2.3-6)

exams2nops: Generation of Written Exams for Automatic Evaluation


Generation of exams in PDF format that can be printed, scanned, and evaluated automatically.


exams2nops(file, n = 1L, nsamp = NULL, dir = NULL, name = NULL,
    language = "en", title = "Exam", course = "",
    institution = "R University", logo = "Rlogo.png", date = Sys.Date(), 
    replacement = FALSE, intro = NULL, blank = NULL, duplex = TRUE, pages = NULL,
    usepackage = NULL, header = NULL, encoding = "", startid = 1L,
    points = NULL, showpoints = FALSE, samepage = FALSE,
    twocolumn = FALSE, reglength = 7L, seed = NULL, …)

make_nops_template(n, replacement = FALSE, intro = NULL, blank = NULL, duplex = TRUE, pages = NULL, file = NULL, nchoice = 5, encoding = "", samepage = FALSE, twocolumn = FALSE, reglength = 7L)



character. A specification of a (list of) exercise files.


integer. The number of copies to be compiled from file (in exams2nops) and the number of exercises per exam (in make_nops_template), respectively.


integer. The number(s) of exercise files sampled from each list element of file. Sampling without replacement is used if possible. (Only if some element of nsamp is larger than the length of the corresponding element in file, sampling with replacement is used.)


character. The default is either display on the screen or the current working directory.


character. A name prefix for resulting exams and RDS file.


character. Path to a DCF file with a language specification. See below for the list of supported languages.


character. Title of the exam, e.g., "Introduction to Statistics".


character. Optional course number, e.g., "101".


character. Name of the institution at which the exam is conducted.


character. Path to a logo image. If the logo is not found, it is simply omitted.


character or "Date" object specifying the date of the exam.


logical. Should a replacement exam sheet be included?


character. Either a single string with the path to a .tex file or a vector with with LaTeX code for optional introduction text on the first page of the exam.


integer. Number of blank pages to be added at the end. (Default is chosen to be half of the number of exercises.) If pages is specified, blank can also be a vector of length two with blank pages before and after the extra pages, respectively.


logical. Should blank pages be added after the title page (for duplex printing)?


character. Path(s) to additional PDF pages to be included at the end of the exam (e.g., formulary or distribution tables).


character. Names of additional LaTeX packages to be included.


character vector or list. Either a character vector with LaTeX code to include in the header or a named list with further options to be passed to the LaTeX files.


character, passed to xweave.


integer. Starting ID for the exam numbers (defaults to 1).


integer. How many points should be assigned to each exercise? Note that this argument overules any exercise points that are provided within the expoints tags of the exercise files (if any). The vector of points supplied should either have length 1 or the number of exercises in the exam.


logical. Should the PDF show the number of points associated with each exercise (if specified in the Rnw/Rmd exercise or in points)?


logical. Should the itemized question lists be forced to be on the same page?


logical. Should a two-column layout be used?


integer. Number of digits in the registration ID. The default is 7 and it can be increased up to 10.


integer matrix or logical. Either NULL (default), logical, or a matrix of random seeds for each possible exercise to be set prior to calling driver@sweave. If NULL no random seeds are set. If a matrix, the number of rows must be n and the number of columns must correspond to unlist(file). If TRUE a suitable matrix of seeds is sampled.

arguments passed on to exams2pdf.


character. The number of choice alternatives per exercise.


A list of exams as generated by xexams is returned invisibly.


exams2nops is a convenience interface for exams2pdf with a dynamically generated title page which can be printed, scanned with nops_scan and evaluated automatically by nops_eval. It is originally intended for single- and multiple choice (schoice/mchoice) questions only but has also some limited support for open-ended (string) questions.

The exam sheet consists of various sections where information is either printed our filled in by the students. The section with personal data is just for human readers, it is not read automatically. The registration number has to be filled in in digits and also marked with corresponding crosses where only the latter is read automatically. The exam ID/type/scrambling are printed directly into the PDF and read automatically after scanning. Note that the font in the PDF must not be modified for the reading step to work reliably. (A sans-serif font is used and hence the sfmath LaTeX package is also used - if it is installed.) The questions can have up to five alternatives which have to answered by the students. The crosses are read automatically where both empty and completely filled boxes are regarded as not crossed.

Tutorial for NOPS workflow: http://www.R-exams.org/tutorials/exams2nops/.

Limitations: (a) Only up to five answer alternatives per question are supported. (b) Currently, only up to 45 questions are supported. If you have more questions, consider splitting the entire exam up into two NOPS exams. (c) Only up to 3 open-ended questions can be included. (d) Each question must have the same number of answer alternatives and the same number of points across random replications. For example, the n replications drawn for the first exercise all need, say, five alternatives and two points. Then, the second exercise may have, say, four alternatives and five points and so on. But this may not be mixed within the same exercise number.

The examples below show how PDF exams can be generated along with an RDS file with (serialized) R data containing all meta-information about the exam. The PDFs can be printed out for conducting the exam and the exam sheet from the first page then needs to be scanned into PDF or PNG images. Then the information from these scanned images can be read by nops_scan, extracting information about the exam, the participants, and the corresponding answers (as described above). The ZIP file produced by nops_scan along with the RDS of the exam meta-information and a CSV file with participant information can then be used by nops_eval to automatically evaluate the whole exam and producing HTML reports for each participant. See nops_eval for a worked example.

Currently, up to three open-ended string questions can also be included. These do not generate boxes on the first exam sheet but instead a second exam sheet is produced for these open-ended questions. It is assumed that a human reader reads these open-ended questions and then assigns points by marking boxes on this separate sheet. Subsequently, this sheet can also be read by nops_scan.

The language elements can be specified through a relatively simple text file and the package already ships with: English ("en"), Croatian ("hr"), Danish ("da"), Dutch ("nl"), Finnish ("fi"), French ("fr"), German ("de"), Hungarian ("hu"), Italian ("it"), Japanese ("ja"), Korean ("ko"), Norwegian (Bokm<U+00E5>l, "no"), Portuguese ("pt-PT" or "pt-BR"; also "pt" is synonymous with "pt-PT"), Romanian ("ro"), Russian ("ru"), Serbian ("sr"), Slovak ("sk"), Slovenian ("sl"), Spanish ("es"), Swiss German ("gsw"), Turkish ("tr"), Vietnamese ("vi"). Note that the language names correspond to the ISO 639 codes (https://www.loc.gov/standards/iso639-2/php/code_list.php) or IETF language tags (https://en.wikipedia.org/wiki/IETF_language_tag) if no ISO 639 codes exists (as for Brazilian Portuguese). For more details about the underlying text file in DCF format, see http://www.R-exams.org/tutorials/nops_language/


## load package and enforce par(ask = FALSE)
## additionally, for simplicity, enforce using the basic
## tools::texi2dvi() LaTeX interface instead of the more
## flexible/robust tinytex::latexmk()
oopt <- options(device.ask.default = FALSE, exams_tex = "tools")

## define an exam (= list of exercises)
myexam <- list(
  c("boxplots.Rnw", "scatterplot.Rnw"),

if(interactive()) {
## compile a single random exam (displayed on screen)
exams2nops(myexam, duplex = FALSE, language = "de")

## create multiple exams on the disk (in a
## temporary directory)
dir.create(mydir <- tempfile())

## generate NOPS exam in temporary directory
ex1 <- exams2nops(myexam, n = 2, dir = mydir)

# }
## use a few customization options: different
## university/logo and language/title
## with a replacement sheet but for non-duplex printing
ex2 <- exams2nops(myexam, n = 2, dir = mydir,
  institution = "Universit\\\"at Innsbruck",
  name = "uibk", logo = "uibk-logo-bw.png",
  title = "Klausur", language = "de",
  replacement = TRUE, duplex = FALSE)
# }
options(exams_tex = oopt$exams_tex)
# }