Thanks @rpayne4 for the example. I'll put that one in my bookmarks for a future project. It's not quite what I was after, but I don't think my original question was clear enough. I'll try to describe what I am after. I would like to be able to grade student submissions in bulk, then post their grades with a late policy status. You can do it individually using this endpoint Submissions - Canvas LMS REST API Documentation, but the option submission[late_policy_status] is not implemented in the bulk_update function.
Normally, I would use something like this (I'm using the Python canvasapi from UCF😞
course = canvas.get_course(some_course_id)
assignment = course.get_assignment(some_assignment_id)
submissions = assignment.get_submissions()
data = {}
for submission in submissions:
data[submission.user_id]['posted_grade'] = some_submission_score
data[submission.user_id]['excuse'] = False
assignment.submissions_bulk_update(grade_data=data)
But since submissions_bulk_update() does not have those options, you have to do it manually (which results in multiple API calls, instead of just one:
course = canvas.get_course(some_course_id)
assignment = course.get_assignment(some_assignment_id)
submissions = assignment.get_submissions()
new_data = {}
for submission in submissions:
submission.edit(submission={'posted_grade':some_grade,
'late_policy_status':'missing',
'seconds_late_override':600})
I initially wrote that this didn't work for me (the submissions I tried to edit returned 401 Unauthorized), but I just found a thread pointing out that the assignment must be published. The bulk update method returns a Progress (which may result in an error), whereas the edit method returns the Submission or an error immediately.