Skip to content
Snippets Groups Projects
Commit 40314d38 authored by akamil's avatar akamil
Browse files

Add script to compute the final deadlines for a course's projects.

parent b1c2b685
No related branches found
No related tags found
No related merge requests found
......@@ -227,6 +227,16 @@ $ ag-last-date 25 akamil
The username can be a uniqname or an email address.
## `ag-final-deadlines`
This determines the last deadline for each project in a course, taking
extensions into account. It also lists which projects have an
outstanding deadline. Requires the course ID.
``` console
$ ag-final-deadlines 25
```
## `ag-roster`
This downloads a roster from the autograder or uploads a new one.
......
#!/usr/bin/env python3
"""
Determine the date of a student's last submission.
"""
import datetime
import click
import pytz
try:
import common
except:
from . import common
MIN_DATETIME = datetime.datetime.min.replace(tzinfo=common.TIMEZONE)
@click.command(context_settings={'help_option_names': ['-h', '--help']})
@click.argument(
'course_id',
type=int,
)
def main(course_id):
api_token = common.get_api_token()
last_date = MIN_DATETIME
now = pytz.utc.localize(datetime.datetime.utcnow())
projects = common.get_project_list(api_token, course_id)
open_projects = []
for project in sorted(projects, key=lambda p: p['name']):
project_date = last_deadline(api_token, project)
if project_date > last_date:
last_date = project_date
if project_date > now:
open_projects.append((project, project_date))
print(f'Last deadline for {project["name"]}: {project_date}')
if open_projects:
print('\nOpen projects:')
for project, project_date in open_projects:
print(f'{project["name"]}: {project_date}')
else:
print('\nNo open projects')
def last_deadline(api_token, project):
"""Determine time of last deadline or extension for a project."""
groups = common.get_endpoint(f'projects/{project["pk"]}/groups/',
api_token)
due_date = common.convert_timestamp(project['closing_time'])
extensions = [common.convert_timestamp(group['extended_due_date'])
for group in groups
if group.get('extended_due_date')]
return max(extensions + [due_date])
if __name__ == '__main__':
main()
......@@ -32,6 +32,7 @@ setup(
'ag-bonus = ag_tools.ag_bonus:main',
'ag-copy-groups = ag_tools.copy_groups:main',
'ag-copy-project = ag_tools.copy_project:main',
'ag-final-deadlines = ag_tools.final_deadlines:main',
'ag-finish-handgrading = ag_tools.finish_handgrading:main',
'ag-get-late-days = ag_tools.get_late_days:main',
'ag-last-date = ag_tools.last_date:main',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment