cancel
Showing results for 
Search instead for 
Did you mean: 
Community Member

Canvas API Quiz Events Inconsistent, At Best.

Jump to solution

I'm having some trouble querying the quiz events of the Canvas API. For example, when I use a simple python script to get the events:

api_target = '{}/api/v1/courses/{}/quizzes/{}/submissions/{}/events'

# Builds a dictionary containing events linked to student canvas ids
quiz_events = {}
for submission_id, user_id in self.submissions[0]:
   events = requests.put(api_target.format(self.url, self.class_id, self.quiz_id, submission_id),
                         headers=self.header)
   quiz_events[user_id] = events.json()

I always end up with data that does not match the "view log" section of quiz results. Notably, a student who left the page multiple times shows up as not leaving the page once in the API result.

Is there a way to rebuild the on the API end so that the data lines up properly with the "View Log"? Or is there something else I can do to get more consistent results? Because as of now this is leaving a project I'm working on impossible.

EDIT: THE PROBLEM WAS A SMALLER AMOUNT OF DATA BEING QUERYED, FIX:

api_target = '{}/api/v1/courses/{}/quizzes/{}/submissions/{}/events?per_page=50'
Tags (3)
1 Solution

Accepted Solutions
Learner II

In case there are more than 50 events, you also need check the pagination information in the link header (Pagination - Canvas LMS REST API Documentation ).

View solution in original post

2 Replies
Community Coach
Community Coach

Hi mbyrd2

I can't even spell API, so I am going to share your question with the https://community.canvaslms.com/groups/canvas-developers?sr=search&searchId=222560e6-079c-4217-9752-...‌ group, where there are folks who can not only spell, but also know coding.

Kelley

Learner II

In case there are more than 50 events, you also need check the pagination information in the link header (Pagination - Canvas LMS REST API Documentation ).

View solution in original post