R/exams2openolat.R

Defines functions exams2openolat

Documented in exams2openolat

#' Deprecated: Generation of Exams for OpenOlat (Uni Innsbruck)
#' 
#' Unexported legacy interface to \code{\link[exams]{exams2openolat}} with
#' slightly different default values as used at the Department of
#' Statistics, Uni Innsbruck. Instead it is recommended to use
#' \code{\link[exams]{exams2openolat}} directly.
#' 
#' \code{exams2openolat} is a convenience interface for
#' \code{\link[exams]{exams2openolat}} with somewhat different defaults:
#' German titles/descriptions, partial credits disabled, solution switch turned off,
#' large cut value (so that the test cannot be passed), and with fancy
#' quotes turned off in verbatim R output. Finally, an RDS file is stored
#' as a by-product containing the \code{\link[exams]{xexams}} list. This
#' enables extracting and displaying specific exercises from an online test in R.
#' 
#' @param file character. A specification of a (list of) exercise files.
#' @param n integer. The number of copies to be compiled from \code{file}.
#' @param dir character. The default is either display on the screen or the
#' current working directory.
#' @param name character. A name prefix for resulting ZIP and RDS file.
#' @param maxattempts integer. The maximum attempts for one question, may also
#' be set to \code{Inf}.
#' @param cutvalue numeric. The cutvalue at which the exam is passed.
#' @param solutionswitch logical. Should the question/item solutionswitch be
#' enabled?
#' @param qti character indicating whether QTI \code{"1.2"} or \code{"2.1"}
#' (default) should be generated.
#' @param stitle,ititle,adescription,sdescription character. Descriptions
#' for various titles/descriptions. Defaults to generic German titles.
#' @param eval named list. Specifies the settings for the evaluation policy, see function
#' \code{\link{exams_eval}}. The default is not to partial credits for multiple-choice
#' exercises.
#' @param template character. The IMS QTI 2.1 template that should be used. In addition
#' to the default template this can be set to \code{"qti21test"} which uses almost
#' the same template but with a PASS variable. Thus, no \code{cutvalue} is needed
#' and the online tests just generate a SCORE.
#' @param \dots arguments passed on to \code{\link[exams]{exams2openolat}}.
#' @return A list of exams as generated by \code{\link[exams]{xexams}} is
#' returned invisibly.
#'
#' @aliases exams2openolat
#' @keywords utilities
#' @seealso olat_eval olat_exercise
#'
#' @examples
#' 
#' ## load package and enforce par(ask = FALSE)
#' library("exams")
#' options(device.ask.default = FALSE)
#' 
#' ## define an exams (= list of exercises)
#' myexam <- list(
#'   "boxplots",
#'   c("tstat", "ttest", "confint"),
#'   c("regression", "anova"),
#'   c("scatterplot", "boxhist"),
#'   "relfreq"
#' )
#' 
#' ## output directory
#' mydir <- tempdir()
#' 
#' ## generate .zip with German OpenOlat exam in temporary directory
#' ## using a few customization options
#' exams2openolat(myexam, n = 3, dir = mydir, maxattempts = 2)
#' dir(mydir)
#' 
exams2openolat <- function(file, n = 1L, dir = ".", name = "olattest",
  maxattempts = 1, cutvalue = 1000, solutionswitch = FALSE, qti = "2.1",
  stitle = "Aufgabe", ititle = "Frage", adescription = "", sdescription = "",
  eval = list(partial = FALSE, negative = FALSE), template = "qti21", ...)
{
  ## use simple ASCII quotes
  quot <- getOption("useFancyQuotes")
  options(useFancyQuotes = FALSE)
  on.exit(options(useFancyQuotes = quot))

  ## custom template without PASS variable
  if(template == "qti21test") template <- file.path(system.file(package = "c403"),
    "templates/qti21test.xml")

  ## call exams::exams2openolat
  rval <- exams::exams2openolat(file, n = n, dir = dir, name = name,
    maxattempts = maxattempts, cutvalue = cutvalue, solutionswitch = solutionswitch, qti = qti,
    stitle = stitle, ititle = ititle, adescription = adescription, sdescription = sdescription,
    eval = eval, template = template, ...)

  ## save exams list generated
  saveRDS(rval, file = file.path(dir, paste(name, ".rds", sep = "")))
  invisible(rval)
}

Try the c403 package in your browser

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

c403 documentation built on Oct. 20, 2023, 3:01 p.m.