Description Usage Arguments Details Value See Also Examples
View source: R/read_exercise.R
Reading an exercise in either LaTeX format (i.e.,
after Sweave
was run) or
Markdown format (i.e., after knit
was run).
1 2  read_exercise(file, markup = NULL)
read_metainfo(file, markup = NULL)

file 
character. Name of the LaTeX ( 
markup 
character specifying whether 
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.
read_exercise
returns a list with elements
question 
a character vector with LaTeX/Markdown code from the question environment (excluding the answerlist environment, if any). 
questionlist 
a character vector with LaTeX/Markdown code from the answerlist environment within the question environment (if any). 
solution 
a character vector with LaTeX/Markdown code from the solution environment (excluding the answerlist environment, if any). 
solutionlist 
a character vector with LaTeX/Markdown code from the answerlist environment within the solution environment (if any). 
metainfo 
a list of metainformation options, see below. 
supplements 
a character vector with paths to supplementary files such as graphics or data files (if any). 
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.
file 
character with file name (without extension) of the exercise template. 
markup 
character indicating whether 
type 
character indicating exercise type: 
name 
character with short name/description (to be used for printing within R). 
title 
character with a pretty longer title. 
section 
character with sections for groups of exercises (using slashes for subsections like a URL). 
version 
character with version of exercise. 
solution 
correct solution. The type/value depends on the

tolerance 
numeric tolerance limits (of length 1 or 2) for numeric solutions. 
clozetype 
character indicating the types of the elements of a

points 
numeric with (default) points for correct solution. 
time 
numeric with (default) time (in seconds) for solution. 
shuffle 
logical indicating whether 
single 
logical indicating whether radio buttons should be used in Moodle. 
length 
numeric with length of 
string 
character with a collapsed string of the solution (and tolerance)
for backward compatibility with 
maxchars 
character with the maximum number of characters allowed in QTI text answers (exercise type: string). 
abstention 
character with the label to be used for an abstention button in schoice/mchoice answers (currently only supported by Moodle). 
1 2 3 4 5 6 7 8 9 
$question
[1] "A machine fills milk into $500$ml packages. It is suspected that the "
[2] "machine is not working correctly and that the amount of milk filled differs "
[3] "from the setpoint $\\mu_0 = 500$. A sample of $226$ packages "
[4] "filled by the machine are collected. The sample mean $\\bar{y}$ is equal to "
[5] "$517.2$ and the sample variance $s^2_{n1}$ is equal to "
[6] "$262.56$."
[7] ""
[8] "Test the hypothesis that the amount filled corresponds on average to the "
[9] "setpoint. What is the absolute value of the $t$~test statistic?"
$questionlist
NULL
$solution
[1] "The $t$~test statistic is calculated by:"
[2] "\\begin{eqnarray*}"
[3] " t & = & \\frac{\\bar y  \\mu_0}{\\sqrt{\\frac{s^2_{n1}}{n}}}"
[4] " = \\frac{517.2  500}{\\sqrt{\\frac{262.56}{226}}}"
[5] " = 15.958."
[6] "\\end{eqnarray*}"
[7] "The absolute value of the $t$~test statistic is thus equal to"
[8] "$15.958$."
$solutionlist
NULL
$metainfo
$metainfo$file
[1] "tstat"
$metainfo$markup
[1] "latex"
$metainfo$type
[1] "num"
$metainfo$name
[1] "t statistic"
$metainfo$title
NULL
$metainfo$section
NULL
$metainfo$version
NULL
$metainfo$solution
[1] 15.958
$metainfo$tolerance
[1] 0.01
$metainfo$clozetype
NULL
$metainfo$points
NULL
$metainfo$time
NULL
$metainfo$shuffle
[1] FALSE
$metainfo$single
[1] FALSE
$metainfo$length
[1] 1
$metainfo$string
[1] "t statistic: 15.958 (15.94815.968)"
$metainfo$maxchars
NULL
$metainfo$abstention
NULL
$supplements
named character(0)
attr(,"dir")
[1] "/work/tmp/tmp/RtmpCjnXkq/file7218706a8b8f/exam1/exercise1"
$question
[1] "A machine fills milk into 500ml packages. It is suspected that the "
[2] "machine is not working correctly and that the amount of milk filled differs "
[3] "from the setpoint $\\mu_0 = 500$. A sample of $226$ packages "
[4] "filled by the machine are collected. The sample mean $\\bar{y}$ is equal to "
[5] "517.2 and the sample variance $s^2_{n1}$ is equal to "
[6] "262.56."
[7] ""
[8] "Test the hypothesis that the amount filled corresponds on average to the "
[9] "setpoint. What is the absolute value of the ttest statistic?"
$questionlist
NULL
$solution
[1] "The ttest statistic is calculated by:"
[2] "$$"
[3] "\\begin{aligned}"
[4] " t = \\frac{\\bar y  \\mu_0}{\\sqrt{\\frac{s^2_{n1}}{n}}}"
[5] " = \\frac{517.2  500}{\\sqrt{\\frac{262.56}{226}}}"
[6] " = 15.958."
[7] "\\end{aligned}"
[8] "$$"
[9] "The absolute value of the ttest statistic is thus equal to"
[10] "15.958."
$solutionlist
NULL
$metainfo
$metainfo$file
[1] "tstat"
$metainfo$markup
[1] "markdown"
$metainfo$type
[1] "num"
$metainfo$name
[1] "t statistic"
$metainfo$title
NULL
$metainfo$section
NULL
$metainfo$version
NULL
$metainfo$solution
[1] 15.958
$metainfo$tolerance
[1] 0.01
$metainfo$clozetype
NULL
$metainfo$points
NULL
$metainfo$time
NULL
$metainfo$shuffle
[1] FALSE
$metainfo$single
[1] FALSE
$metainfo$length
[1] 1
$metainfo$string
[1] "t statistic: 15.958 (15.94815.968)"
$metainfo$maxchars
NULL
$metainfo$abstention
NULL
$supplements
named character(0)
attr(,"dir")
[1] "/work/tmp/tmp/RtmpCjnXkq/file7218293942d3/exam1/exercise1"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.