Skip to contents

Computes the tables used by the teacher dashboard without launching Shiny. This function is useful for testing, reporting, and non-interactive summaries.

Usage

dashboard_data(
  con,
  tutorial_id = NULL,
  rule = c("last", "best", "first"),
  include_unregistered = TRUE,
  group_id = NULL
)

Arguments

con

A DBI connection.

tutorial_id

Optional tutorial identifier. If NULL, the first available tutorial found in the database is used.

rule

Scoring rule passed to gradebook().

include_unregistered

If TRUE, include attempted questions that were not registered with register_questions().

group_id

Optional registered student group identifier. If supplied, only students registered in that group are included.

Value

A list with tutorials, groups, selected tutorial id, selected group id, summary, student summary, gradebook, question summary, attempts, and Moodle-ready grades.

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)
dashboard_data(con, tutorial_id = "module_01")
#> $tutorials
#> # A tibble: 1 × 1
#>   tutorial_id
#>   <chr>      
#> 1 module_01  
#> 
#> $groups
#> # A tibble: 0 × 1
#> # ℹ 1 variable: group_id <chr>
#> 
#> $tutorial_id
#> [1] "module_01"
#> 
#> $group_id
#> NULL
#> 
#> $summary
#> # A tibble: 9 × 2
#>   metric              value     
#>   <chr>               <chr>     
#> 1 Tutorial            module_01 
#> 2 Group               All groups
#> 3 Students            1         
#> 4 Attempts            1         
#> 5 Questions           2         
#> 6 Completed           0         
#> 7 Completion rate (%) 0.0       
#> 8 Mean percent        50.0      
#> 9 Median percent      50.0      
#> 
#> $students
#> # A tibble: 1 × 6
#>   student_id  student_label email group_id n_attempts has_attempts
#>   <chr>       <chr>         <chr> <chr>         <int> <lgl>       
#> 1 student_001 NA            NA    NA                1 TRUE        
#> 
#> $gradebook
#> # A tibble: 1 × 12
#>   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
#> # ℹ 4 more variables: n_questions <int>, n_answered <int>, n_unanswered <int>,
#> #   completed <lgl>
#> 
#> $questions
#> # A tibble: 2 × 9
#>   question_id question_label question_type max_score n_attempts n_students
#>   <chr>       <chr>          <chr>             <dbl>      <int>      <int>
#> 1 q1          q1             NA                    1          1          1
#> 2 q2          q2             NA                    1          0          0
#> # ℹ 3 more variables: n_answered <int>, mean_score <dbl>, mean_percent <dbl>
#> 
#> $attempts
#> # A tibble: 1 × 15
#>   student_id  student_label email group_id attempt_id session_id     tutorial_id
#>   <chr>       <chr>         <chr> <chr>         <int> <chr>          <chr>      
#> 1 student_001 NA            NA    NA                1 session_stude… module_01  
#> # ℹ 8 more variables: question_id <chr>, attempt_number <int>,
#> #   submitted_answer <chr>, grade_status <chr>, score <dbl>, max_score <dbl>,
#> #   feedback <chr>, timestamp <chr>
#> 
#> $moodle_grades
#> # A tibble: 1 × 2
#>   useridnumber module_01
#>   <chr>            <dbl>
#> 1 student_001         50
#> 
DBI::dbDisconnect(con)