Skip to content

Commit

Permalink
only list assignments user has access to
Browse files Browse the repository at this point in the history
  • Loading branch information
zonca committed Sep 19, 2017
1 parent b310040 commit a288c9b
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions nbgrader/exchange/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,34 +58,36 @@ def copy_files(self):

def parse_assignments(self):
assignments = []
courses = self.get_current_user_courses()
for path in self.assignments:
info = self.parse_assignment(path)
if self.path_includes_course:
root = os.path.join(info['course_id'], info['assignment_id'])
else:
root = info['assignment_id']

if self.inbound or self.cached:
info['status'] = 'submitted'
info['path'] = path
elif os.path.exists(root):
info['status'] = 'fetched'
info['path'] = os.path.abspath(root)
else:
info['status'] = 'released'
info['path'] = path

if self.remove:
info['status'] = 'removed'

info['notebooks'] = []
for notebook in sorted(glob.glob(os.path.join(info['path'], '*.ipynb'))):
info['notebooks'].append({
'notebook_id': os.path.splitext(os.path.split(notebook)[1])[0],
'path': os.path.abspath(notebook)
})

assignments.append(info)
if info['course_id'] in courses:
if self.path_includes_course:
root = os.path.join(info['course_id'], info['assignment_id'])
else:
root = info['assignment_id']

if self.inbound or self.cached:
info['status'] = 'submitted'
info['path'] = path
elif os.path.exists(root):
info['status'] = 'fetched'
info['path'] = os.path.abspath(root)
else:
info['status'] = 'released'
info['path'] = path

if self.remove:
info['status'] = 'removed'

info['notebooks'] = []
for notebook in sorted(glob.glob(os.path.join(info['path'], '*.ipynb'))):
info['notebooks'].append({
'notebook_id': os.path.splitext(os.path.split(notebook)[1])[0],
'path': os.path.abspath(notebook)
})

assignments.append(info)

return assignments

Expand Down

0 comments on commit a288c9b

Please sign in to comment.