Computes one gradebook row per student and tutorial. Unlike
compute_scores(), this function uses registered questions from
register_questions() when available, so unanswered questions are counted in
the denominator.
Usage
gradebook(
con,
tutorial_id,
student_id = NULL,
rule = c("last", "best", "first"),
include_unregistered = TRUE
)Arguments
- con
A DBI connection.
- tutorial_id
Tutorial identifier. Required.
- student_id
Optional student identifier. If supplied, the gradebook includes that student even when they have no recorded attempts.
- rule
Scoring rule.
"last"keeps the last attempt per question,"best"keeps the attempt with the highest score, and"first"keeps the first attempt.- include_unregistered
If
TRUE, attempted questions that are not in the registered question list are included in the gradebook. IfFALSE, they are ignored when registered questions exist.
Value
A tibble with student_id, tutorial_id, score, max_score,
percent, n_questions, n_answered, n_unanswered, and completed.
Examples
db_path <- tempfile(fileext = ".sqlite")
con <- init_tracking_db(db_path, overwrite = TRUE)
register_questions(con, "module_01", c("q1", "q2"))
#> # 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 1 2026-06-24T12:…
track_attempt(con, "student_001", "module_01", "q1", "mean(x)", score = 1, max_score = 1)
gradebook(con, tutorial_id = "module_01")
#> # A tibble: 1 × 9
#> student_id tutorial_id score max_score percent n_questions n_answered
#> <chr> <chr> <dbl> <dbl> <dbl> <int> <int>
#> 1 student_001 module_01 1 2 50 2 1
#> # ℹ 2 more variables: n_unanswered <int>, completed <lgl>
DBI::dbDisconnect(con)