exams2webquiz: Setting Up and Running Simple Web Quizzes with R/exams...

View source: R/exams2webquiz.R

exams2webquizR Documentation

Setting Up and Running Simple Web Quizzes with R/exams Exercises

Description

The exams2webquiz function is a convenience tool that sets up an R/Markdown document embedding R/exams exercises in a (temporary) directory and directly rendering it to an HTML page.

Usage

exams2webquiz(file, n = 1L, nsamp = NULL, dir = NULL,
  name = "webquiz", title = "R/exams quiz", browse = TRUE, edir = NULL,
  ..., clean = TRUE, quiet = TRUE, envir = parent.frame())

webquiz(...)

Arguments

file

character. A specification of (a list of) exercise files.

n

integer. The number of copies to be taken from file.

nsamp

integer. The number(s) of exercise files sampled from each list element of file. Sampling without replacement is used if possible. (Only if some element of nsamp is larger than the length of the corresponding element in file, sampling with replacement is used.)

dir

character. A path in which the tutorial file is created, by default chosen as a tempfile.

name

character. A name prefix for the resulting .Rmd document.

title

character. Title of the quiz.

browse

logical. Should the resulting tutorial be displayed using browseURL?

edir

character. The path of the directory (along with its sub-directories) in which the files in file are stored. If both dir and edir are NULL (the default), the edir is set to the current working directory.

...

arguments passed to exams2forms (in exams2webquiz) or html_document (in webquiz), respectively.

clean, quiet, envir

arguments passed to render.

Details

exams2webquiz is a convenience function that sets up a .Rmd document (in a temporary directory by default) and then calls render from rmarkdown to quickly try out the quiz interactively.

webquiz is a small wrapper function that creates an html_document but includes some custom CSS and Javascript for the quiz display and user interactions. The idea and original code is adapted from the webexercises package, authored by Dale Barr and Lisa DeBruine.

For full customization it is recommended to set up a dedicated .Rmd file within which exams2forms can be used to include R/exams exercises.

Value

Invisible character vector containing the path of the Rmd document and rendered HTML file, respectively.

See Also

exams2forms, render

Examples

## Not run: 
## quickly render a quiz based on a set of R/exams exercises
ex <- c("swisscapital.Rmd", "capitals.Rmd", "fruit.Rmd", "function.Rmd", "lm2.Rmd")
exams2webquiz(ex)

## End(Not run)

exams2forms documentation built on May 9, 2025, 3 a.m.