Added error handling when getting submissions

This commit is contained in:
alex-bellon 2021-03-16 21:56:03 -05:00
parent a0be61b2ef
commit 4866967140
1 changed files with 94 additions and 87 deletions

View File

@ -330,6 +330,7 @@ def findCourseAssignments(course):
# Get all assignments
assignments = course.get_assignments()
try:
for assignment in assignments:
# Create a new assignment view
assignment_view = assignmentView()
@ -362,6 +363,7 @@ def findCourseAssignments(course):
except:
print("Got no submissions for this assignment")
else:
try:
for submission in submissions:
sub_view = submissionView()
@ -404,6 +406,9 @@ def findCourseAssignments(course):
attach_view.filename = attachment["filename"]
sub_view.attachments.append(attach_view)
assignment_view.submissions.append(sub_view)
except Exception as e:
print("Skipping submission that gave the following error:")
print(e)
# The following is only useful if you are a student in the class.
# Get my user"s submission object
@ -425,7 +430,9 @@ def findCourseAssignments(course):
assignment_view.submission.submission_comments = str(submission.submission_comments) if hasattr(submission, "submission_comments") else ""
assignment_views.append(assignment_view)
except Exception as e:
print("Skipping course assignments that gave the following error:")
print(e)
return assignment_views