Calculate current mark (grade)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024
12:45 PM
Hello,
I am new to the API and DAP. Is there any easy way to calculate current marks for students?
It sounds simple but it looks like a complicated calculation, roughly the average of all required assignments mapped to a mark using the grading scheme for the section.
Is there a handy GitHub repo that I can leverage?
Thanks in advance!
Solved! Go to Solution.
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024
02:08 PM
It appears there is a grades property in the Enrollments endpoint: https://canvas.instructure.com/doc/api/enrollments.html
For each active enrollment you can get the final_score property from the grades collection.
I just tested this with the UCF Python wrapper library and it seems to work:
from canvasapi import Canvas
# Specify your Canvas instance and the API key of a user with grades viewing permissions
API_URL = <your_canvas_server_url>
API_KEY = <your_api_key>
# Create a Canvas object
canvas = Canvas(API_URL,API_KEY)
# Specify the course you want to query
course = canvas.get_course(<course_id>)
# Get all the active enrollments
enrollments = course.get_enrollments(type='StudentEnrollment',state='active')
# Iterate through all the enrollments and display name and grade
for e in enrollments:
print(e.user['sortable_name'] + ': ' + str(e.grades['final_score']))