Learn R Programming

exams (version 1.9-0)

exams2pdf: Generation of Exams in PDF Format

Description

Automatic generation of exams in PDF format.

Usage

exams2pdf(file, n = 1L, nsamp = NULL, dir = ".", template = "plain", 
    inputs = NULL, header = list(Date = Sys.Date()), name = NULL, 
    control = NULL, quiet = TRUE, edir = NULL, tdir = NULL, sdir = NULL)
  
  make_exams_write_pdf(template = "plain", inputs = NULL,
    header = list(Date = Sys.Date()), name = NULL, quiet = TRUE,
    control = NULL)

Arguments

file
character. A specification of a (list of) exercise files.
n
integer. The number of copies to be compiled from file.
nsamp
integer. The number 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
dir
character. The output directory, this has to be set if n is greater than 1 (or template is longer than 1). Current working directory is used by default.
template
character. A specification of a LaTeX template. The package currently provides "exam", "solution", "plain". For details see below.
inputs
character. Names of files that are needed as inputs during LaTeX compilation (e.g., style files, headers). Either the full path must be given or the file needs to be in edir.
header
list. A list of further options to be passed to the LaTeX files.
name
character. A name prefix for resulting exercises, by default chosen based on template.
control
A list of control arguments for the appearance of multiple choice results (see details).
quiet
logical. Should output be suppressed when calling Sweave and texi2dvi.
edir
character specifying the path of the directory in which the files in file are stored (see also below).
tdir
character specifying a temporary directory, by default this is chosen via tempdir.
sdir
character specifying a directory for storing supplements, by default this is chosen via tempdir.

Value

  • exams2pdf returns a list of exams as generated by xexams. make_exams_write_pdf returns a function that is suitable for being supplied as driver$write to xexams.

Details

exams2pdf is a proof-of-concept implementation of the new extensible xexams framework. It is a (slightly less efficient) reimplementation of the old exams function. It proceeds by using make_exams_write_pdf to set up a custom driver$write function on the fly before calling xexams. This custom driver combines each exams with the desired template (and inputs etc.) and then calls texi2dvi on the resulting LaTeX file to produce PDF output. For a single exams (n = 1) the resulting PDF is displayed on screen while for n > 1 some output directory dir has to be specified where the PDF files are stored. For more details see the original exams function.

See Also

xexams, exams, texi2dvi

Examples

Run this code
## load package and enforce par(ask = FALSE)
options(device.ask.default = FALSE)

if(interactive()) {
## compile a single random exam (displayed on screen)
exams2pdf(list(
  "boxplots",
  c("tstat", "ttest", "confint"),
  c("regression", "anova"),
  "scatterplot",
  "relfreq"
))
}

Run the code above in your browser using DataLab