moodle_m2s: moodle_m2s

View source: R/moodle_m2s.R

moodle_m2sR Documentation

moodle_m2s

Description

The exams package does not support multiple-choice questions with multiple correct answers but only one allowed answer; but Moodle does. The function reads the XML file generated by exams2moodle and changes for all mchoice questions:

  • <single>...</single> to <single>true</single>, and

  • modifies the attribute fraction in the tags <answer fraction="...">...</answer>. If fraction is less than 0, it is set to zero, and if fraction is greater than 0, it is set to 100.

If the file does not end with .xml, .xml is appended. At the end, the modified XML code is stored in newfile.

Usage

moodle_m2s(file, newfile = NULL, verbose = 1)

Arguments

file

character: Moodle XML file with exercises to read from

newfile

character: Moodle XML file to write to (default: file)

verbose

integer: generate output (default: 1)

Value

invisibly the file name written to

Examples

if (interactive()) {
  newfile <- tempfile(fileext=".xml")
  moodle_m2s(system.file("xml", "klausur-test.xml", package="exams.moodle"), newfile=newfile)
  file.edit(newfile)
}

sigbertklinke/exams2moodle documentation built on July 6, 2023, 3:26 p.m.