Builds the data tables used by generate_teacher_report() without rendering
an HTML file. This is useful for inspection, testing, and custom reports.
Usage
teacher_report_data(
con,
tutorial_id,
rule = c("last", "best", "first"),
include_unregistered = TRUE,
group_id = NULL,
max_mean_percent = 60,
max_student_percent = 60,
min_students = 1,
min_attempts = 1
)Arguments
- con
A DBI connection.
- tutorial_id
Tutorial identifier. Required.
- rule
Scoring rule passed to
summarise_questions()andsummarise_students().- include_unregistered
If
TRUE, include attempted questions not registered withregister_questions().- group_id
Optional registered student group identifier.
- max_mean_percent
Maximum mean question percent used by
detect_difficult_questions().- max_student_percent
Maximum student percent used by
detect_stalled_students().- min_students
Minimum student count for difficult-question detection.
- min_attempts
Minimum attempt count for difficult-question and stalled-student detection.
Value
A list containing report metadata and tibbles named summary,
questions, students, difficult_questions, and stalled_students.
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)
teacher_report_data(con, "module_01")
#> $tutorial_id
#> [1] "module_01"
#>
#> $group_id
#> NULL
#>
#> $rule
#> [1] "last"
#>
#> $generated_at
#> [1] "2026-06-24T12:25:20Z"
#>
#> $questions
#> # A tibble: 2 × 14
#> tutorial_id question_id question_label question_type max_score
#> <chr> <chr> <chr> <chr> <dbl>
#> 1 module_01 q1 q1 NA 1
#> 2 module_01 q2 q2 NA 1
#> # ℹ 9 more variables: n_possible_students <int>, n_students <int>,
#> # n_attempts <int>, n_answered <int>, n_full_credit <int>, mean_score <dbl>,
#> # mean_percent <dbl>, full_credit_rate <dbl>, mean_attempts_per_student <dbl>
#>
#> $students
#> # A tibble: 1 × 15
#> student_id student_label email group_id tutorial_id score max_score percent
#> <chr> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl>
#> 1 student_001 NA NA NA module_01 1 2 50
#> # ℹ 7 more variables: n_questions <int>, n_answered <int>, n_unanswered <int>,
#> # completed <lgl>, n_attempts <int>, last_activity <chr>, status <chr>
#>
#> $difficult_questions
#> # A tibble: 0 × 14
#> # ℹ 14 variables: tutorial_id <chr>, question_id <chr>, question_label <chr>,
#> # question_type <chr>, max_score <dbl>, n_possible_students <int>,
#> # n_students <int>, n_attempts <int>, n_answered <int>, n_full_credit <int>,
#> # mean_score <dbl>, mean_percent <dbl>, full_credit_rate <dbl>,
#> # mean_attempts_per_student <dbl>
#>
#> $stalled_students
#> # A tibble: 1 × 15
#> student_id student_label email group_id tutorial_id score max_score percent
#> <chr> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl>
#> 1 student_001 NA NA NA module_01 1 2 50
#> # ℹ 7 more variables: n_questions <int>, n_answered <int>, n_unanswered <int>,
#> # completed <lgl>, n_attempts <int>, last_activity <chr>, status <chr>
#>
#> $summary
#> # A tibble: 10 × 2
#> metric value
#> <chr> <chr>
#> 1 tutorial_id "module_01"
#> 2 group_id ""
#> 3 scoring_rule "last"
#> 4 n_students "1"
#> 5 n_completed "0"
#> 6 completion_rate "0"
#> 7 mean_percent "50"
#> 8 n_questions "2"
#> 9 n_difficult_questions "0"
#> 10 n_stalled_students "1"
#>
DBI::dbDisconnect(con)