Scope
This guide shows how to prepare a Canvas Gradebook-style CSV grade
file from learnrTrackR. The package does not call the
Canvas API. The workflow is a manual CSV import into the Canvas
Gradebook.
Instructure’s Canvas Instructor Guide states that Gradebook CSV uploads can update existing assignment grades or create new assignments, but they cannot update other Gradebook areas such as assignment status, comments, or grade posting policies.
Create a small gradebook
library(learnrTrackR)
db_path <- tempfile(fileext = ".sqlite")
con <- init_tracking_db(db_path, overwrite = TRUE)
register_students(
con,
data.frame(
student_id = c("student_001", "student_002"),
student_label = c("Student 1", "Student 2"),
email = c("student.001@example.test", "student.002@example.test"),
group_id = c("A", "A")
)
)
#> # A tibble: 2 × 5
#> student_id student_label email group_id created_at
#> <chr> <chr> <chr> <chr> <chr>
#> 1 student_001 Student 1 student.001@example.test A 2026-06-24T12:25:…
#> 2 student_002 Student 2 student.002@example.test A 2026-06-24T12:25:…
register_questions(
con,
tutorial_id = "module_01",
questions = data.frame(
question_id = c("q1", "q2"),
max_score = c(1, 1)
)
)
#> # 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_id = "student_001",
tutorial_id = "module_01",
question_id = "q1",
submitted_answer = "mean(x)",
score = 1,
max_score = 1,
require_registered_student = TRUE
)
track_attempt(
con,
student_id = "student_002",
tutorial_id = "module_01",
question_id = "q1",
submitted_answer = "sd(x)",
score = 0,
max_score = 1,
require_registered_student = TRUE
)Build the Canvas table
canvas_grades() returns a wide table with the standard
leading columns used in Canvas Gradebook CSV files and one assignment
grade column.
canvas_grades(
con,
tutorial_id = "module_01",
assignment = "Module 01 quiz"
)
#> # A tibble: 2 × 6
#> Student ID `SIS User ID` `SIS Login ID` Section `Module 01 quiz`
#> <chr> <chr> <chr> <chr> <chr> <dbl>
#> 1 Student 1 "" student_001 "" A 1
#> 2 Student 2 "" student_002 "" A 0By default, learnrTrackR writes student_id
values to the SIS User ID column. If your Canvas course
matches users with another field, change the identifier mapping.
canvas_grades(
con,
tutorial_id = "module_01",
assignment = "Module 01 quiz",
student_id_column = "SIS Login ID",
student_id_source = "email"
)
#> # A tibble: 2 × 6
#> Student ID `SIS User ID` `SIS Login ID` Section `Module 01 quiz`
#> <chr> <chr> <chr> <chr> <chr> <dbl>
#> 1 Student 1 "" "" student.001@example.te… A 1
#> 2 Student 2 "" "" student.002@example.te… A 0The default grade value is the raw score, because Canvas
assignment imports are interpreted as assignment points. If the Canvas
assignment is intended to receive a 0 to 100 value, use
grade_value = "percent".
canvas_grades(
con,
tutorial_id = "module_01",
assignment = "Module 01 percent",
grade_value = "percent"
)
#> # A tibble: 2 × 6
#> Student ID `SIS User ID` `SIS Login ID` Section `Module 01 percent`
#> <chr> <chr> <chr> <chr> <chr> <dbl>
#> 1 Student 1 "" student_001 "" A 50
#> 2 Student 2 "" student_002 "" A 0Export the CSV file
csv_path <- tempfile(fileext = ".csv")
export_canvas_grades(
con,
path = csv_path,
tutorial_id = "module_01",
assignment = "Module 01 quiz",
grade_value = "score",
digits = 2
)
readr::read_csv(csv_path, show_col_types = FALSE)
#> # A tibble: 2 × 6
#> Student ID `SIS User ID` `SIS Login ID` Section `Module 01 quiz`
#> <chr> <lgl> <chr> <lgl> <chr> <dbl>
#> 1 Student 1 NA student_001 NA A 1
#> 2 Student 2 NA student_002 NA A 0If the database contains several registered groups, use
group_id to export only one cohort:
canvas_grades(
con,
tutorial_id = "module_01",
assignment = "Module 01 quiz",
group_id = "A"
)
#> # A tibble: 2 × 6
#> Student ID `SIS User ID` `SIS Login ID` Section `Module 01 quiz`
#> <chr> <chr> <chr> <chr> <chr> <dbl>
#> 1 Student 1 "" student_001 "" A 1
#> 2 Student 2 "" student_002 "" A 0Suggested Canvas import workflow
Before importing into a real course:
- Export the current Canvas Gradebook first.
- Compare the Canvas identifier columns with the
learnrTrackRexport. - Confirm whether your course uses
ID,SIS User ID, orSIS Login ID. - Create the Canvas assignment first when possible, especially when grading periods are enabled.
- Generate a
learnrTrackRCSV with the matching identifier column. - Import the CSV in Canvas’s Gradebook import interface.
- Review the Canvas import preview before saving changes.
- Validate the workflow on a small test group before importing a full cohort.
Privacy check before import
The Canvas grade CSV should contain only the identifiers needed for matching, the section when operationally useful, and the assignment grade column. Do not include attempts, feedback, free-text answers, or pseudonymisation keys in a Canvas import file.
References
- Instructure. Accessed 2026-06-08. How do I import grades in the Gradebook? https://community.canvaslms.com/t5/Instructor-Guide/How-do-I-import-grades-in-the-Gradebook/ta-p/807
- Instructure. Accessed 2026-06-08. How do I export grades in the Gradebook? https://community.canvaslms.com/t5/Instructor-Guide/How-do-I-export-grades-in-the-Gradebook/ta-p/809