exams2forms | R Documentation |
The exams2forms
interface can be used within R/Markdown or Quarto
documents to dynamically insert individual questions or entire quizzes
based on R/exams exercise templates.
exams2forms(file,
write = TRUE, check = TRUE, box = TRUE, solution = TRUE, nchar = c(20, 40),
schoice_display = "buttons", mchoice_display = "buttons",
cloze_schoice_display = "dropdown", cloze_mchoice_display = mchoice_display,
usecase = TRUE, usespace = TRUE, auto = FALSE,
show_filename = !isFALSE(auto), show_tolerance = !isFALSE(auto),
n = 1L, nsamp = NULL, dir = ".", edir = NULL, tdir = NULL, sdir = NULL, verbose = FALSE,
quiet = TRUE, resolution = 100, width = 4, height = 4, svg = FALSE,
converter = "pandoc-mathjax", base64 = NULL, obfuscate = TRUE, ...)
file |
character. A specification of (a list of) exercise files. |
write |
logical. Should |
check |
logical. Should a check for showing the answer be added to the exercise? |
box |
logical. Should a box be added around the |
solution |
logical or character. Should the solution environment
of the R/exams exercises (if any) be displayed or not? Optionally,
|
nchar |
numeric. Number of characters for numeric or string fields
( |
schoice_display , mchoice_display , cloze_schoice_display , cloze_mchoice_display |
character. Should the interaction for single-choice or multiple-choice forms be displayed with buttons (radio buttons or checkboxes, respectively) or with drop-down menus? The default is to use buttons for single-choice and multiple-choice items and for multiple-choice interactions within cloze items. Only for single-choice interactions within cloze items, the default is to use drop-down menus. |
usespace |
logical. Defaults to |
usecase |
logical. Defaults to |
auto |
logical or named list/vector. If set to |
show_filename |
logical. Should the tolerance for numeric fields be
shown before the field? Enabled by default only if the form is
|
show_tolerance |
logical. Should the filename be displayed in the
form? Enabled by default only if the form is |
n |
integer. The number of copies to be taken from |
nsamp |
integer. The number(s) of exercise files sampled from each
list element of |
dir |
character. Standard argument for exams interfaces and hence
included in the argument - but actually not used because |
edir |
character specifying the path of the directory (along with its
sub-directories) in which the files in |
tdir |
character specifying a temporary directory, by default
this is chosen via |
sdir |
character specifying a directory for storing supplements, by
default this is chosen via |
verbose |
logical. Should information on progress of exam generation be reported? |
quiet |
logical. Should output be suppressed when calling
|
resolution , width , height |
numeric. Options for rendering PNG (or SVG)
graphics passed to |
svg |
logical. Should graphics be rendered in SVG or PNG (default)? |
converter |
passed on to |
base64 |
logical. Should supplementary files be embedded using Base 64 coding?
Passed on to |
... |
currently not used. |
obfuscate |
logical. Should the correct answer be obfuscated when
embedded in the HTML source code? If |
exams2forms
provides an interface for including exercises from
R/exams (https://www.R-exams.org/) in R/Markdown or Quarto documents.
This is done by rendering the exercises (either in .Rnw or .Rmd format)
into Markdown which can then be included in .Rmd or .qmd
documents. For a short introduction see
https://www.R-exams.org/tutorials/exams2forms/.
The function exams2webquiz
can set up a suitable .Rmd file and directly render it. This is intended mostly
for quick interactive testing when authoring R/exams exercises.
The idea and original code for inserting interactions into R/Markdown documents along with CSS and Javascript is adapted from the webexercises package, authored by Dale Barr and Lisa DeBruine.
A list of exercises, each of which is a character vector with the Markdown code of the individual exercises.
exams2webquiz
,
xexams
,
xweave
## example R/exams exercises: string, num, schoice, mchoice
exams2forms("function.Rmd")
exams2forms("deriv.Rmd")
exams2forms("swisscapital.Rmd")
exams2forms("switzerland.Rmd")
## usually exams2forms() is used within R/Markdown or Quarto tutorials,
## two example files are shipped within the package.
## - questions.Rmd: all questions set up indvidually
## - quiz.Rmd: an entire quiz set up in one go
lr <- system.file("forms", package = "exams2forms")
dir(lr)
## quiz.Rmd is rather short and straightforward
rmd <- file.path(lr, "quiz.Rmd")
writeLines(readLines(rmd))
## Not run:
## either .Rmd file can be loaded in RStudio and rendered from there or
## using the command line, e.g.,
rmarkdown::render(rmd)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.