Exam Code Time Controls
This commit is contained in:
parent
09aa30694e
commit
2cab80bda4
@ -48,8 +48,13 @@ def start():
|
||||
test_code = request.form.get('test_code').replace('—', '')
|
||||
user_code = request.form.get('user_code')
|
||||
user_code = None if user_code == '' else user_code
|
||||
if not db.tests.find_one({'test_code': test_code}):
|
||||
test = db.tests.find_one({'test_code': test_code})
|
||||
if not test:
|
||||
return jsonify({'error': 'The exam code you entered is invalid.'}), 400
|
||||
if test['expiry_date'] < datetime.utcnow():
|
||||
return jsonify({'error': f'The exam code you entered expired on {test["expiry_date"].strftime("%d %b %Y")}.'}), 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")}.'}), 400
|
||||
entry = {
|
||||
'_id': uuid4().hex,
|
||||
'name': encrypt(name),
|
||||
|
Loading…
Reference in New Issue
Block a user