-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhomeworkmap.py
More file actions
25 lines (22 loc) · 810 Bytes
/
homeworkmap.py
File metadata and controls
25 lines (22 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import os
#send this a homework directory!
def buildMap(homeworkpath):
studentids = os.listdir(homeworkpath)
studenthomeworkmap = {}
for student in studentids:
submissionspath = os.path.join(homeworkpath,student)
submissions = None
if os.path.isdir(submissionspath):
submissions = os.listdir(submissionspath)
if submissions:
latest = max(submissions)
latestpath = os.path.join(submissionspath,latest)
submissionfoldercontents = os.listdir(latestpath)
lastsubmission = None
i = 0
while i<len(submissionfoldercontents) and not lastsubmission:
if os.path.splitext(submissionfoldercontents[i])[1] == '.py':
lastsubmission = os.path.join(latestpath, submissionfoldercontents[i])
studenthomeworkmap[student] = lastsubmission
i += 1
return studenthomeworkmap