Calculate current mark (grade)

Jump to solution
KarlSteinbreche
Community Explorer

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!

 

 

Labels (4)
0 Likes
1 Solution
themidiman
Community Champion

@KarlSteinbreche 

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']))

 

View solution in original post

0 Likes