Better precision in expiring quizzes

This commit is contained in:
2021-12-07 00:08:01 +00:00
parent eca786d444
commit 176a0f069f
3 changed files with 8 additions and 7 deletions

View File

@ -63,7 +63,7 @@ def start():
return jsonify({'error': 'The exam code you entered is invalid.'}), 400
if user_code and user_code not in test['time_adjustments']:
return jsonify({'error': f'The user code you entered is not valid.'}), 400
if test['expiry_date'] + timedelta(days=1) < datetime.utcnow():
if test['expiry_date'] < datetime.utcnow():
return jsonify({'error': f'The exam code you entered expired on {test["expiry_date"].strftime("%d %b %Y")} UTC.'}), 400
if test['start_date'] > datetime.utcnow():
return jsonify({'error': f'The exam has not yet opened. Your exam code will be valid from {test["start_date"].strftime("%d %b %Y %H:%M")} UTC.'}), 400