Debug time limit handling

This commit is contained in:
Vivek Santayana 2022-06-16 14:15:18 +01:00
parent 5123365567
commit 3f59d1b1b7
2 changed files with 2 additions and 2 deletions

View File

@ -291,7 +291,7 @@ def _create_test():
new_test.start_date = datetime.strptime(new_test.start_date, '%Y-%m-%dT%H:%M') 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 = request.form.get('expiry_date')
new_test.end_date = datetime.strptime(new_test.end_date, '%Y-%m-%dT%H:%M') 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') dataset = request.form.get('dataset')
new_test.dataset = Dataset.query.filter_by(id=dataset).first() new_test.dataset = Dataset.query.filter_by(id=dataset).first()
success, message = new_test.create() success, message = new_test.create()

View File

@ -86,7 +86,7 @@ class Entry(db.Model):
self.answers = answers self.answers = answers
self.result = result self.result = result
write('tests.log', f'Test completed by {self.get_first_name()} {self.get_surname()}.') 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: if not self.test.time_limit or self.end_time <= self.start_time + delta:
self.status = 'completed' self.status = 'completed'
self.valid = True self.valid = True