[ARCHIVED] Individual Quiz Answers - Canvas API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Our campus is trying to compile quiz response data for our annual review process. In trying to compile this data I came across this API call which gives me all the data I need for a given quiz:
This call displays quiz_id, user_id, question_id, answer_id, and whether or not that answer was correct for every student who took the quiz and every question they answered.
To extract this data systematically across a large number of quizzes we created a short python script using the canvasapi library. However, we are having trouble getting the answers students gave to individual questions. It appears as though in the submission_questions endpoint the individual answer data does not exist as described in this github thread. That thread is now five years old though so I was wondering if anyone has found another solution
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can try a requests based extract. The code below worked for me
Just substitute in your URL, KEY and the ID numbers
import os
import requests
import json
URL1 = r'https://XXXXXXX.instructure.com/api/v1/courses'
course_id = 99999
assignment_id = 99999
url2 = f'{URL1}/{course_id}/assignments/{assignment_id}/submissions?include[]=submission_history'
header = {'Authorization': 'Bearer ' + '%s' % KEY}
r = requests.get(url2, headers= header)
print('Request status code',r.status_code)
a = r.json()
for x in a:
print(x['id'],x['user_id'])
print(x['submission_history'])
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.