Skip to contents

Wraps learnr::question_checkbox() and records each submitted answer in a learnrTrackR SQLite database when learnr evaluates the question.

Usage

tracked_question_checkbox(
  text,
  ...,
  question_id,
  tutorial_id,
  student_id,
  db_path,
  max_score = 1,
  context = NULL
)

Arguments

text

Question text passed to learnr::question_checkbox().

...

Answers created with learnr::answer() or learnr::answer_fn(), followed by optional arguments passed to learnr::question_checkbox().

question_id

Question identifier stored in the tracking database.

tutorial_id

Tutorial identifier stored in the tracking database.

student_id

Student identifier stored in the tracking database.

db_path

Path to the SQLite tracking database.

max_score

Maximum score stored for the question. Defaults to 1.

context

Optional context returned by setup_learnr_tracking(). If supplied, student_id, tutorial_id, and db_path are read from the context unless explicitly provided.

Value

A learnr checkbox question object with tracking metadata.

Details

The tracking implementation uses the public learnr::question_is_correct() S3 extension point. It does not use browser JavaScript interception.

Examples

if (requireNamespace("learnr", quietly = TRUE)) {
  db_path <- tempfile(fileext = ".sqlite")
  question <- tracked_question_checkbox(
    "Select all even numbers.",
    learnr::answer("2", correct = TRUE),
    learnr::answer("3"),
    learnr::answer("4", correct = TRUE),
    question_id = "q1",
    tutorial_id = "module_01",
    student_id = "student_001",
    db_path = db_path
  )
}