Your Community is getting an upgrade!
Read about our partnership with Higher Logic and how we will build the next generation of the Instructure Community.
Found this content helpful? Log in or sign up to leave a like!
I have been using the update_grades API call to update student assignment grades for a while. I saw last month when the new gradebook rolled out (I'm using Free for Teacher currently) that I can now mark submissions late or missing. But it looks like I can't use the late policy with bulk updates, only individual submission grading. Am I missing something, or is there any plan to enhance update_grades so late policies can be set also?
Submissions - Canvas LMS REST API Documentation #bulk_update
Hi @steven_williams
I don't know if this helps or not but I've recently been using APIs to bulk update the late policy for all courses on our Canvas instance. We used the Late Policy API here: Late Policy - Canvas LMS REST API Documentation
By setting the late policy for a course it will apply the rules to all submissions in the course past and present with penalties and everything.
Here's a cut down version of a Powershell script I used to set the late policies for courses through the API.
#Variables
$token = "<API Token>"
$domain = "<Canvas Domain>"
$termid = "<Term ID Number>"
$account_id = "<Account ID Number>"
#Get all course for sub account
$courses_url = "https://"+$domain+"/api/v1/accounts/"+$account_id+"/courses?per_page=250&enrollment_term_id="+$termid
$headers = @{"Authorization"="Bearer "+$token}
$courses = ConvertFrom-Json (Invoke-WebRequest -Headers $headers -Method GET -Uri $courses_url)
#update course late policies
foreach ($course in $courses){
$latePolicyCreationURL = "https://"+$domain+"/api/v1/courses/"+$course.id+"/late_policy"
try {
$params = @{"late_policy[late_submission_deduction_enabled]" = "true"; "late_policy[late_submission_deduction]" = "25"; "late_policy[late_submission_interval]" = "day"; "late_policy[late_submission_minimum_percent_enabled]" = "true"; "late_policy[late_submission_minimum_percent]" = "0"}
$data = (Invoke-WebRequest -Headers $headers -Method POST -Uri $latePolicyCreationURL -Body $params)
} catch {
Write-Host $_.Exception.Response.StatusCode.Value__
}
}
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😞
# initialize canvas previously
course = canvas.get_course(some_course_id)
assignment = course.get_assignment(some_assignment_id)
submissions = assignment.get_submissions()
data = {}
for submission in submissions:
# do your grading in this loop
data[submission.user_id]['posted_grade'] = some_submission_score
data[submission.user_id]['excuse'] = False
# it would be nice to mark a submission as 'late' or 'missing' here
# data[submission.user_id]['late_policy_status'] = 'missing'
# data[submission.user_id]['seconds_late_override'] = 600
# but submissions_bulk_update() does not have that feature
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:
# initialize canvas previously
course = canvas.get_course(some_course_id)
assignment = course.get_assignment(some_assignment_id)
submissions = assignment.get_submissions()
new_data = {}
for submission in submissions:
# do your grading in this loop
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.
To interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign InTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign In