Skip to contents

Writes the output of canvas_grades() to a CSV file with readr::write_csv().

Usage

export_canvas_grades(
  con,
  path,
  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.

path

Output CSV path.

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

The output path, invisibly.

Examples

db_path <- tempfile(fileext = ".sqlite")
csv_path <- tempfile(fileext = ".csv")
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:14Z
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)
export_canvas_grades(con, csv_path, tutorial_id = "module_01")
DBI::dbDisconnect(con)