exams2pandoc {exams} | R Documentation |
Generation of Exams via Pandoc
Description
Automatic generation of exams via pandoc, by default in docx format.
Usage
exams2pandoc(file, n = 1L, nsamp = NULL, dir = ".",
name = "pandoc", type = "docx", template = "plain.tex",
question = "Question", solution = "Solution",
header = list(Date = Sys.Date()), inputs = NULL, options = NULL,
quiet = TRUE, resolution = 100, width = 4, height = 4, svg = FALSE,
encoding = "UTF-8", envir = NULL, engine = NULL,
edir = NULL, tdir = NULL, sdir = NULL, verbose = FALSE,
points = NULL, exshuffle = NULL, ...)
Arguments
file |
character. A specification of a (list of) exercise files. |
n |
integer. The number of copies to be compiled from |
nsamp |
integer. The number(s) of exercise files sampled from each
list element of |
dir |
character specifying the output directory (default:
current working directory). If only a single HTML file is produced
and no |
name |
character. A name prefix for resulting exercises. |
type |
character. The file type to convert to using pandoc. The default is
|
template |
character. A specification of a template in either
LaTeX, HTML, or Markdown format. The default is to use the |
question |
character or logical. Should the question be included in the
output? If |
solution |
character or logical, see argument |
header |
list. A list of named character strings (or functions generating such)
to be substituted in the |
inputs |
character. Names of files that are needed as inputs for the
|
options |
character. A string of options to be passed on to
|
quiet |
logical. Should output be suppressed when calling
|
resolution , width , height |
numeric. Options for rendering PNG (or SVG)
graphics passed to |
svg |
logical. Should graphics be rendered in SVG or PNG (default)? |
encoding |
character, ignored. The encoding is always assumed to be UTF-8. |
envir |
|
engine |
argument passed to |
edir |
character specifying the path of the directory (along with its
sub-directories) in which the files in |
tdir |
character specifying a temporary directory, by default
this is chosen via |
sdir |
character specifying a directory for storing supplements, by
default this is chosen via |
verbose |
logical. Should information on progress of exam generation be reported? |
points |
integer. How many points should be assigned to each exercise? Note that this
argument overules any exercise points that are provided within the |
exshuffle |
logical or integer. If the |
... |
currently not used. |
Details
exams2pandoc
can generate exams in various output formats
(by default docx) using xexams
and
pandoc_convert
. It proceeds by (1) calling
xweave
on each exercise, (2) reading the resulting
LaTeX or Markdown code, (3) transforming the code to the markup of
some exam template (either LaTeX, HTML, or Markdown), (4) embedding the
code in a template and converting it to the desired output format
using pandoc.
For steps (1) and (2) the standard drivers in xexams
are used.
For step (3) a suitable transformation function is set up on the fly
using make_exercise_transform_pandoc
. Depending
on which format the template uses (LaTeX or HTML or Markdown) the
transformation may or may not be trivial.
For step (4) all exercises are inserted into the template (and also
replacing certain additional tags from header
) and then
pandoc_convert
is used to convert to the
desired output format (one file for each exam). In principle, all output
types of pandoc are supported, but most of them have not been tested.
(The main motivation for exams2pandoc
was the generation of
"docx"
or "odt"
files.)
Value
exams2pandoc
returns a list of exams as generated by xexams
.
See Also
Examples
## load package and enforce par(ask = FALSE)
options(device.ask.default = FALSE)
## define an exams (= list of exercises)
myexam <- list(
"boxplots.Rmd",
c("tstat.Rmd", "ttest.Rmd", "confint.Rmd"),
c("regression.Rmd", "anova.Rmd"),
c("scatterplot.Rmd", "boxhist.Rmd"),
"relfreq.Rmd"
)
## output directory
dir.create(mydir <- tempfile())
## compile two docx and odt versions each
set.seed(1090)
exams2pandoc(myexam, n = 2, dir = mydir, type = "docx")
set.seed(1090)
exams2pandoc(myexam, n = 2, dir = mydir, type = "odt")