| Title: | R Markdown format for 'Moodle' XML cloze quizzes |
|---|---|
| Description: | Enables the creation of 'Moodle' quiz questions using literate programming with R Markdown. This makes it easy to quickly create a quiz that can be randomly replicated with new datasets, questions, and options for answers. |
| Authors: | Mitchell O'Hara-Wild [aut, cre] (ORCID: <https://orcid.org/0000-0002-3813-7155>), Emi Tanaka [aut] (ORCID: <https://orcid.org/0000-0002-1455-259X>) |
| Maintainer: | Mitchell O'Hara-Wild <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.1.9000 |
| Built: | 2026-05-10 09:05:33 UTC |
| Source: | https://github.com/numbats/moodlequiz |
Create a set of choices for single or multiple choice questions
choices(options, answer)choices(options, answer)
options |
A character vector of selectable choices |
answer |
A character vector of the correct answers |
A named vector of choices suitable for use with cloze_singlechoice() and cloze_multichoice()
cloze_singlechoice(), cloze_multichoice()
These functions create cloze-type questions for Moodle quizzes, designed for use with inline R code chunks in an R Markdown document formatted with the moodlequiz::moodlequiz output format.
cloze_shortanswer( options, weight = max(options), feedback = "", case_sensitive = FALSE ) cloze_multichoice( options, weight = max(options), feedback = "", type = c("vertical", "horizontal"), shuffle = FALSE ) cloze_singlechoice( options, weight = max(options), feedback = "", type = c("dropdown", "vertical", "horizontal"), shuffle = FALSE ) cloze_numerical(answer, weight = 1, tolerance = 0, feedback = "") cloze(x, ...)cloze_shortanswer( options, weight = max(options), feedback = "", case_sensitive = FALSE ) cloze_multichoice( options, weight = max(options), feedback = "", type = c("vertical", "horizontal"), shuffle = FALSE ) cloze_singlechoice( options, weight = max(options), feedback = "", type = c("dropdown", "vertical", "horizontal"), shuffle = FALSE ) cloze_numerical(answer, weight = 1, tolerance = 0, feedback = "") cloze(x, ...)
options |
A named vector of answer options. For single/multiple choice questions the |
weight |
A numeric value specifying the weight for the question. Defaults to the highest weight in |
feedback |
A character vector providing feedback for answers. |
case_sensitive |
Logical. For |
type |
A character string specifying the presentation style of the options. For |
shuffle |
Logical. For |
answer |
A numeric value specifying the correct numerical answer(s). |
tolerance |
A numeric value specifying the acceptable range of deviation for |
x |
For |
... |
Additional arguments passed to other |
A character string containing the Moodle-compatible XML or inline text for the specified cloze question(s).
cloze_shortanswer(): Creates a short-answer question where the student provides a text response.
cloze_singlechoice(): Generates a single-choice question where students select one correct answer from a list.
cloze_multichoice(): Creates a multiple-choice question where students can select one or more correct answers.
cloze_numerical(): Generates a numerical question where students input a numeric response with optional tolerance.
cloze(): Automatic question types based on the class of the answers.
# Short-answer question: Where is the best coffee? cloze_shortanswer( options = c("Melbourne" = 1), case_sensitive = FALSE ) # Multiple-choice question: Select all lower-case answers cloze_multichoice( options = c("a" = 1, "F" = 0, "g" = 1, "V" = 0, "K" = 0), type = "vertical" ) # Where is Melbourne? cloze_singlechoice( choices( c("New South Wales", "Victoria", "Queensland", "Western Australia", "South Australia", "Tasmania", "Australian Capital Territory", "Northern Territory"), "Victoria" ), type = "dropdown" ) # Numerical question: Pick a number between 1 and 10 cloze_numerical( answer = 5.5, tolerance = 4.5 ) # Automatic cloze questions cloze(42) # Numerical cloze("Australia") # Short answer cloze("rep_len", c("rep", "rep.int", "rep_len", "replicate")) # Single choice cloze(c("A", "B", "C"), LETTERS) # Multiple choice# Short-answer question: Where is the best coffee? cloze_shortanswer( options = c("Melbourne" = 1), case_sensitive = FALSE ) # Multiple-choice question: Select all lower-case answers cloze_multichoice( options = c("a" = 1, "F" = 0, "g" = 1, "V" = 0, "K" = 0), type = "vertical" ) # Where is Melbourne? cloze_singlechoice( choices( c("New South Wales", "Victoria", "Queensland", "Western Australia", "South Australia", "Tasmania", "Australian Capital Territory", "Northern Territory"), "Victoria" ), type = "dropdown" ) # Numerical question: Pick a number between 1 and 10 cloze_numerical( answer = 5.5, tolerance = 4.5 ) # Automatic cloze questions cloze(42) # Numerical cloze("Australia") # Short answer cloze("rep_len", c("rep", "rep.int", "rep_len", "replicate")) # Single choice cloze(c("A", "B", "C"), LETTERS) # Multiple choice
Provides an alternative interface to working with the exams package for producing Moodle questions any type.
moodlequiz( replicates = 1L, self_contained = TRUE, extra_dependencies = NULL, theme = NULL, includes = NULL, lib_dir = NULL, md_extensions = NULL, pandoc_args = NULL, ... )moodlequiz( replicates = 1L, self_contained = TRUE, extra_dependencies = NULL, theme = NULL, includes = NULL, lib_dir = NULL, md_extensions = NULL, pandoc_args = NULL, ... )
replicates |
The number of times the questions are rendered, useful for producing multiple versions of the same quiz with different random samples. To keep identify replicates of questions for random importation into Moodle we recommend organising the materials into categories using top level headers. |
self_contained |
Produce a standalone HTML file with no external dependencies, using data: URIs to incorporate the contents of linked scripts, stylesheets, images, and videos. Note that even for self contained documents MathJax is still loaded externally (this is necessary because of its size). |
extra_dependencies |
Extra dependencies as a list of the
|
theme |
One of the following:
|
includes |
Named list of additional content to include within the
document (typically created using the |
lib_dir |
Directory to copy dependent HTML libraries (e.g. jquery,
bootstrap, etc.) into. By default this will be the name of the document with
|
md_extensions |
Markdown extensions to be added or removed from the
default definition of R Markdown. See the |
pandoc_args |
Additional command line options to pass to pandoc |
... |
Additional function arguments to pass to the base R Markdown HTML
output formatter |
R Markdown output format to pass to rmarkdown::render()