Automatic generation of exams in QTI 1.2 with some tweaks (still under development) for the learning management system Canvas.
exams2canvas(file, n = 1L, dir = ".", name = "canvasquiz",
maxattempts = 1, duration = NULL, points = NULL,
converter = NULL, template = "canvas_qti12.xml",
quiztype = "assignment", ...)
exams2canvas
returns a list of exams as generated by xexams
.
character. A specification of a (list of) exercise files.
integer. The number of copies to be compiled from file
.
character. The default is the current working directory.
character. A name prefix for resulting exercises and ZIP file.
integer. The maximum attempts for one question
(must be smaller than 100000
).
integer. Set the duration of the exam in minutes.
integer. How many points should be assigned to each exercise? Note that this
argument overules any exercise points that are provided within an "\expoints{}"
tag
in the .Rnw
file. The vector of points supplied is expanded to the number of exercises in
the exam.
character passed on to make_exercise_transform_html
,
indicating the type of converter from LaTeX/Markdown to HTML. Currently,
Canvas requires HTML with MathML. Hence, if there are Markdown-based .Rmd
exercises, the converter
needs to be "pandoc-mathml"
(or
equivalently "pandoc"
). For only LaTeX-based .Rnw exercises "ttm"
can be used as an alternative and is currently the default.
character. The IMS QTI 1.2 template that should be used.
character. The type of quiz that should be created in Canvas.
Defaults to "assignment"
with alternative values being "practice_quiz"
,
"graded_survey"
, or "survey"
.
arguments passed on to exams2qti12
.
The arguments base64
and eval
cannot be modified but are
hard-coded internally (for details see below).
exams2canvas
is a convenience interface to exams2qti12
for generating QTI 1.2 with some small tweaks for Canvas
(https://www.instructure.com/canvas). The supported exercise types at the
moment are num, schoice, mchoice, and string. There is limited support for cloze exercises
with multiple dropdown menus, i.e., schoice elements placed in the text with ANSWERi tags.
The Canvas-specific tweaks include:
Canvas necessitates a converter
that produces HTML plus MathML.
Thus, "pandoc-mathml"
(or equivalently "pandoc"
) can be used
or alternatively "ttm"
for exams with only R/LaTeX .Rnw exercises.
Supplementary files (images, data, ...) must be embedded without Base 64
encoding. Thus, base64 = FALSE
is hard-coded internally in exams2canvas
.
Multiple-choice exercises (referred to as multiple answer questions in Canvas)
are always evaluated (aka scored) with partial credits in Canvas. Therefore,
eval = list(partial = TRUE, negative = FALSE)
is hard-coded internally
in exams2canvas
. Negative points are not supported in Canvas.
The QTI XML file requires a few special tags which are enforced through
flavor = "canvas"
in exams2qti12
.
Technical note: For multiple-choice questions the QTI XML file produced by
exams2canvas
appears to encode an “all-or-nothing” scheme without partial
credits (i.e., partial = FALSE
). However, this is necessary for Canvas to recognize
the answer alternatives correctly. Despite this, Canvas always applies partial-credit
evaluation (as explained above).
exams2qti12
# \donttest{
## load package and enforce par(ask = FALSE)
library("exams")
options(device.ask.default = FALSE)
## define an exams (= list of exercises)
myexam <- c(
"boxplots.Rmd",
"tstat.Rmd",
"ttest.Rmd",
"regression.Rmd",
"relfreq.Rmd"
)
## output directory
dir.create(mydir <- tempfile())
## generate .zip with Canvas test in temporary directory
exams2canvas(myexam, n = 3, dir = mydir)
dir(mydir)
# }
Run the code above in your browser using DataLab