Get box and whisker plots (averages) for assignments via API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey there!
I'm wondering if it's currently possible to pull the average (mean, high, and low) scores for assignments from the Canvas API.
Is this currently supported functionality?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You mentioned box and whiskers, but then asked for the averages and the answer to one is yes and no to the other. The five number summary (minimum, first quartile, median, third quartile, and maximum) are available through the Get course-level assignment data endpoint of the Analytics API.
That API call returns the values for all of the graded assignments in a course. It gives an array, one item for each assignment. Here's what one of them looks like.
{
"assignment_id": 24792049,
"title": "Quiz 1.2 Sampling & Experiments",
"due_at": "2020-01-29T05:59:00Z",
"muted": true,
"points_possible": 13,
"non_digital_submission": false,
"max_score": 11,
"min_score": 0,
"first_quartile": 7.25,
"median": 9,
"third_quartile": 10,
"tardiness_breakdown": {
"missing": 0.02272727272727273,
"late": 0,
"on_time": 0.9772727272727273,
"floating": 0,
"total": 44
}
},
You will need to be careful, though. If anyone got a 0 because they didn't take it, then that shows up as the minimum score. In my example, not the 2.27% that are missing (that's one student for this class: 44*0.02272727=1). That's why I have 0's, but that's not really what I want. However, including the average would incorporate that 0 and lower the average.
If you want to exclude 0 for missing, then you'll need to download the submissions and calculate the values directly. This can be done through the Submissions API. When I fetch that data, you want to look for 0 with missing: true. A value of missing: false and a 0 would be someone who took my quiz but got 0 points.
The above is for assignments, including quizzes.
If you want quiz-specific information, you can use the Fetching the latest quiz statistics endpoint of the Quiz Statistics API. Note that this uses the quiz ID and not the assignment ID. This includes a lot of information (not just averages, minimums, and maximums), but only for quizzes that have few students or attempts. This lesson in the Canvas Instructor Guide explains what the limitations are (see the blue box at the top): Once I publish a quiz, what kinds of quiz statistics are available?
Here's the results for that same quiz.
"submission_statistics": {
"scores": {
68: 1, 72: 1, 76: 2, 79: 1, 81: 1, 85: 1, 87: 1
},
"score_average": 10.1625,
"score_high": 11.35,
"score_low": 8.9,
"score_stdev": 0.7712611425451237,
"correct_count_average": 8.75,
"incorrect_count_average": 1.875,
"duration_average": 1005.75,
"unique_count": 8
},
This sounds promising because it gave the mean and the standard deviation. However, this may not be reliable even if it is available. It's only giving me the results for 8 students, even though there were 44 who took it.
In order to get all of the results, you need to add the undocumented query parameter all_versions=1 to your request. When I do that, I have all 43 student's scores.
The good news is that it doesn't include the 0 for the student who didn't take the quiz, so the average and standard deviation are only for the non-missing assignments.
"submission_statistics": {
"scores": {
36: 1, 40: 1, 48: 1, 52: 1, 55: 1, 57: 1, 60: 1, 61: 2, 63: 1, 66: 2,
67: 1, 68: 2, 69: 1, 70: 1, 72: 2, 73: 1, 74: 2, 76: 2, 77: 2, 79: 3,
80: 1, 81: 1, 82: 1, 83: 1, 84: 1, 85: 1, 87: 1, 89: 1, 90: 3, 92: 1, 98: 2
},
"score_average": 8.917857142857137,
"score_high": 12.8,
"score_low": 4.3,
"score_stdev": 1.99229790132999,
"correct_count_average": 7.597402597402597,
"incorrect_count_average": 3.207792207792208,
"duration_average": 1070.792207792208,
"unique_count": 43
}
The bad news is that adding all_versions=1 still fails if you exceed the limits of the quiz reporting detailed in the Instructor Guide and that it is only valid for quizzes and not other types of assignments.