Skip to contents

Builds a Canvas-style Gradebook CSV table with the standard leading columns Student, ID, SIS User ID, SIS Login ID, Section, and one assignment grade column. By default, learnrTrackR student identifiers are exported to SIS User ID and raw gradebook scores are exported as points.

Usage

canvas_grades(
  con,
  tutorial_id,
  rule = c("last", "best", "first"),
  assignment = NULL,
  student_id_column = "SIS User ID",
  student_id_source = "student_id",
  grade_value = c("score", "percent"),
  digits = 2,
  include_unregistered = TRUE,
  group_id = NULL,
  section = c("group_id", "blank")
)

Arguments

con

A DBI connection.

tutorial_id

Tutorial identifier. Required.

rule

Scoring rule passed to gradebook().

assignment

Column name for the Canvas assignment. Defaults to tutorial_id.

student_id_column

Canvas identifier column to populate. Use "SIS User ID", "SIS Login ID", or "ID".

student_id_source

Student metadata column used to populate student_id_column. Use "student_id", "student_label", or "email".

grade_value

Which gradebook value to export. Use "score" for raw points or "percent" for a 0-100 grade.

digits

Number of decimal places used to round exported grades. Use NULL to disable rounding.

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 in that registered group are exported.

section

Use "group_id" to copy registered groups to the Canvas Section column, or "blank" to leave the section column empty.

Value

A tibble with one row per student.

Details

The exported identifiers must match the identifiers used by the target Canvas course. When in doubt, export the current Canvas Gradebook first and compare the identifier columns before importing.

Examples

db_path <- tempfile(fileext = ".sqlite")
con <- init_tracking_db(db_path, overwrite = TRUE)
register_students(con, data.frame(student_id = "student_001", group_id = "A"))
#> # A tibble: 1 × 5
#>   student_id  student_label email group_id created_at          
#>   <chr>       <chr>         <chr> <chr>    <chr>               
#> 1 student_001 student_001   NA    A        2026-06-24T12:25:11Z
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)
canvas_grades(con, tutorial_id = "module_01")
#> # A tibble: 1 × 6
#>   Student     ID    `SIS User ID` `SIS Login ID` Section module_01
#>   <chr>       <chr> <chr>         <chr>          <chr>       <dbl>
#> 1 student_001 ""    student_001   ""             A               1
DBI::dbDisconnect(con)