Merge pull request #2 from alex-bellon/master

Added error handling when getting submissions
This commit is contained in:
David Katsandres 2021-03-18 16:57:03 -07:00 committed by GitHub
commit 577327f31a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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