Stores the expected questions for a tutorial in the questions table. These
registered questions are used by gradebook() to count unanswered questions
in the score denominator.
Usage
register_questions(
con,
tutorial_id,
questions,
default_max_score = 1,
overwrite = FALSE,
timestamp = Sys.time()
)Arguments
- con
A DBI connection.
- tutorial_id
Tutorial identifier.
- questions
A data frame with a required
question_idcolumn and optionalquestion_label,question_type, andmax_scorecolumns. A character vector is treated as a vector of question identifiers.- default_max_score
Score used when
max_scoreis missing. Defaults to1.- overwrite
If
TRUE, delete existing registered questions fortutorial_idbefore insertingquestions. IfFALSE, upsert the supplied questions and leave other registered questions unchanged.- timestamp
Creation timestamp for inserted rows. Defaults to
Sys.time().
Examples
db_path <- tempfile(fileext = ".sqlite")
con <- init_tracking_db(db_path, overwrite = TRUE)
register_questions(
con,
tutorial_id = "module_01",
questions = data.frame(
question_id = c("q1", "q2"),
max_score = c(1, 2)
)
)
#> # A tibble: 2 × 6
#> question_id tutorial_id question_label question_type max_score created_at
#> <chr> <chr> <chr> <chr> <dbl> <chr>
#> 1 q1 module_01 q1 NA 1 2026-06-24T12:…
#> 2 q2 module_01 q2 NA 2 2026-06-24T12:…
DBI::dbDisconnect(con)