cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
speden
Community Participant

How do I get a list of all results for a particular assignment/gradebook column via API?

Jump to solution

I'm having a hard time finding a straightforward way to grab all grades for a particular grade column with the API

IE:  "Practice Test" 

I found it's easy to get the listing of all students in a course with their current/final grades, but haven't found a way to get the same (full class list) for a particular column/assignment-

Do I really need to iterate through every student in the course to pull that data out??

Thanks!

1 Solution

Accepted Solutions
ben_hudson
Community Contributor

Hi  @speden ,

I believe the answer to your question is yes, you would need to iterate through every student. From my testing I wrote this in Powershell:

$access_token="insert-token-here"
$url = "https://myschool.instructure.com/api/v1/courses/15155/assignments/155610/submissions/?access_token=$..."
$webresponse = Invoke-RestMethod -Method Get -Uri $url
$users = $webresponse.user_id
foreach($user_id in $users)
{$url2 = "https://myschool.instructure.com/api/v1/courses/15155/assignments/155610/submissions/"+"$user_id"+"?access_token=$access_token"
$webresponse2 = Invoke-RestMethod -Method Get -Uri $url2
$userScore = "$($webresponse2.user_id),$($webresponse2.grade)"
$userScore}

I had to do an API call for all of the assignments submissions, then I stored the user_id into an array. Next I looped through the array building url2 which targets specific student submissions. Finally I print out the user_id and assignment grade.

I'm still new to working with the API and don't do it very often, so someone else might have a better answer for you.

Thanks,

Ben

View solution in original post

3 Replies
kona
Community Coach
Community Coach

 @speden ‌, Due to the technical nature of this question I'm going to share it with the Canvas Developers group in the Community. They are the ones that work with this side of Canvas and should hopefully be able to help! In addition, you might consider joining the Developers group and checking out some of their other resources/information!

jperkins
Instructure
Instructure

This is a little bit hidden, but the Submissions API is what you are looking for. You can set the student and assignment parameters to what you need to get just one assignment for all users out.

Hope that helps,

ben_hudson
Community Contributor

Hi  @speden ,

I believe the answer to your question is yes, you would need to iterate through every student. From my testing I wrote this in Powershell:

$access_token="insert-token-here"
$url = "https://myschool.instructure.com/api/v1/courses/15155/assignments/155610/submissions/?access_token=$..."
$webresponse = Invoke-RestMethod -Method Get -Uri $url
$users = $webresponse.user_id
foreach($user_id in $users)
{$url2 = "https://myschool.instructure.com/api/v1/courses/15155/assignments/155610/submissions/"+"$user_id"+"?access_token=$access_token"
$webresponse2 = Invoke-RestMethod -Method Get -Uri $url2
$userScore = "$($webresponse2.user_id),$($webresponse2.grade)"
$userScore}

I had to do an API call for all of the assignments submissions, then I stored the user_id into an array. Next I looped through the array building url2 which targets specific student submissions. Finally I print out the user_id and assignment grade.

I'm still new to working with the API and don't do it very often, so someone else might have a better answer for you.

Thanks,

Ben

View solution in original post