Skip to contents

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_id column and optional question_label, question_type, and max_score columns. A character vector is treated as a vector of question identifiers.

default_max_score

Score used when max_score is missing. Defaults to 1.

overwrite

If TRUE, delete existing registered questions for tutorial_id before inserting questions. If FALSE, upsert the supplied questions and leave other registered questions unchanged.

timestamp

Creation timestamp for inserted rows. Defaults to Sys.time().

Value

A tibble of registered questions.

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)