diff --git a/ref-test/app/quiz/views.py b/ref-test/app/quiz/views.py index d9885fe..e87c2b1 100644 --- a/ref-test/app/quiz/views.py +++ b/ref-test/app/quiz/views.py @@ -59,11 +59,11 @@ def _start(): except Exception as exception: write('system.log', f'Database error when processing request \'{request.url}\': {exception}') return abort(500) + if not test: return jsonify({'error': 'The exam code you entered is invalid.'}), 400 entry.test = test entry.dataset = test.dataset entry.user_code = request.form.get('user_code') entry.user_code = None if entry.user_code == '' else entry.user_code.lower() - if not test: return jsonify({'error': 'The exam code you entered is invalid.'}), 400 if entry.user_code and entry.user_code not in test.adjustments: return jsonify({'error': f'The user code you entered is not valid.'}), 400 if test.end_date < datetime.now(): return jsonify({'error': f'The exam code you entered expired on {test["expiry_date"].strftime("%d %b %Y %H:%M")}.'}), 400 if test.start_date > datetime.now(): 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")}.'}), 400