Fetching grades data

Jump to solution
michael5
Community Contributor

Hello developers,

For a statistics project for our school I'm currently interested in discovering how many of our students actually complete their courses. A course is considered completed if the student has been awarded more than 80% of the available points in the course, so in order to evaluate how many students complete their courses I need to calculate how many students, per course, who have been awarded more than 80% of the available points.

This has turned out to be a lot more complicated than I initially assumed it would be. I've tried a few approaches:

  1. The submissions object: https://canvas.instructure.com/doc/api/submissions.html
    Manually mapping student data from here was easy enough, but the operation is quite intense because I have to repeat the process on a lot of courses so I'd rather avoid doing that.
  2. The grades report (Account > Reports > Grades) is perfect and exactly what I need but I can't seem to find a way to fetch the actual data within these reports with the API. If I could get the CSV file that is generated by these reports either as a CSV file, JSON data or even raw text, that would be sufficient.

  3. I haven't experimented too much with this but it may be possible to pull the numbers from the New Analytics if that comes with an API, however at a glance it only seems to offer an average grade and not a total of points awarded in the course.

 

Since the number(s) that I'm trying to fetch are already in the system, I feel like I'm missing something and that this should be an easy request to make with the API. Did I overlook something? Any suggestions would be very much appreciated. 🙂

Thanks in advance,

Michael

 

 

 

Labels (2)
0 Likes
1 Solution
DecoyLex
Community Participant

The enrollments API is probably what you're looking for. It includes each enrollment as well as a student's current grade and final grade as calculated by Canvas. Here's what I get by doing a GET request to /api/v1/courses/123/enrollments:

[
    {
        "id": ...,
        "user_id": ...,
        "course_id": ...,
        "type": "StudentEnrollment",
        "created_at": ...,
        "updated_at": ...,
        "associated_user_id": null,
        "start_at": null,
        "end_at": null,
        "course_section_id": ...,
        "root_account_id": 1,
        "limit_privileges_to_course_section": false,
        "enrollment_state": "active",
        "role": "StudentEnrollment",
        "role_id": 3,
        "last_activity_at": ...,
        "last_attended_at": null,
        "total_activity_time": ...,
        "sis_import_id": ...,
        "grades": {
            "html_url": ...,
            "current_grade": "B+",
            "current_score": 88.6,
            "final_grade": "B+",
            "final_score": 88.6,
            "unposted_current_score": 88.6,
            "unposted_current_grade": "B+",
            "unposted_final_score": 88.6,
            "unposted_final_grade": "B+"
        },
        "sis_account_id": ...,
        "sis_course_id": ...,
        "course_integration_id": null,
        "sis_section_id": ...,
        "section_integration_id": null,
        "sis_user_id": ...,
        "html_url": ...,
        "user": {
            "id": ...,
            "name": ...,
            "created_at": ...,
            "sortable_name": ...,
            "short_name": ...,
            "sis_user_id": ...,
            "integration_id": ...,
            "sis_import_id": ...,
            "login_id": ...
        }
    }
]

You can also add ?include[]=current_points to the end to get the raw points value of the student's enrollment.

You'd probably want to use the unposted_current_score for your report since it's the percentage that the instructor sees in the gradebook and would be the most likely value they'd use when entering grades into SIS manually (if that's relevant to you).

Enrollments API: https://canvas.instructure.com/doc/api/enrollments.html#method.enrollments_api.index

View solution in original post