| Title: | R Markdown format for 'Moodle' XML cloze quizzes |
| Version: | 0.2.0 |
| 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. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Language: | es |
| RoxygenNote: | 7.3.3 |
| Imports: | rlang, rmarkdown, bookdown, xfun, yaml |
| URL: | https://github.com/numbats/moodlequiz, https://numbats.github.io/moodlequiz/ |
| BugReports: | https://github.com/numbats/moodlequiz/issues |
| Suggests: | knitr, testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| NeedsCompilation: | no |
| Packaged: | 2025-12-01 13:58:59 UTC; mitchell |
| Author: | Mitchell O'Hara-Wild
|
| Maintainer: | Mitchell O'Hara-Wild <mail@mitchelloharawild.com> |
| Repository: | CRAN |
| Date/Publication: | 2025-12-06 12:10:07 UTC |
Create a set of choices for single or multiple choice questions
Description
Create a set of choices for single or multiple choice questions
Usage
choices(options, answer)
Arguments
options |
A character vector of selectable choices |
answer |
A character vector of the correct answers |
Value
A named vector of choices suitable for use with cloze_singlechoice() and cloze_multichoice()
See Also
cloze_singlechoice(), cloze_multichoice()
Generate Cloze-Type Questions for Moodle
Description
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.
Usage
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, ...)
Arguments
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 |
Value
A character string containing the Moodle-compatible XML or inline text for the specified cloze question(s).
Functions
-
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.
Examples
# 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
R Markdown format for Moodle XML quizzes
Description
Provides an alternative interface to working with the exams package for producing Moodle questions any type.
Usage
moodlequiz(
replicates = 1L,
self_contained = TRUE,
extra_dependencies = NULL,
theme = NULL,
includes = NULL,
lib_dir = NULL,
md_extensions = NULL,
pandoc_args = NULL,
...
)
Arguments
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 |
Value
R Markdown output format to pass to rmarkdown::render()
Generate Moodle Quiz XML Output for R Markdown
Description
This function is intended for internal generation of the XML output.
It is strongly recommended that you use the [moodlequiz::moodlequiz()]
output format, which provides a higher-level interface for creating
Moodle-compatible quizzes.
Usage
moodlequiz_xml(
replicate = "",
self_contained = TRUE,
extra_dependencies = NULL,
theme = NULL,
includes = NULL,
lib_dir = NULL,
md_extensions = NULL,
pandoc_args = NULL,
...
)
Arguments
replicate |
A character string specifying the how many replications of the quiz should be produced. |
self_contained |
Logical. If |
extra_dependencies |
Additional dependencies to include in the output. These can be
specified as an |
theme |
A character string specifying the theme for the output. This can be a standard theme name or a custom CSS file. |
includes |
Additional content to include in the output. This should be a list of
named elements, such as |
lib_dir |
Directory to copy library files for the output. If |
md_extensions |
A character string specifying Markdown extensions to be passed to Pandoc. |
pandoc_args |
Additional arguments to pass to Pandoc. |
... |
Additional arguments passed to |
Value
An R Markdown output format object.