exams2ans: Generation of Quizzes for Ans

View source: R/exams2ans.R

exams2ansR Documentation

Generation of Quizzes for Ans

Description

Automatic generation of exams in QTI 2.1 with some tweaks (still under development) for the online testing system Ans.

Usage

exams2ans(file, n = 1L, dir = ".", name = "anstest",
  converter = "pandoc-mathjax", maxattempts = 1, cutvalue = NULL, ...)

Arguments

file

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

n

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

dir

character. The default is the current working directory.

name

character. A name prefix for resulting exercises and XML file.

converter

character passed on to make_exercise_transform_html, indicating the type of converter from LaTeX/Markdown to HTML.

maxattempts

integer. The maximum attempts for one question.

cutvalue

numeric. The number of points at which the exam is passed.

...

arguments passed on to exams2qti21.

Details

exams2ans is a convenience interface to exams2qti21 for generating QTI 2.1 with some small tweaks for Ans (https://www.ans.app). The supported exercise types at the moment are num, schoice, mchoice, and string. There is limited support for cloze exercises: It only allows for questions with similar item types (choice items versus fill-in items), meaning that only combinations of schoice and mchoice items or combinations of numeric and string items are allowed.

The Ans-specific tweaks currently include:

  • Ans only recognizes HTML with mathematical notation created with "pandoc-mathjax", which is set as default.

  • The Ans system does not properly render html-<pre> environments and requires an additional adjustment of the QTI XML.

  • Ans has its own unique way of setting tolerance for numeric questions, which is incorporated in the function.

Value

exams2ans returns a list of exams as generated by xexams.

References

Ans (2025). Exercises and Questions. Available at https://support.ans.app/hc/en-us/sections/360004983014-Exercises-Questions

Zeileis A, Umlauf N, Leisch F (2014). Flexible Generation of E-Learning Exams in R: Moodle Quizzes, OLAT Assessments, and Beyond. Journal of Statistical Software, 58(1), 1–36. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v058.i01")}.

See Also

exams2qti21

Examples


## load package and enforce par(ask = FALSE)
library("exams")
options(device.ask.default = FALSE)

## define an exams (= list of exercises)
myexam <- c(
  "boxplots.Rmd",
  "tstat.Rmd",
  "ttest.Rmd",
  "relfreq.Rmd",
  "fourfold.Rmd"
)

## output directory
dir.create(mydir <- tempfile())

## generate .zip with Ans test in temporary directory
exams2ans(myexam, dir = mydir)
dir(mydir)


exams documentation built on April 27, 2026, 3:02 a.m.