exams2moodle(file, n = 1L, nsamp = NULL, dir = ".",
name = NULL, quiet = TRUE, edir = NULL,
tdir = NULL, sdir = NULL, resolution = 100,
width = 4, height = 4, iname = TRUE, stitle = NULL,
testid = FALSE, zip = FALSE, num = NULL, mchoice = NULL,
schoice = mchoice, string = NULL, cloze = NULL,
...) make_question_moodle23(name = NULL, solution = TRUE,
shuffle = FALSE, penalty = 0, answernumbering = "abc",
usecase = FALSE, cloze_mchoice_display = "MULTICHOICE",
truefalse = c("True", "False"), enumerate = TRUE)
file
.file
. Sampling without replacement is used
if possible. (Only if some element of nsamp
is larger than
the length of the corresponding element in Sweave
?file
are stored (see also below).tempdir
.tempdir
.Sweave
.name
be included in the path in the
tag in the final XML file? This option may be useful when questions should be added to
certain already existing question banks, i.e. iname = TR
file
, additional section
titles may be set. The section titles will then be added to the
tag in the final XML file (see also argument iname
), i.e.name
.num
)
questions. If num
is a function, num
will be used
for generating the item body of the question, see function make_itembody_qti12()
.
mchoice
, schoice
,
string
, and cloze
), respectively. See argument num
for momchoice
and schoice
exercises, if set to TRUE
will
force Moodle to additionally shuffle the provided answer list.cloze
type questions, the user may set the
visual appearance of choice questions in either a drop down menue (default)
"MULTICHOICE"
, vertical alignment "MULTICHOICE_V"
or horizontal
"
cloze
questions,
the user may specify the possible options shown.cloze
questions, if set to TRUE
, the answerlist and
solutionlist will be enumerated.make_exercise_transform_html
.exams2moodle
returns a list of exams as generated by xexams
. make_question_moodle23
returns a function that generates the XML code
for the question in Moodle's XML standard 2.3.
exams2moodle
will produce a XML file that may be uploaded in Moodle. It proceeds by (1)
calling Sweave
on each exercise, (2) reading the resulting LaTeX code, (3)
transforming the LaTeX code to HTML, and (4) embedding the HTML code in a XML file using the
Moodle 2.3 standards for exams/quizzes. For steps (1) and (2) the standard drivers in xexams
are used. In step (3), a suitable
transformation function is set up on the fly using make_exercise_transform_html
, see also
the details section in exams2html
.
For step (4), the function will cycle through all questions and exams to generate the final XML
file in Moodle 2.3 standard. The structure of the resulting XML file is such that one category
will be set for the exam/quiz using the exam/quiz name
(or this category may be
suppressed (i.e., not included in the XML) by setting iname = FALSE
), followed by one
category/section for each question, while the replicates of each question will be included in the
corresponding category/section. Note that category/section names may also be provided in the
\exsection{}
tag in the .Rnw
files, or within argument stitle
in
exams2moodle
. This may be useful when questions should automatically be added to already
existing Moodle question banks. (See also the argument descriptions above)
The XML code for each question is then generated using function make_question_moodle23
.
Note that for each question type, either the arguments of make_question_moodle23
may be set
within num
, mchoice
, schoice
, string
and cloze
in
exams2moodle
, by providing a named list of specifications that should be used, or for each
questiontype, a function that produces the question XML code may be provided to num
,
mchoice
, schoice
, string
and cloze
. E.g., to suppress the solution
for numeric questions one may set num = list(solution = FALSE)
.
MoodleDocs (2012).
Moodle XML Format.
xexams
,
ttm
,
tth
,
tex2image
,
make_exercise_transform_html
,## load package and enforce par(ask = FALSE)
library("exams")
options(device.ask.default = FALSE)
## define an exams (= list of exercises)
myexam <- list(
"boxplots",
c("tstat", "ttest", "confint"),
c("regression", "anova"),
c("scatterplot", "boxhist"),
"relfreq"
)
## output directory
mydir <- tempdir()
## generate moodle quiz in temporary directory
## using a few customization options
exams2moodle(myexam, n = 3, dir = mydir,
num = list(solution = FALSE),
mchoice = list(shuffle = TRUE)
)
dir(mydir)
Run the code above in your browser using DataLab