Quiz Submissions API: are inactive enrollments (no longer) included?

Jump to solution
saelterman
Community Novice

Hi,

Many months ago I started a project to extract quiz results by question and by student. I am quite confident I got a Postman collection working that gave me all the quiz submission events for a particular quiz in a particular course.

There would be quite a bit of work to determine if the event was the final selection a student made for a question and related minutiae, but it seemed this was the way to go.

Then I got sidetracked and just now returned to the project. The API call I had before (GET request URL below) returns a status code of 200, but no submissions are included at all. The UI shows submissions for that quiz in that course, though they all belong to now inactive enrollments.

Is there perhaps a query string parameter I am overlooking to include results from inactive enrollments?

My GET request:

https://troy.instructure.com/api/v1/courses/{{CourseID}}/quizzes/{{QuizID}}/submissions?include=subm... 

JSON response:

{
"quiz_submissions": [],
"submissions": [],
"meta": {
"primaryCollection": "quiz_submissions"
}
}

https://troy.instructure.com/api/v1/courses/

Labels (1)
1 Solution
James
Community Champion

 @saelterman ,

See the Canvas Enrollment Status Comparison pdf

Have you removed these enrollments from the course (deleted them)? If so, then you're not going to be able to get anything. If we delete them, we have to re-add them to get anything. 

If they are inactive, then it says you can see previously submitted assignments. That means that there is an option to get that information. The gradebook fetches the data through the API, so it is possible.

We don't mark our students as inactive, we either delete them or conclude them depending on whether it's within the first 10 days of the course or after that. That means it's going to be a little challenging for me to test.

I have a suspicion about what is going on. In the new gradebook, when I toggle the "Show inactive enrollments", Canvas makes a call to an internal location (not an API) to get the list of users. However, all of my development work with the gradebook was done with the old one and when I toggle it in the old gradebook, it makes a call to get a list of users that should be included and then it specifies the individual users using student_ids[] multiple times rather than using student_ids[]=all.

The call to get the list of users looks like this:

GET /api/v1/courses/2513281/users

?enrollment_state[]=active&enrollment_state[]=invited&enrollment_state[]=inactive&enrollment_type[]=student&enrollment_type[]=student_view

&include[]=avatar_url&include[]=group_ids&include[]=enrollments&per_page=100

Then, it takes a list of those student IDs and make a call to the submissions API (I've replaced the actual IDs by {id#}

GET /api/v1/courses/2513281/students/submissions?grouped=1
&student_ids[]={id1}&student_ids[]={id2}&student_ids[]={id3} ...
&response_fields[]=id&response_fields[]=user_id&response_fields[]=url
&response_fields[]=score&response_fields[]=grade&response_fields[]=submission_type
&response_fields[]=submitted_at&response_fields[]=assignment_id
&response_fields[]=grade_matches_current_submission
&response_fields[]=attachments&response_fields[]=late
&response_fields[]=workflow_state&response_fields[]=excused
&response_fields[]=cached_due_date&exclude_response_fields[]=preview_url

I include all of the parameters because it was helpful for me to minimize the information that I needed. In particular, the exclude_response_fields[] can help cut down on descriptions on assignments to save the information transferred.

Based on that ...

Instead of using student_ids[]=all have you tried using student_ids[]=123&student_ids[]=456 where 123 and 456 are the Canvas IDs of some students who are inactive?

I'm using the documentation from List submissions for multiple assignments (just so we're on the same page)

View solution in original post

0 Likes