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

API endpoint for score on an assignment group?

Jump to solution

Hi admins,

I'm rummaging around in the API doc, and hoping to find a way to pull a piece of user data from a course. I'm stumped, and hoping the autonomous collective can help.

I'd like to be able to programmatically know the total score (or percentage) that a student has achieved for a particular assignment group in a course. I can get current/final grade (see below). That's fine, but what I'd like to do is see how they're doing on just one assignment group in the course. The scenario is our orientation course... once a student completes a certain set of assignments at a grade level, an external web app picks this up an unlocks certain privileges in and out of Canvas.

Is that endpoint there and I'm just documentation challenged today?

Thanks in advance for any help you can provide.

Marc

What I get from (I think) the users object:

"grades":{

      "html_url":"https://canvas.highline.edu/courses/123456/grades/********",

      "current_score":100,

      "final_score":8,

      "current_grade":null,

      "final_grade":null

1 Solution

Accepted Solutions
tyler_clair
Community Champion

Hi Marc,

So I have thought of two methods to use, one is fairly easy and the other one is fairly complex. Each seems to have some caveats attached to them.

The first (easy, maybe...)

Have your script download the gradebook CSV which can be grabbed from the following URL: https://abc.instructure.com/courses/12345/gradebook.csv. From there you can parse the CSV to get a percentage directly from one of the assignment group columns. as well as be able to check each assignment. The columns should accurately reflect what comes from the gradebook.

You will have to get a fresh copy of the gradebook often for this to be up-to-date.

The second (complex)

This uses the API to handle the collection of data.

You will have to know what the assignment group id is before you can proceed or use the API to grab the courses assignment groups.

1. Grab a list of the course assignment groups.

GET /api/v1/courses/:course_id/assignment_groups

https://canvas.instructure.com/doc/api/assignment_groups.html#method.assignment_groups.index

2. Once you grab the Assignment group id, you need to get the assignment group and include assignments.

GET /api/v1/courses/:course_id/assignment_groups

Parameters: include[]=assignments

https://canvas.instructure.com/doc/api/assignment_groups.html#method.assignment_groups_api.show

Save the assignment ids and points_possible from each assignment.

3. As far as I have researched the easiest way to get a students score from a subset of assignments is through the student submissions API, in particular the list submissions for multiple assignments.

https://canvas.instructure.com/doc/api/submissions.html#method.submissions_api.for_students

GET /api/v1/courses/:course_id/students/submissions

Parameters: student_ids[]=all (this is a shortcut method for all students in the course) you could also provide a list of students if you just want a subset.

assignment_ids[]=List of assignment ids from step 3

grouped=True (this will group all assignments together for each student, making it easer to get a total score)

4. For each group of scores associated with a student, total their scores together and then compare that to the points_possible for each assignment and then you can also compare their total score to their total points possible.

I hope this gives you enough direction,

Tyler

View solution in original post

7 Replies
tyler_clair
Community Champion

Hi Marc,

So I have thought of two methods to use, one is fairly easy and the other one is fairly complex. Each seems to have some caveats attached to them.

The first (easy, maybe...)

Have your script download the gradebook CSV which can be grabbed from the following URL: https://abc.instructure.com/courses/12345/gradebook.csv. From there you can parse the CSV to get a percentage directly from one of the assignment group columns. as well as be able to check each assignment. The columns should accurately reflect what comes from the gradebook.

You will have to get a fresh copy of the gradebook often for this to be up-to-date.

The second (complex)

This uses the API to handle the collection of data.

You will have to know what the assignment group id is before you can proceed or use the API to grab the courses assignment groups.

1. Grab a list of the course assignment groups.

GET /api/v1/courses/:course_id/assignment_groups

https://canvas.instructure.com/doc/api/assignment_groups.html#method.assignment_groups.index

2. Once you grab the Assignment group id, you need to get the assignment group and include assignments.

GET /api/v1/courses/:course_id/assignment_groups

Parameters: include[]=assignments

https://canvas.instructure.com/doc/api/assignment_groups.html#method.assignment_groups_api.show

Save the assignment ids and points_possible from each assignment.

3. As far as I have researched the easiest way to get a students score from a subset of assignments is through the student submissions API, in particular the list submissions for multiple assignments.

https://canvas.instructure.com/doc/api/submissions.html#method.submissions_api.for_students

GET /api/v1/courses/:course_id/students/submissions

Parameters: student_ids[]=all (this is a shortcut method for all students in the course) you could also provide a list of students if you just want a subset.

assignment_ids[]=List of assignment ids from step 3

grouped=True (this will group all assignments together for each student, making it easer to get a total score)

4. For each group of scores associated with a student, total their scores together and then compare that to the points_possible for each assignment and then you can also compare their total score to their total points possible.

I hope this gives you enough direction,

Tyler

View solution in original post

MLentini
Community Participant

Tyler,

This looks like two great options.

I had started working out the kludge option, which was to require one "final" assignment that didn't open until all the other assignments had been graded, and use that one assignment as the score to check. That's a lot of hard-wiring in places that shouldn't be hard wired.

We'll get to work, and report back on this.

Marc

This gets even more complex if your assignment groups have rules applied (drop lowest score) or assignment group weights. These items can be found in the Assignment Group api data mentioned above (Canvas LMS REST API Documentation) and then plugged into your formula to calculate each student score.

b_willems
Community Participant

Hi, 

it's been a while since this discussion was published but I have a similar question (I have posted it here). As there doesn't seem to be a way to get the group score directly, we need to make sure we get all the calculations and pitfalls right when transferring grades to our SIS via the API. Can you describe how exactly to mirror all the calculations that happen in the gradebook 'behind the scenes' and share your experience of what to pay attention to? 

Thanks! 

Barbara

b_willems
Community Participant

MLentini‌ I have created this idea: 

https://community.canvaslms.com/ideas/13985-api-endpoint-for-assignment-group-score 

Please vote if you still think a direct retrieval of the assignment group score would be useful. 

Thanks! 

Barbara

ECUEd
Community Member

I have been investigating how we could best achieve an extract student scores at an assignment group level.  The best approach I have found currently is to use GraphQL.  The GraphQL query extracts the student scores at assignment group level, and applies the assignment group rules.  This can all be done in a single API call, rather than several REST API calls.

Hope this helps others

Ed

lucas_ames
Community Participant

I ran the following query to get a single student grade for a single assignment category

 

query MyQuery {
assignmentGroup(id: "xx") {
gradesConnection(filter: {enrollmentIds: "xx"}) {
edges {
node {
currentScore
}
}
}
}
}