Learn R Programming

exams (version 1.9-0)

xexams: Extensible Generation of Exams

Description

Extensible automatic generation of exams including multiple choice questions and arithmetic problems.

Usage

xexams(file, n = 1L, nsamp = NULL,
    driver = list(sweave = NULL, read = NULL, transform = NULL, write = NULL),
    dir = ".", edir = NULL, tdir = NULL, sdir = NULL)
  exams_metainfo(x, ...)

Arguments

file
character. A specification of a (list of) exercise files, for details see below.
n
integer. The number of copies to be taken 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
driver
list with elements sweave (weaver function or list of arguments for the default Sweave), read (function for reading exercise files, defaulting to
dir
character. The output directory passed on to driver$write.
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.
x
a list as returned by xexams.
...
currently not used.

Value

  • A list of exams (of length n), each of which is a list of exercises (whose length depends on the length of file and nsamp), each of which is a list (whose length/contents depends on driver$read).

    When using the default reader, the resulting list can be simplified using exams_metainfo, returning the same (classed) structure as the older exams interface.

Details

xexams is meant to provide an extensible framework for generating exams based on exercises in Sweave format and rendering them into various output formats such as PDF, HTML, or XML (e.g., for Moodle or IMS QTI). xexams is typically not called by the user directly but is used as a common infrastructure for functions such as exams2pdf, exams2html, exams2moodle, exams2qti12, or exams2lops. xexams generates exams from lists (or vectors) of Sweave source files by: (1) running driver$sweave on each Sweave exercise (by default Sweave), (2) running driver$read on the resulting LaTeX file which by default uses read_exercise to read question/solution texts plus metainformation and stores the result in a list, (3) running driver$transform on this list for possible transformations (e.g., from LaTeX to HTML), (4) running driver$write on the list of exercises within each exam.

Each exercise in an exam is essentially a standalone Sweave source file that xexams knows (almost) nothing about, it just calls driver$sweave in each iteration and assumes that driver$read can read the resulting LaTeX file into a list. The specification in file should be either of form "foo" or equivalently "foo.Rnw", where the file "foo.Rnw" should either be in the local directory, the edir directory or in the exercises directory of the package. file can either be a simple vector or a list of vectors. In the latter case, exercises are chosen randomly within each list element. For example, the specification file = list(c("a", "b"), "xyz") will result in an exam with two exercises: the first exercise is chosen randomly between "a" and "b" while "xyz" is always included as the second exercise.

See Also

Sweave, exams, exams2pdf, exams2html, exams2moodle, exams2qti12, exams2lops

Examples

Run this code
## define an exam with five exercises
myexam <- list(
  "boxplots",
  c("tstat", "ttest", "confint"),
  c("regression", "anova"),
  "scatterplot",
  "relfreq"
)

## run exams with default drivers (i.e., no transformations or writer)
x <- xexams(myexam, n = 2)
## x is a list of 2 exams,
## each of which contains 5 exercises,
## each of which contains LaTeX code for question(list) and solution(list),
## plus metainformation and potential supplements

## The first exercise in each exam is "boxplots", a multiple choice question.
## Its general question text is
x[[1]][[1]]$question
## with a list of multiple choice questions given as
x[[1]][[1]]$questionlist
## the corresponding graphic is in supplementary file
x[[1]][[1]]$supplements

## The metainformation is a list read for the \ex*{} items
x[[1]][[1]]$metainfo

## The metainformation can also be extracted/printed as
## in the old exams() (rather than xexams()) interface
exams_metainfo(x)

Run the code above in your browser using DataLab