Learn R Programming

exams.forge (version 1.0.10)

moodle_m2s: Moodle Multiple-Choice

Description

The exams package does not support multiple-choice questions with multiple correct answers; it only allows for one answer to be chosen. However, Moodle does support such questions. The function reads the XML file generated by exams.forge and makes 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, then .xml is appended. At the end, the modified XML code is stored in newfile.

Usage

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

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

Value

Invisibly, the written file name.

Arguments

file

character: Moodle XML file with exercises to read from

newfile

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

verbose

integer: output generation (default: 1)

Examples

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

Run the code above in your browser using DataLab