From 3f59d1b1b75b6e5e335b34c1d04e7f771785976d Mon Sep 17 00:00:00 2001 From: viveksantayana Date: Thu, 16 Jun 2022 14:15:18 +0100 Subject: [PATCH] Debug time limit handling --- ref-test/app/admin/views.py | 2 +- ref-test/app/models/entry.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ref-test/app/admin/views.py b/ref-test/app/admin/views.py index 02030da..65bb6f2 100644 --- a/ref-test/app/admin/views.py +++ b/ref-test/app/admin/views.py @@ -291,7 +291,7 @@ def _create_test(): new_test.start_date = datetime.strptime(new_test.start_date, '%Y-%m-%dT%H:%M') new_test.end_date = request.form.get('expiry_date') new_test.end_date = datetime.strptime(new_test.end_date, '%Y-%m-%dT%H:%M') - new_test.time_limit = request.form.get('time_limit') + new_test.time_limit = None if request.form.get('time_limit') == 'none' else int(request.form.get('time_limit')) dataset = request.form.get('dataset') new_test.dataset = Dataset.query.filter_by(id=dataset).first() success, message = new_test.create() diff --git a/ref-test/app/models/entry.py b/ref-test/app/models/entry.py index 557003a..c1adfb6 100644 --- a/ref-test/app/models/entry.py +++ b/ref-test/app/models/entry.py @@ -86,7 +86,7 @@ class Entry(db.Model): self.answers = answers self.result = result write('tests.log', f'Test completed by {self.get_first_name()} {self.get_surname()}.') - delta = timedelta(minutes=self.test.time_limit+1) + delta = timedelta(minutes=int(0 if self.test.time_limit is None else self.test.time_limit)+1) if not self.test.time_limit or self.end_time <= self.start_time + delta: self.status = 'completed' self.valid = True