The Instructure Community will enter a read-only state on November 22, 2025 as we prepare to migrate to our new Community platform in early December.
Read our blog post for more info about this change.
Found this content helpful? Log in or sign up to leave a like!
I am exploring the APIs to fetch Total score for every Module in a Course for all the Students. Please refer the attached screen print. I was able to get the scores for each assignment/quizzes using /submissions API and the final score for the whole course through /enrollments but finding difficulty to get the module total/average score highlighted in the pic.
Could anyone please advise on this?
GET /api/v1/courses/:course_id/assignments/:assignment_id/submissions
Solved! Go to Solution.
As @chriscas mentioned, there is no intrinsic notion of a module score, this is all done through filtering. The assignment information does not contain any information about which module(s) it is in. The modules and modules items contain information about which assignments it contains. Scores are tied to submissions that are tied to assignments and users, but not modules.
Since modules don't directly factor into the grades, I would not worry about following the rules for dropping scores. If you're looking for the lowest grade in a module, it may not be the lowest grade in the assignment group. Calculating which assignments are dropped is not trivial. Just realize that it isn't going to be perfect, but if you're analyzing at the module level, you may not want to consider dropped grades anyway.
You would have to get a list of the module items for the module you're concerned with and all of the grades and then do the calculations.
When you view the gradebook, several API calls are made. It then uses those items to filter.
It is important to note that an assignment may belong to more than one module. The Google Apps Script (GAS) that @JaredWall would be a convenient way of listing the scores for each of the modules, but the GAS would need to do the module calculations internally. If that's the route you were going, I would prefer some other langauge and then output the results. I mostly program in JavaScript and that's what GAS uses and I've written (and shared) some GAS sheets with people, so I guess it depends on your audience. Is this something that the teacher is going to use or something that someone is doing across multiple courses? If it's more than a single teacher, I would probably program it in something other than GAS.
Some of that information can be obtained using GraphQL. For example, I could combine the assignment information and submission information into one request. That would leave me the module information and user information as separate requests.
To test this out, add /graphiql to your Dashboard URL. Paste this code in the middle section.
query submissionsWithModulesInfo($courseId: ID!, $c1: String, $c2: String) {
course(id: $courseId) {
_id
name
courseCode
assignmentsConnection(first: 100, after: $c1) {
nodes {
_id
title
modules {
_id
}
submissionsConnection(
filter: {enrollmentTypes: StudentEnrollment}
first: 100
after: $c2
) {
nodes {
score
userId
}
pageInfo {
hasNextPage
endCursor
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
Then expand the variables section at the bottom and add this, changing the courseId to match one of yours instead of my sandbox.
{
"courseId": 896851,
"c1": null,
"c2": null
}
Then click the run button.
On the right panel, you'll get the ouput. There is some information about the course (ID, name, and code) followed by an assignmentsConnection section with a nodes array. There is one item for each assignment that contains the Canvas assignment ID, title, and which modules it belongs to.
Then there is a submissionsConnection with a nodes array that contains the score and user ID information for each submission for that assignment.
You still have to filter all that information.
The c1 and c2 variables are for pagination. If you have more than 100 assignments in a course, you will need to take the endCursor for the assignments pageInfo and place it into c1 and make the call again. If you have more than 100 submissions (students) in a course, you will need to worry about pagination with the c2 variable.
I normally try to keep my pagination variables to just one, which makes it easier to iterate through, but I don't know how big your classes are or how many assignments you have.
I realize that you could supply the module name along with the module IDs. You could also return user information instead of just user_id. That is, you could combine all four requests into a single request using GraphQL. I find the requests faster to fetch the user information and module information once rather than repeating it for each assignment or submission, but it lowers the complexity of the program to get it all at once.
Once you have it working correctly, then you can automate the GraphQL using the REST API.
@JeffCampbell @Chris_Hofer any suggestions here please
I have not worked with the API so would be practically useless for this question 🙃. I cannot speak for Chris. However, you might consider posting in the Developer Group. You might find individuals there that would be helpful.
Hi @NitinN,
I'm not aware of an API that would return module scores. Essentially those are a filter on the gradebook, and are probably calculated on the fly, but like what happens in a spreadsheet. I think you'd need to get all grades then do some manual scoring, but also be aware of all the complexities that may be involved depending on your goal and course setup (dropped scores from assignment groups, for example).
-Chris
Would be easier to build this API pull using something like Google Apps Scripts in a Google Sheet. Then you could have the script create the scores from the data and return the module scores along with the individual assignment scores. Or, if you have the ability, pull the data into the Google Sheet and then just have formulas generate the module scores from the returned data.
As @chriscas mentioned, there is no intrinsic notion of a module score, this is all done through filtering. The assignment information does not contain any information about which module(s) it is in. The modules and modules items contain information about which assignments it contains. Scores are tied to submissions that are tied to assignments and users, but not modules.
Since modules don't directly factor into the grades, I would not worry about following the rules for dropping scores. If you're looking for the lowest grade in a module, it may not be the lowest grade in the assignment group. Calculating which assignments are dropped is not trivial. Just realize that it isn't going to be perfect, but if you're analyzing at the module level, you may not want to consider dropped grades anyway.
You would have to get a list of the module items for the module you're concerned with and all of the grades and then do the calculations.
When you view the gradebook, several API calls are made. It then uses those items to filter.
It is important to note that an assignment may belong to more than one module. The Google Apps Script (GAS) that @JaredWall would be a convenient way of listing the scores for each of the modules, but the GAS would need to do the module calculations internally. If that's the route you were going, I would prefer some other langauge and then output the results. I mostly program in JavaScript and that's what GAS uses and I've written (and shared) some GAS sheets with people, so I guess it depends on your audience. Is this something that the teacher is going to use or something that someone is doing across multiple courses? If it's more than a single teacher, I would probably program it in something other than GAS.
Some of that information can be obtained using GraphQL. For example, I could combine the assignment information and submission information into one request. That would leave me the module information and user information as separate requests.
To test this out, add /graphiql to your Dashboard URL. Paste this code in the middle section.
query submissionsWithModulesInfo($courseId: ID!, $c1: String, $c2: String) {
course(id: $courseId) {
_id
name
courseCode
assignmentsConnection(first: 100, after: $c1) {
nodes {
_id
title
modules {
_id
}
submissionsConnection(
filter: {enrollmentTypes: StudentEnrollment}
first: 100
after: $c2
) {
nodes {
score
userId
}
pageInfo {
hasNextPage
endCursor
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
Then expand the variables section at the bottom and add this, changing the courseId to match one of yours instead of my sandbox.
{
"courseId": 896851,
"c1": null,
"c2": null
}
Then click the run button.
On the right panel, you'll get the ouput. There is some information about the course (ID, name, and code) followed by an assignmentsConnection section with a nodes array. There is one item for each assignment that contains the Canvas assignment ID, title, and which modules it belongs to.
Then there is a submissionsConnection with a nodes array that contains the score and user ID information for each submission for that assignment.
You still have to filter all that information.
The c1 and c2 variables are for pagination. If you have more than 100 assignments in a course, you will need to take the endCursor for the assignments pageInfo and place it into c1 and make the call again. If you have more than 100 submissions (students) in a course, you will need to worry about pagination with the c2 variable.
I normally try to keep my pagination variables to just one, which makes it easier to iterate through, but I don't know how big your classes are or how many assignments you have.
I realize that you could supply the module name along with the module IDs. You could also return user information instead of just user_id. That is, you could combine all four requests into a single request using GraphQL. I find the requests faster to fetch the user information and module information once rather than repeating it for each assignment or submission, but it lowers the complexity of the program to get it all at once.
Once you have it working correctly, then you can automate the GraphQL using the REST API.
Community helpTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign inTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign in