Found this content helpful? Log in or sign up to leave a like!
API Call to get final grade in gradebook to enable us to integrate it into SMS.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Everyone,
We use weighted assignment groups to calculate the final grade of our students.
For example in the attached image you can see two assignment groups that counts 50% each towards the final grade and then the total grade as calculated by Canvas.
We would like this total grade to be integrated into our SMS. Is there an API statement that would give me the total grade for a course?
Or how could I go about getting this information. I specifically want the "Total" grade. Not the grade for assignment groups or an individual assignment. I will get the SMS team to do the rest, but I just need to know how to extract this data from Canvas.
Thank you for your help!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The List Enrollments endpoint will provide grade information for users enrolled in the course. You will likely want to include the 'type[]' query parameter to limit the enrollments to just 'StudentEnrollment'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Assuming you're an admin on an account in Canvas:
I would pull the Grade Export report instead of trying API calls into each course.
Go to the account in question (ex. XXX.instructure.com/accounts/1 leads to the "root level" account), then go to Settings -> Reports tab and run the Grade Export report. That will save you many API calls with going to each course and then pulling grades.
I also advise a 'sanity check' to make sure the Grade Export report reflects the grade that is shown in Canvas for the gradebook.
There is an API call to grab reports.
Hopefully this meets your needs!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use GraphQL to get the grades for all the enrollments without having to loop through each one.
To see this in action, add /graphiql to the end of your dashboard URL.
You can use a query like this.
query courseGrades($courseId: ID!, $c1: String) {
course(id: $courseId) {
enrollmentsConnection(
first: 100
after: $c1
filter: {types: StudentEnrollment, states: active}
) {
nodes {
grades {
currentScore
finalScore
}
userId
user {
sisId
sortableName
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
In the variables section, you need to define courseId and c1. Change the 123456 to your actual courseID. I use c1 for my first cursor parameter in case I need pagination. To start with, it’s null. If there are additional records, you set it to the end cursor value and make the call again to get the next page of results.
{
"courseId": 123456,
"c1": null
}
Now click the execute/run button to see the output.
You can use the explorer panel on the left to customize the query to get just the fields you want. The userId is the Canvas userId and may not be as helpful as the SIS ID. I also added some filters that you may not want.
Once you have the query returning the information that you need, you can use the GraphQL API to automate the call.
Note that you will get multiple entries if someone is enrolled more than once in the course. I would check for duplicates and clean up the results before using it.