\name{exams2ilias}
\alias{exams2ilias}
\title{Generation of Exams in ILIAS Format}
\description{
  Interface for automatic generation of exams in QTI 1.2
  for the learning management system ILIAS.
}
\usage{
  exams2ilias(file, n = 1L, nsamp = NULL, dir = ".",
    name = NULL, quiet = TRUE, edir = NULL, tdir = NULL, sdir = NULL,
    verbose = FALSE, resolution = 100, width = 4, height = 4, svg = FALSE,
    encoding  = "UTF-8", num = list(fix_num = FALSE, minvalue = NA),
    mchoice = list(maxchars = c(3, NA, 3), minvalue = NA),
    schoice = mchoice, string = NULL, cloze = NULL,
    template = "ilias",
    duration = NULL, stitle = "Exercise", ititle = "Question",
    adescription = "Please solve the following exercises.",
    sdescription = "Please answer the following question.",
    maxattempts = 0, cutvalue = 0, solutionswitch = TRUE, zip = TRUE,
    points = NULL, eval = list(partial = TRUE, negative = FALSE),
    converter = "pandoc-mathjax", xmlcollapse = TRUE,
    metasolution = FALSE, \dots)
}
\arguments{
  \item{file}{character. A specification of a (list of) exercise files.}
  \item{n}{integer. The number of copies to be compiled from \code{file}.}
  \item{nsamp}{integer. The number(s) of exercise files sampled from each
    list element of \code{file}. Sampling without replacement is used
    if possible.}
  \item{dir}{character. The default is the current working directory.}
  \item{name}{character. A name prefix for resulting exercises and ZIP file.}
  \item{quiet}{logical. Should output be suppressed when calling
    \code{\link[exams]{xweave}}?}
  \item{edir}{character specifying the path of the directory (along with its
    sub-directories) in which the files in \code{file} are stored.}
  \item{tdir}{character specifying a temporary directory.}
  \item{sdir}{character specifying a directory for storing supplements.}
  \item{verbose}{logical. Should information on progress of exam generation
    be reported?}
  \item{resolution, width, height}{numeric. Options for rendering PNG (or SVG)
    graphics passed to \code{\link[exams]{xweave}}.}
  \item{svg}{logical. Should graphics be rendered in SVG or PNG (default)?}
  \item{encoding}{character, ignored. The encoding is always assumed to be UTF-8.}
  \item{num}{function or named list applied to numerical questions.}
  \item{mchoice, schoice, string, cloze}{function or named list applied to multiple choice,
    single choice, string, and cloze questions, respectively.}
  \item{template}{character. Either the internal \code{"ilias"} / \code{"ilias_9_17"}
    template alias or a path to a custom QTI 1.2 template file. The internal default
    targets ILIAS 9.17.}
  \item{duration}{integer. Set the duration of the exam in minutes.}
  \item{stitle}{character. A title that should be used for the sections.}
  \item{ititle}{character. A title that should be used for the assessment items.}
  \item{adescription}{character. Description for the overall assessment.}
  \item{sdescription}{character. Vector of descriptions for each section.}
  \item{maxattempts}{integer. The maximum attempts for one question.}
  \item{cutvalue}{numeric. The cutvalue at which the exam is passed.}
  \item{solutionswitch}{logical. Should the question/item solutionswitch be enabled?}
  \item{zip}{logical. Should the resulting XML file be zipped?}
  \item{points}{integer. How many points should be assigned to each exercise?}
  \item{eval}{named list, specifies the settings for the evaluation policy.}
  \item{converter}{character. Argument passed on to \code{make_exercise_transform_html}.}
  \item{xmlcollapse}{logical or character. Should line breaks be collapsed in the XML
    code. If \code{TRUE} everything is collapsed with spaces.}
  \item{metasolution}{logical. Should the solution be added to the XML
    output as qtimetadata tag? This currently only works for essay-like
    ILIAS questions.}
  \item{\dots}{further arguments passed on to \code{make_exercise_transform_html}.}
}
\value{
  \code{exams2ilias} returns a list of exams as generated by \code{\link[exams]{xexams}}.

  If \code{zip} is \code{TRUE} (default), an ILIAS question pool object is generated.
}
\details{
  \code{exams2ilias} uses an ILIAS-specific QTI 1.2 rendering path inside this
  package and then rewrites the result to the question-pool layout required by ILIAS.

  Version 0.0.1 in this package targets ILIAS 9.17 and mirrors the working export
  structure that was validated against that version. In particular, the exported
  question pool XML is written as a flat collection of \code{<item>} elements
  directly below \code{<questestinterop>}, matching the layout expected by current
  ILIAS question pool imports.

  Numeric and cloze questions are exported in an ILIAS-specific item layout. For cloze
  questions, the subtypes \code{num}, \code{string}, \code{schoice}, and \code{mchoice}
  are mapped to ILIAS gap elements.
}
\seealso{
  \code{\link[exams]{xexams}}
}
\examples{
library("exams2ilias")

dir.create(mydir <- tempfile())

exams2ilias(
  system.file("exercises/lm.Rmd", package = "exams"),
  n = 1,
  dir = mydir,
  name = "lm_ilias"
)

dir(mydir)
}
\keyword{utilities}
