R/exams2canvas.R

Defines functions exams2canvas

Documented in exams2canvas

exams2canvas <- function(file, n = 1L, dir = ".", name = "canvasquiz",
  maxattempts = 1, duration = NULL, points = NULL, converter = NULL,
  template = "canvas_qti12.xml", ...)
{
  ## enforce MathML for mathematical notation
  if(any(tolower(tools::file_ext(unlist(file))) == "rmd")) {
    if(is.null(converter)) converter <- "pandoc-mathml"
    if(!(converter %in% c("pandoc", "pandoc-mathml"))) {
      warning("'converter' must be 'pandoc-mathml' (or equivalently 'pandoc')")
      converter <- "pandoc-mathml"
    }
  } else {
    if(is.null(converter)) converter <- "ttm"
    if(!(converter %in% c("ttm", "pandoc", "pandoc-mathml"))) {
      warning("'converter' must either be 'ttm' or 'pandoc-mathml' (or equivalently 'pandoc')")
      converter <- "ttm"
    }  
  }

  ## call exams2qti12
  rval <- exams2qti12(file = file, n = n, dir = dir, name = name,
    maxattempts = maxattempts, duration = duration, points = points,
    converter = converter, flavor = "canvas", base64 = FALSE,
    eval = list(partial = TRUE, negative = FALSE),
    template = template, ...)

  invisible(rval)
}

Try the exams package in your browser

Any scripts or data that you put into this service are public.

exams documentation built on Oct. 17, 2022, 5:10 p.m.