Inconsistent Grade Change Event Results Through the API

AaronWong
Community Explorer

Hello -

 

I'm new to the Canvas API, and I wanted to learn it, so I thought I'd pick an easy target: Get the grade change log and recreate the gradebook. Fast forward one week, and I'm starting to go crazy trying to figure out what's happening because I'm getting an inconsistent result depending on my approach, and it's not making any sense.

 

Approach #1: By Student and Assignment

  1. Get a list of all students (api/v1/courses/{courseID}/enrollments?type[]=StudentEnrollment)
  2. Get a list of all assignments (api/v1/courses/{courseID}/assignments?per_page=100)
  3. Get all grade change events for the course by student and assignment (/audit/grade_change?course_id={courseID}&assignment_id={assignmentID}&student_id={studentID}&per_page=100)

Runs extremely slowly (as expected) and recreates the gradebook successfully after yielding 10743 entries for the particular class I selected to try this on.

 

Approach #2: By Student

  1. Get a list of all students (api/v1/courses/{courseID}/enrollments?type[]=StudentEnrollment)
  2. Get all grade change events for the course by student (api/v1//audit/grade_change?course_id={courseID}&student_id={studentID}&per_page=100)

Runs slowly (but not as bad) and recreates the gradebook successfully after yielding 10743 entries.

 

Approach #3: By Course

  1. Get all grade change events for the course (api/v1/audit/grade_change?course_id={courseID})

Runs reasonably quickly, but only yields 10710 entries. And there is no rhyme or reason to the missing 33 entries that I can find. The missing entries seem to be randomly scattered throughout, not linked to any one student or assignment, or missing the last page of changes, any other pattern that I can identify.

I tried it with another course, and got 6951 entries in the first two approaches and 6939 for the third one (missing 12 entries). But when I did it with a smaller course, I got a consistent 751 items across the methods. Is there something happening with these larger requests maybe?

Here is a link to the Python code on Github to see if the problem replicates elsewhere. Obviously, you'll need to change the institution, key, and course number. 

https://github.com/AaronWongNSC/CanvasAPIHelp

Thanks for any insight you can provide!

Labels (3)