Wraps learnr::question_numeric() and records each submitted answer in a
learnrTrackR SQLite database when learnr evaluates the question.
Usage
tracked_question_numeric(
text,
...,
question_id,
tutorial_id,
student_id,
db_path,
max_score = 1,
correct = "Correct!",
incorrect = "Incorrect",
try_again = incorrect,
allow_retry = FALSE,
value = NULL,
min = NA,
max = NA,
step = NA,
options = list(),
tolerance = 1.5e-08,
context = NULL
)Arguments
- text
Question text passed to
learnr::question_numeric().- ...
Answers created with
learnr::answer()orlearnr::answer_fn(), followed by optional arguments passed tolearnr::question_numeric().- 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.- correct
Text shown by
learnrfor a correct answer.- incorrect
Text shown by
learnrfor an incorrect answer.- try_again
Text shown by
learnrfor an incorrect retry.- allow_retry
Whether
learnrshould allow retries.- value
Initial numeric value.
- min, max
Optional numeric bounds.
- step
Optional numeric step.
- options
Additional
learnrquestion options.- tolerance
Numeric tolerance used by
learnr.- 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_numeric(
"What is 2 + 2?",
learnr::answer(4, correct = TRUE),
question_id = "q1",
tutorial_id = "module_01",
student_id = "student_001",
db_path = db_path
)
}