Added ability to download all submissiosn from students and load credentials from file #1

Merged
moorepants merged 5 commits from all-assignments into master 2020-07-13 22:40:08 -06:00
1 changed files with 5 additions and 1 deletions
Showing only changes of commit 74e3f91436 - Show all commits

View File

@ -102,10 +102,12 @@ class submissionView():
class attachmentView(): class attachmentView():
filename = "" filename = ""
id = 0
url = "" url = ""
def __init__(self): def __init__(self):
self.filename = "" self.filename = ""
self.id = 0
self.url = "" self.url = ""
@ -256,7 +258,8 @@ def download_submission_attachments(course, course_view):
if not os.path.exists(attachment_dir): if not os.path.exists(attachment_dir):
os.makedirs(attachment_dir) os.makedirs(attachment_dir)
for attachment in submission.attachments: for attachment in submission.attachments:
filepath = os.path.join(attachment_dir, attachment.filename) filepath = os.path.join(attachment_dir, str(attachment.id) +
"_" + attachment.filename)
if not os.path.exists(filepath): if not os.path.exists(filepath):
print('Downloading attachment: {}'.format(filepath)) print('Downloading attachment: {}'.format(filepath))
r = requests.get(attachment.url, allow_redirects=True) r = requests.get(attachment.url, allow_redirects=True)
@ -397,6 +400,7 @@ def findCourseAssignments(course):
for attachment in submission.attachments: for attachment in submission.attachments:
attach_view = attachmentView() attach_view = attachmentView()
attach_view.url = attachment["url"] attach_view.url = attachment["url"]
attach_view.id = attachment["id"]
attach_view.filename = attachment["filename"] attach_view.filename = attachment["filename"]
sub_view.attachments.append(attach_view) sub_view.attachments.append(attach_view)
assignment_view.submissions.append(sub_view) assignment_view.submissions.append(sub_view)