Sweave was run) or
Markdown format (i.e., after knit
was run).
read_exercise(file) read_metainfo(file).tex) or
Markdown (.md) file that should be read into R.read_exercise returns a list with elements
read_metainfo returns a list with the following elements.
Most elements may also be NULL (or empty) if the underlying
information is not specified in the file. If file specifies
extra information, there may also be additional list elements.
"latex" or "markdown"
markup is used in the exercise.num, mchoice,
schoice, string, or cloze.type of the exercise: num leads to a numeric vector (of length 1
or 2), mchoice/schoice lead to logical vector, string to
a character vector (of length 1), and cloze leads to a list of
solutions (depending on clozetype).cloze exercise.mchoice/schoice
answers should be shuffled (in Moodle or other e-learning systems).solution.exams.read_exercise extracts the LaTeX/Markdown code from the question
and solution environments/sections of the exercise file, extracting
the corresponding answerlists separately (if any). Paths to supplementary
files (such as graphics or data files) are stored and the
metainformation is extracted (by calling read_metainfo which
also includes sanity checks).
The supported metainformation commands are described in detail in
vignette("exams2", package = "exams"), see Table 2. Essentially
the extype command in is mapped to the type
element of the returned list etc. (see the Value section below), using
the right storage mode for each command (numeric, character, logical).
Additionally, there is an exextra command which allows to set
up arbitrary additional metainformation elements.
xexams
## xexams() uses read_exercise() by default to read in
## each individual exercise, e.g., here for only a single
## exam with only a single exercise the result is:
set.seed(1090)
xexams("tstat.Rnw")[[1]][[1]]
## the corresponding Markdown version has:
set.seed(1090)
xexams("tstat.Rmd")[[1]][[1]]
Run the code above in your browser using DataLab