FlexibleGenerationofE-LearningExamsinR:
Moodle Quizzes, OLAT Assessments, and Beyond
Achim Zeileis
Universit¨atInnsbruck
Nikolaus Umlauf
Universit¨at Innsbruck
Friedrich Leisch
Universit¨at f¨ur
Bodenkultur Wien
Abstract
Thisintroductiontoversion2oftheRpackageexamsisa(slightly) modifiedversion
of Zeileis, Umlauf,and Leisch (2014), published in the Journal of Statistical Software.
Sinceitspublication,theexamspackagehasbeenextendedinvariouswayswhicharenot
yet reflectedinthisvignette(e.g., exercisesin R/Markdownformat insteadof R/L
A
T
E
X,
ortheexams2nopsinterfaceforexamsthatcanbeautomaticallyscannedandevaluated).
Thecapabilitiesofthepackageexamsforautomaticgenerationof(statistical)examsin
Rareextendedbyaddingsupportforlearningmanagementsystems: Asinearlierversions
of the packageexamgenerationisstillbasedonseparateSweave filesfor eachexercise–
but rather thanjust producingdifferent typesofPDFoutput files,thepackage cannow
render the same exercises into a wide variety of output formats. These include HTML
(with various options for displaying mathematical content) and XML specifications for
online examsinlearningmanagement systemssuchasMoodle orOLAT.Thisflexibility
is accomplished by a new modular and extensible design of the package that allows for
readingallweavedexercisesintoRandmanagingassociatedsupplementary files(suchas
graphicsor datafiles). Themanuscriptdiscussesthereadily availableuser interfaces,the
designof theunderlyinginfrastructure,andhownewfunctionality canbebuiltontopof
theexistingtools.
Keywords:exams,e-learning,multiplechoice,arithmeticproblems,Sweave,R,LAT
E
X,HTML,
XML, IMS QTI, Moodle, OLAT.
1. Introduction
Thedesign for version 1 oftheexams package was conceived eightyears ago (in 2006) when
theoriginal authors (Gr¨unandZeileis2009)wereinvolved in aredesign of theintroductory
statistics lecture at WU Wirtschaftsuniversit¨at Wien. Back then the main goal was to be
abletoproduceexamsalongwith associatedself-studymaterialsasPDF(portabledocument
format)files. Thus,themainfocuswasstillonprintablematerialsforclassicclassroomexams.
Although e-learningsystems started tobecomeavailablemoreeasilyback at thattime, they
were still not very widely used and, more importantly, rather few easy-to-use standards for
specifying e-learning exams were available (e.g., WU Wien used a partially self-developed
e-learningsystem based on .LRN, seeBlesiusetal.2007).
However,since2006thesituation hasclearlychanged: E-learningsystemsarenowabundant
with many universities offering one (ore more) e-learning system(s) in which all students
Pdf data extraction to excel - extract form data from PDF in C#.net, ASP.NET, MVC, Ajax, WPF
Help to Read and Extract Field Data from PDF with a Convenient C# Solution
pdf form field recognition; how to make a pdf form fillable in reader
Pdf data extraction to excel - VB.NET PDF Form Data Read library: extract form data from PDF in vb.net, ASP.NET, MVC, Ajax, WPF
Convenient VB.NET Solution to Read and Extract Field Data from PDF
export pdf form data to excel; saving pdf forms in acrobat reader
2
FlexibleGenerationofE-Learning Exams in R
are readily registered. Consequently, many lecturers routinely offer online exams (or tests,
quizzes, assessments) forlarge-lecture courses– either as self-study materials or as (part of)
themain assessment ofthecourse.
Amongthemorepopularchoicesoflearningmanagementsystemsaretheopen-sourcesystems
Moodle – developed by Dougiamas et al. (2014) and supported by a large world-wide user
community–orOLAT(foronlinelearningandtraining)–originallydevelopedbyUniversit
¨
at
Z
¨
urich(2012)andwiththerecentforkOpenOLATbeingdevelopedby frentix GmbH(2014)
andasupportcommunity. ApopularproprietarylearningmanagementsystemisBlackboard
developed by Blackboard Inc. (2010). Standards for specifying and exchanging e-learning
exams/assessementshavealsoemerged(seeAgeaetal.2009, foran overview). WhileMoodle
specifies its own Moodle XML format (but can import and export several other formats),
OLAT/OpenOLAT and Blackboard employ certain subsets of the international QTI (ques-
tion &test interoperability) standard, version 1.2, maintained by theIMSGlobalLearning
Consortium, Inc.(2002). ThesuccessorformatsareQTI2.0andthecurrentQTI2.1which
is for exampleemployed in the ONYX testsuite (BPSBildungsportalSachsenGmbH2014)
thatalsooffersinterfaces to OLAT and Blackboard.
Therefore,althoughthePDFexamsproducedbyversion1oftheexamspackageasintroduced
byGr¨unandZeileis(2009) arestill useful formanytypes ofcourses, itwould alsobe highly
desirabletohavesupport for generatinge-learningexamsfrom the same poolofexercises. In
fact, this became an apparent need when the authors of the present manuscript took over
newlarge-lecturestatistics and mathematics coursesat their respectiveinstitutions (Univer-
sit
¨
at Innsbruck and Universit
¨
at f
¨
ur Bodenkultur Wien, BOKU, respectively). For example,
the new“Mathematics 101”lectureat Universit
¨
at Innsbruck is currently attended by about
1,600 students (mostly first-year business and economics students) and accompanied by bi-
weeklyonlineexams conducted in theuniversity’sOLATlearningmanagementsystem. This
was astrong incentive to start developing version 2 of the exams package that is presented
here and offers an extensible toolbox for generating e-learning exams, including easy-to-use
functions for Moodle quizzesand OLAT assessments
1
.
ThenewversionoftheexamspackagefortheRsystemforstatisticalcomputing(RCoreTeam
2014)isavailablefromtheComprehensiveRArchiveNetworkathttp://CRAN.R-project.
org/package=exams.Likepriorversionsitemploysideasandtechnologiesfromliteratepro-
grammingandreproducibleresearch(seee.g.,Knuth1992;deLeeuw2001;LeischandRossini
2003; Kuhn 2014)byusingSweave()(Leisch 2002)tocombinedata-generatingprocessesin
Rwith correspondingquestions/solutions in L
A
T
E
X(Knuth1984;Lamport1994). But in ad-
dition toproducingexamsin PDFformat, thenewversionofexamsincludesextensibletools
forgeneratingotheroutputformatswithout havingtomodifythepoolofexercises. Thus,the
designprinciples of the exams packageareonly somewhat extended compared toversion 1:
Each exercise template (also called“exercise”for short) is a single Sweave file (.Rnw)
interweaving R code for data generation and L
A
T
E
Xcode for describing question and
solution (possibly containingmathematical notation in L
A
T
E
X).
Examscanbegeneratedbyrandomlydrawingdifferentversionsofexercisesfromapool
of such Sweave exercise templates. The resulting exams can be rendered into various
1
Currently,OLATandOpenOLATdo notdifferwithrespecttotheirspecificationofexams. Hence,essen-
tiallyalldiscussionofOLATinthismanuscriptappliestobothOLATandOpenOLAT.
VB.NET PDF Text Extract Library: extract text content from PDF
Application. Advanced Visual Studio .NET PDF text extraction control, built in .NET framework 2.0 and compatible with Windows system.
collect data from pdf forms; pdf form data extraction
C# PDF Text Extract Library: extract text content from PDF file in
Image text extraction control provides text extraction from PDF images and image files. Best C#.NET PDF text extraction library and component for free download.
extract data from pdf using java; export pdf data to excel
Achim Zeileis, Nikolaus Umlauf, Friedrich Leisch
3
formatsincludingPDF, HTML, MoodleXML,orQTI1.2
2
(for OLAT/OpenOLAT).
Maintenance is simple as exercises are separate standalone files. Thus, large teams
can work jointly on the pool of exercises in a multi-author and cross-platform setting
becauseeach team member can independently develop and editasingleexercise.
The remainder of this paper consists of two major parts: First, we illustrate in Section 2
how to use both the old and new exam-generating functions that are readily available in
thepackage. This serves as afirst introduction and is sufficient for getting agood overview
of the available features and how to get started. Second, Section3 provides details about
the design underlying the toolbox for the new infrastructure. This section – as well as the
subsequentSection4showinghowtoextendthetoolbox–maybeskippedupon firstreading
but it contains many important details that are likelytoberequired when actually starting
tocreatecourse materials with the package. Finally, adiscussion in Section5concludes the
paper.
2. Using the exams package
In this section we provide an overview of the most important user interfaces provided by
the exams package. This serves as a first introduction, assuming only (basic) knowledge of
Sweave(Leisch2012a,b). First,theformatoftheexerciseSweavefilesisreviewedalongwith
the old (version 1) exams() function. Subsequently, the new (version 2) functions of type
exams2xyz() are introduced: exams2pdf() and exams2html() produce one PDF or HTML
filefor each exam, respectively. In caseofjust asingleexam, this isshown interactively in a
viewer/browser. exams2moodle() and exams2qti12() generate Moodleand QTI1.2exams,
i.e.,justasingleXMLorZIPfile, respectively,whichcanbeeasilyuploaded intoMoodleand
OLAT.
2.1. Version 1: PDF exams() from Sweave exercises
Exercisetemplates(orjust“exercises”forshort)areessentiallyseparatestandardSweavefiles
(Leisch2012a,b). Theyarecomposed of the followingelements:
Rcodechunks(as usual within <<>>= and @)forrandom datageneration.
Question and solution descriptions contained in LAT
E
Xenvironments of corresponding
names. Both can contain Rcodechunksagain or includedatavia\Sexpr{}.
Metainformationabouttheexercisetype(numeric,multiplechoice,...),itscorrectsolu-
tionetc. AllmetainformationcommandsareinLAT
E
Xstylebutareactuallycommented
outandhidden in thefinal output file.
The underlying ideas are eplained in more detail byGr¨unandZeileis(2009) and Section3
provides more technical details. Here, we focus on illustratinghow different output formats
can begenerated from such exercises.
2
An implementation of the newer QTI 2.1 standard is also available in the package, see?exams2qti21.
However,atthetimeofwritingthefunctionstillneedsmorethoroughtestingandishencenotdiscussedhere.
VB.NET PDF Image Extract Library: Select, copy, paste PDF images
Support PDF Image Extraction from a Page, a Region on a Page, and PDF Document in VB.NET Project. DLLs for PDF Image Extraction in VB.NET.
extract data from pdf into excel; edit pdf form in reader
VB.NET PDF Page Extract Library: copy, paste, cut PDF pages in vb.
VB.NET PDF - PDF File Pages Extraction Guide. Detailed VB.NET Guide for Extracting Pages from Microsoft PDF Doc. Free PDF document
can reader edit pdf forms; how to save editable pdf form in reader
4
FlexibleGenerationofE-Learning Exams in R
<<echo=FALSE, results=hide>>=
## DATA GENERATION
n <- sample(120:250, 1)
mu <- sample(c(125, 200, 250, 500, 1000), 1)
y <- rnorm(n, mean = mu * runif(1, min = 0.9, max = 1.1),
sd = mu * runif(1, min = 0.02, max = 0.06))
## QUESTION/ANSWER GENERATION
Mean <- round(mean(y), digits = 1)
Var <- round(var(y), digits = 2)
tstat <- round((Mean - mu)/sqrt(Var/n), digits = 3)
@
\begin{question}
A machine fills milk into $\Sexpr{mu}$ml packages. It is suspected that the
machine is not working correctly and that the amount of milk filled differs
from the setpoint $\mu_0 = \Sexpr{mu}$. A sample of $\Sexpr{n}$ packages
filled by the machine are collected. The sample mean $\bar{y}$ is equal to
$\Sexpr{Mean}$ and the sample variance $s^2_{n-1}$ is equal to
$\Sexpr{Var}$.
Test the hypothesis that the amount filled corresponds on average to the
setpoint. What is the absolute value of the $t$~test statistic?
\end{question}
\begin{solution}
The $t$~test statistic is calculated by:
\begin{eqnarray*}
t & = & \frac{\bar y - \mu_0}{\sqrt{\frac{s^2_{n-1}}{n}}}
= \frac{\Sexpr{Mean} - \Sexpr{mu}}{\sqrt{\frac{\Sexpr{Var}}{\Sexpr{n}}}}
= \Sexpr{tstat}.
\end{eqnarray*}
The absolute value of the $t$~test statistic is thus equal to
$\Sexpr{fmt(abs(tstat), 3)}$.
\end{solution}
%% META-INFORMATION
%% \extype{num}
%% \exsolution{\Sexpr{fmt(abs(tstat), 3)}}
%% \exname{t statistic}
%% \extol{0.01}
Figure1: A simpleSweave exercise: tstat.Rnw.
C# PDF Image Extract Library: Select, copy, paste PDF images in C#
Document. Support PDF Image Extraction from a Page, a Region on a Page, and PDF Document. C# Project: DLLs for PDF Image Extraction. In
extract data from pdf table; save data in pdf form reader
VB.NET PDF Library SDK to view, edit, convert, process PDF file
PDF Text Extraction. Mature and robust APIs are provided for programmers to integrate and perform PDF text extraction feature in .NET windows and web project.
how to fill out a pdf form with reader; pdf form save in reader
Achim Zeileis, Nikolaus Umlauf, Friedrich Leisch
5
\begin{question}
A machine fills milk into $500$ml packages. It is suspected that the
machine is not working correctly and that the amount of milk filled differs
from the setpoint $\mu_0 = 500$. A sample of $226$ packages
filled by the machine are collected. The sample mean $\bar{y}$ is equal to
$517.2$ and the sample variance $s^2_{n-1}$ is equal to
$262.56$.
Test the hypothesis that the amount filled corresponds on average to the
setpoint. What is the absolute value of the $t$~test statistic?
\end{question}
\begin{solution}
The $t$~test statistic is calculated by:
\begin{eqnarray*}
t & = & \frac{\bar y - \mu_0}{\sqrt{\frac{s^2_{n-1}}{n}}}
= \frac{517.2 - 500}{\sqrt{\frac{262.56}{226}}}
= 15.958.
\end{eqnarray*}
The absolute value of the $t$~test statistic is thus equal to
$15.958$.
\end{solution}
%% META-INFORMATION
%% \extype{num}
%% \exsolution{15.958}
%% \exname{t statistic}
%% \extol{0.01}
Figure2: L
A
T
E
Xoutputof Sweave("tstat.Rnw").
In Figure1, the Sweave file for a simple exercise asking students to compute a one-sample
ttest statistic is shown for illustration (as already used by Gr
¨
un and Zeileis 2009). The e R
chunkforthedata-generatingprocess(DGP),thequestionandsolutionenvironments, and
themetainformation can beeasilydistinguished. The L
A
T
E
Xfileresultingfrom an Sweave()
call isshown in Figure2, and Figure3 showsthefinal compiled PDFoutput generated by
R> library("exams")
R> set.seed(1090)
R> exams("tstat.Rnw")
Here,theexams()functionlooksfortheexercisetemplatetstat.Rnwfirstinthelocalworking
directory and then within the installed exams package where this file is provided. Then it
C#: Demos and Sample Codes for Image Content Extraction Using OCR
C# Sample Code for Png Image Text Extraction. This C# OCR demo code illustrates how to extract text from Png and save to png.pdf. // Set the training data path.
pdf data extraction tool; extracting data from pdf to excel
C# PDF File Permission Library: add, remove, update PDF file
Form Process. Data: Read, Extract Field Data. Data: Auto Fill-in Field Data. Field: Insert Choose to offer PDF annotation and content extraction functions.
exporting data from pdf to excel; extract table data from pdf
6
FlexibleGenerationofE-Learning Exams in R
1. Problem
Amachinefillsmilkinto500mlpackages. Itissuspectedthatthemachineisnotworking
correctlyandthattheamountofmilkfilleddiffersfromthesetpointµ
0
=500. Asample
of226packagesfilledbythemachinearecollected. Thesamplemean ¯y isequalto517.2
and the samplevariances
2
n−1
isequal to262.56.
Testthehypothesisthattheamountfilledcorrespondsonaveragetothesetpoint. What
is theabsolutevalueofthet test statistic?
Solution
Thettest statistic iscalculated by:
t =
¯y−µ
0
s
2
n−1
n
=
517.2−500
262.56
226
=15.958.
Theabsolute valueof the tteststatisticis thus equal to15.958.
Figure 3: Displayof atstat exerciseasPDF viaexams() orexams2pdf().
Figure 4: Display of a tstat exercise as HTML via exams2html(). MathML is employed
formathematicequations, asrendered byaFirefoxbrowser.
VB.NET PDF File Permission Library: add, remove, update PDF file
Data: Read, Extract Field Data. Data: Auto Fill-in Field Data. Field: Insert, Delete, Update Choose to offer PDF annotation and content extraction functions.
extract pdf data into excel; java read pdf form fields
C# PDF File Merge Library: Merge, append PDF files in C#.net, ASP.
Merge Microsoft Office Word, Excel and PowerPoint data to PDF form. PDF document splitting, PDF page reordering and PDF page image and text extraction.
extract data from pdf form fields; how to extract data from pdf to excel
Achim Zeileis, Nikolaus Umlauf, Friedrich Leisch
7
Argument Description
file
A(list of) character vector(s) specifying the (base) names of theSweave ex-
ercisefiles.
n
Thenumber of exams tobegeneratedfrom thelistof exercises. Default: 1.
nsamp
Thenumber ofexercisefilessampledfrom eachlist elementof file. Default:
Oneforeach listelement.
dir
Path to output directory. Default: Single PDF or HTML files are shown
directlyinaviewer/browser(i.e.,exams/exams2pdf/exams2htmlwithn = 1).
In all other cases thecurrent working directoryis used bydefault.
edir
Path to the directory in which the exercises in file are stored. Default:
Workingdirectory (orwithin theexamsinstallation).
tdir
PathtoatemporarydirectoryinwhichSweave()iscarriedout. Default: New
tempdir().
sdir
Pathtothedirectoryinwhichsupplementaryfiles(e.g.,graphicsordatafiles)
arestored (exceptfor exams()). Default: Newtempdir().
name
Nameprefix for theresultingexam files.
template
Character specifying the (base) names of aL
A
T
E
X, HTML, or XML filetem-
platefortheexam (exceptfor exams2moodle()). Default: Afunction-specific
template provided within the exams installation.
encoding
Characterspecifying the encoding tobeused (in version 2interfaces only).
verbose
Should progressinformation bedisplayed (in version 2interfacesonly)?
Table 1: Common arguments of the main user interfaces for generating exams: exams(),
exams2pdf(), exams2html(), exams2moodle(), exams2qti12(). The first group of argu-
ments pertains to the specification of the exam(s), the second group to the handling of in-
put/temporary/output directories, and the last group to name and setup for the resulting
files. For furtherfunction-specificargumentsand moredetails/examples, seethecorrespond-
ingmanual pages.
copies theexercise.Rnw toatemporary directory, calls Sweave()togenerate the .tex, and
includes this in the default LAT
E
Xtemplate for exams before producing the .pdf. As, by
default, just a single .pdf exam is produced and no output directory is specified, a PDF
viewerpops up and displays theresultingexam (as in Figure3).
While applying exams() to just a single exercise is very useful while writing/programming
an exercise, a full exam will typically encompass several different exercises. Also, it may
requiresuppressingthe solutions, includingatitlepage with a questionnaireform, etc. The
former can be achieved by supplyinga (list of)vector(s) of exercises while thelatter can be
accomodated by usingdifferenttemplates:
R> myexam <- list(
+
"boxplots",
+
c("confint", "ttest", "tstat"),
+
c("anova", "regression"),
+
"scatterplot",
+
"relfreq")
R> odir <- tempfile()
R> set.seed(1090)
8
FlexibleGenerationofE-Learning Exams in R
R> exams(myexam, n = 3, dir = odir, template = c("exam", "solution"))
Themyexamlistcontainsfiveexercises: thefirstoneisalwaysboxplots.Rnwwhilethesecond
exercise is randomly drawn from confint.Rnw, ttest.Rnw, tstat.Rnw, and so on for the
remainingexercises. Then, exams() is used todraw n = 3 random exams and produce one
examandonesolutionPDFforeach. ThetemplateargumenttakesnamesofL
A
T
E
Xfileswhich
provide the L
A
T
E
Xheaders and footers. These templates can be used to create a title page
with aquestionnaireform (forstudentname, id, signature, etc.), showor suppresssolutions,
andsetfurtherformattingdetails. Allinvolved.Rnwfiles(withexercises)and.textemplates
employed in the example above are provided in the exams source package and its installed
versions. The resulting output files are stored along with the extracted metainformation in
theoutput directory:
R> dir(odir)
[1] "exam1.pdf"
"exam2.pdf"
"exam3.pdf"
"metainfo.rda"
[5] "solution1.pdf" "solution2.pdf" "solution3.pdf"
More details on basic usageand more advanced customization of this function are provided
by the vignette vignette("exams", package = "exams") which is an updated version of
Gr
¨
un and Zeileis (2009). The e vignetteactually uses the new andsomewhat more flexible
exams2pdf() function rather than exams() and discusses the enhancements made for the
former(see alsobelow).
2.2. Version 2: Producing PDF, HTML, or XML for Moodle or OLAT
Thenewinfrastructureaddedtotheexamspackageontheroadtoversion2isprovidingmore
flexibilityandenablesamuchbroadervarietyofoutputformatswhilekeepingthespecification
of the exercise templates fully backward compatible and only slightly extended. While the
designoftheunderlyingworkhorsefunctions israther different(see Section3), thenewuser
interfacesareverysimilartotheoldone,sharingmostofitsarguments(seeTable1). Hence,
forusersofthepreviousversion ofthepackage,itiseasyand straightforward toadapttothe
newfacilities.
Producing PDF documents: exams2pdf()
Asmentionedabove,thefunctionexams2pdf()isamoreflexiblereimplementationofexams()
usingthenewextensible infrastructure oftheexamspackage. For the user virtually nothing
changes:
R> set.seed(1090)
R> exams2pdf("tstat.Rnw")
pops up the same PDF as shown in Figure 3. We refrain from further discussion of cus-
tomization of the PDF output because this is discussed in vignette("exams", package
= "exams") with details about LAT
E
X master templates, additional auxiliary files, show-
ing/hidingsolutionsetc. Hereweonlypointoutthemaindifferencebetweentheold exams()
function and the new exams2pdf(): The latter not only returns the metainformation from
Achim Zeileis, Nikolaus Umlauf, Friedrich Leisch
9
theexercise butadditionally alsotheL
A
T
E
Xcodefor the question and solution environments
aswellaspathstosupplementarymaterials(suchasgraphicsordatafiles). Section3explains
thestructureofthereturn values in moredetail and illustrates howthiscan be used.
3
Producing HTML documents: exams2html()
As a first step towards including exams generated from Sweave files into e-learning exams,
it is typically necessary to be able to generate an HTML version of the exams. Hence,
the function exams2html() is designed analogously to exams()/exams2pdf() but produces
HTMLfiles. In caseofjustasinglegenerated exam, this isdisplayed in abrowserusingbase
R’s browseURL() function
4
. Again, this is particularly useful while writing/programming a
newexercise template. For example,
R> set.seed(1090)
R> exams2html("tstat.Rnw")
generates theHTML file shown in Figure4which corresponds directlytothePDF filefrom
Figure3. Note that for properly viewing the formulas in this HTML file, a browser with
MathML support is required. This is discussed in more detail in Section 3.4. Here, the
Firefox browser is used (in Debian Linux’s rebranded Iceweasel version) which has native
MathML support.
TotransformtheL
A
T
E
Xquestions/solutionstosomethingthatawebbrowsercanrender,three
options areavailable: translation oftheL
A
T
E
Xto(1)plain HTML, (2) HTMLplusMathML
for mathematical formulas (default), or conversion of the corresponding PDF to (3) HTML
with one embedded raster images for the whole question and solution, respectively. The
formertwooptionsareconsiderablyfasterandmoreelegant–theyjustrequiretheRpackage
tth (Hutchinson, Leisch, and Zeileis s 2013) that makes the ‘T
E
X-to-HTML’ converter TtH
(Hutchinson2012) easily available in R. Also, by default, the base64enc package (Urbanek
2012)isemployedforembeddinggraphicsinBase64encoding.Moredetailsonthisapproach
areprovided in Section3.4.
TheHTML filesproduced with approaches (1) and (2)can also easily contain hyperlinks to
supplementaryfiles. Forexample,iftheRcodeintheSweavefilegeneratesafilemydata.rda,
say,thensimplyincluding\url{mydata.rda}inthequestion/solutionwillresultinasuitable
hyperlink. Thesupplementarydatafilesforeachrandomreplicationoftheexerciseismanaged
fully automatically and a copy of the data is created in an (exam-specific) sub-directory of
theoutput directory. Run exams2html("boxhist.Rnw")forsuch an example.
Justlikeexams()/exams2pdf(),exams2html()canalsogeneratemultiplereplicationsofran-
domly drawn exams viaexams2html(myexam, n = 3, dir = odir). Alsomultiple versions
of the same replications can be generated by providing several templates, e.g., for show-
ing/suppressingsolutions.
3
Toobtainthesametypeofreturnvalueasfromtheexams()function,exams_metainfo(exams2xyz(...))
canbeused.
4
InRStudio(RStudioTeam2014),versionspriorto0.97.133,the"browser"optionissettoafunctionthat
cannot browselocalHTMLfiles onsomeplatforms. Recent versions of RStudio have resolved thisproblem
and?exams2htmlalsoprovidesworkaroundsforolderRStudioversions.
10
Flexible Generation ofE-LearningExamsin R
Producing Moodle XML: exams2moodle()
To incorporate exams generated from Sweave exercises into learning management systems,
such asMoodle, twobuildingblocks aretypically required: (1) questions/solutionsareavail-
ablein plain textorHTML format, and (2)questions/solutionscan beembeddedalongwith
themetainformationaboutthepossibleandcorrectsolutionsintosomeexamdescription for-
mat. (1) can be accomplished as outlined in the previous subsection for exams2html() and
forMoodle(2) requires embeddingeverythinginto Moodle XML format. Both stepscan be
easilycarried outusingtheexams2moodle() function:
R> set.seed(1090)
R> exams2moodle(myexam, n = 3, dir = odir)
This draws the same threerandom examsfrom the myexam list that were already generated
in PDFformat above. Theoutput file, stored again in odir, is asingleXML file.
R> dir(odir)
[1] "exam1.pdf"
"exam2.pdf"
"exam3.pdf"
"metainfo.rda"
[5] "moodlequiz.xml" "solution1.pdf" "solution2.pdf" "solution3.pdf"
ThisXML filemoodlequiz.xml can beeasily imported intoaMoodle quizand then further
customized: First, the XML file is imported into the question bank in Moodle. Then, all
replicationsofeachexercisecan beadded as“random”questions intoaquiz(and potentially
further customized). Figure5 shows the first random draw of the boxplots exercise in the
resulting Moodle quiz (again rendered by a Firefox browser). More details on how exams-
generated questions can beintegrated in Moodle areprovided in Section5.
The corresponding solutions are displayed upon completion of the exam in Moodle. As
before, selected supplementary files are automatically managed and can easily be included
using\url{} in the underlyingL
A
T
E
Xcode. Tobeable to include all thesesupplements in a
single XML file, Base64encoding is employed for all supplements. See themanual page for
thelistofall supported supplement fileformats.
Producing QTI 1.2 XML (for OLAT): exams2qti12()
Thegeneration of QTI 1.2 assessments (for OLAT) proceeds essentially in the same way as
for the Moodle quizzes, by default usingttm for transformation of the text to HTML
5
.The
samethree random draws ofexamsfrom myexamcan be prepared in QTI1.2 format via:
R> set.seed(1090)
R> exams2qti12(myexam, n = 3, dir = odir)
Thisproducesasingle ZIP fileqti.zip, again written toodir.
R> dir(odir)
5
ItmaybeofinteresttoOLATusersthatweexperiencedproblemswiththedisplayofMathMLmatricesin
OLAT.ThecolumnswerenotseparatedbyspacesandwehavenotbeenabletoadaptourOLATinstallation
toavoidethisproblem. Hence,if wewantto displaymatricesinOLAT,wegeneratethemwithextra empty
columns. Thecholesky.Rnwexercisetemplatehascodethatcanautomaticallydothis,ifenabled.
Documents you may be interested
Documents you may be interested