Skip to contents

Validates a complete bank, selects questions, writes wrapper sources and an ordered manifest, and optionally renders Moodle XML plus student and teacher HTML/PDF documents. Relative question paths are resolved from index_file. Relative output directories are also resolved from the index's folder.

Usage

build_quiz(
  index_file,
  title = "Question Bank Quiz",
  ids = NULL,
  n = NULL,
  seed = NULL,
  topics = NULL,
  difficulties = NULL,
  category = "Question bank",
  replicates = 1,
  generated_dir = NULL,
  output_dir = NULL,
  render = TRUE,
  shuffle = FALSE,
  toc = TRUE
)

build_question_bank(
  index_file,
  title = "Question Bank Quiz",
  ids = NULL,
  n = NULL,
  seed = NULL,
  topics = NULL,
  difficulties = NULL,
  category = "Question bank",
  replicates = 1,
  generated_dir = NULL,
  output_dir = NULL,
  render = TRUE,
  shuffle = FALSE,
  toc = TRUE
)

Arguments

index_file

Path to the authoritative question-index CSV. This is deliberately required; see vignette("getting-started") for the design rationale and create_question_index() for folder-based setup.

title

Quiz title.

ids

Optional ordered vector of question IDs.

n

Optional topic-stratified sample size. Do not combine with ids.

seed

Optional seed for reproducible selection and shuffling.

topics, difficulties

Optional filters applied before sampling.

category

Moodle question-bank category.

replicates

Number of Moodle variants requested from moodlequiz.

generated_dir

Folder for generated .qmd and .Rmd wrappers. NULL uses generated next to the index.

output_dir

Folder for the manifest and rendered outputs. NULL uses output next to the index.

render

If FALSE, create and validate sources without running Quarto, Pandoc, or LaTeX.

shuffle

Whether to shuffle the selected question order. When FALSE, questions follow the supplied ids or topics order, or index order when neither is supplied.

toc

Whether generated student and teacher HTML/PDF documents should include a table of contents.

Value

Invisibly, the selected rows of the question index.

Examples

root <- tempfile("ecosanctuary-example-")
dir.create(root)
selected <- build_quiz(
  index_file = example_question_index(),
  ids = "example-numeric",
  generated_dir = file.path(root, "generated"),
  output_dir = file.path(root, "output"),
  render = FALSE
)
#> Selected questions: example-numeric
selected$id
#> [1] "example-numeric"