Change "submitted_at" date in a submission via API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've run into a quandary using the "decaying average" mastery calculations with objectives. It appears that the artifacts are ordered by the "submitted_at" element, and if any of these elements are missing a time stamp (i.e. the assignment was not submitted) they rise to the top of the list.
The issue manifests as follows: I give five quizzes assessing a given outcome, due on consecutive days. A student completes quizzes 1, 3, 4, and 5, but does not complete quiz 2. The missing quiz is marked as failing using the rubric. When I check the Mastery Gradebook, it uses the missing quiz (#2) as the most recent.
(This begs the question: why do we not have the option to order the artifacts by due date rather than by submission timestamp?)
My attempt to "fix" this issue has been to modify the "submitted_at" timestamp. Using the python canvasapi package, I have the following:
------------------------------------------------
#!/usr/bin/python
from canvasapi import Canvas
from math import floor
from datetime import datetime, timezone
API_URL=[my url]
API_KEY="none of your business"
COURSE_ID=[my course]
# Initialize the canvas object and get the course, then get all assignments
now=datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
print("Getting Canvas course at "+now+"...")
canvas=Canvas(API_URL,API_KEY)
course=canvas.get_course(COURSE_ID)
# Make a list of all the assignments and include their due dates.
print("Gathering all assignment submissions",course.name)
assignments=course.get_assignments(include="due_at",per_page=50)
# Cycle through the assignments, only process those whose due dates are passed.
for assignment in assignments:
if str(assignment.due_at) < now:
newdate=str(assignment.due_at)#.replace("Z",".000Z")
# Pull all of the submissions for this assignment
submissions=assignment.get_submissions(include="submitted_at",per_page=50)
# Cycle over the submissions. If the submitted_at is not the same
# as the due date, change it.
for submission in submissions:
#if submission.submitted_at != assignment.due_at:
if submission.submitted_at == None:
newstatus={
'submission_type':"online_upload",
'submitted_at':newdate,
'graded_at':newdate
}
returned = submission.edit(submission=newstatus) # Doesn't change anything.
------------------------------------------
The course, assignments, and submissions all load correctly, and the conditionals are picking out only the assignments where submitted_at is None. However, the last line doesn't appear to actually change anything.
Am I missing something, or is simply not possible to modify the submitted_at timestamp?