API endpoint for score on an assignment group?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.