Wraps learnr::question_radio() and records each submitted answer in a
learnrTrackR SQLite database when learnr evaluates the question. This
function is intended for small prototypes and local teaching workflows.
Usage
tracked_question_radio(
text,
...,
question_id,
tutorial_id,
student_id,
db_path,
max_score = 1,
context = NULL
)Arguments
- text
Question text passed to
learnr::question_radio().- ...
Answers created with
learnr::answer(), followed by optional arguments passed tolearnr::question_radio().- 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, anddb_pathare read from the context unless explicitly provided.
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_radio(
"What is 2 + 2?",
learnr::answer("3"),
learnr::answer("4", correct = TRUE),
question_id = "q1",
tutorial_id = "module_01",
student_id = "student_001",
db_path = db_path
)
}