ifnottest:returnjsonify({'error':'The exam code you entered is invalid.'}),400
ifentry.user_codeandentry.user_codenotintest.adjustments:returnjsonify({'error':f'The user code you entered is not valid.'}),400
iftest.end_date<datetime.now():returnjsonify({'error':f'The exam code you entered expired on {test["expiry_date"].strftime("%d%b %Y %H:%M")}.'}),400
iftest.start_date>datetime.now():returnjsonify({'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
success,message=entry.start()
ifsuccess:
session['id']=entry.id
returnjsonify({
'success':'Received and validated test and/or user code. Redirecting to test client.',
'id':entry.id
}),200
returnjsonify({'error':'There was an error processing the user test and/or user codes.'}),400
flavour_text_plain="""Well done on successfully completing the refereeing theory exam. We really appreciate members of our community taking the time to get qualified to referee.
"""
elifentry.results['grade']=='merit':
flavour_text_plain="""Congratulations on achieving a merit in the refereeing exam. We are delighted that members of our community work so hard with refereeing.
"""
elifentry.results['grade']=='fail':
flavour_text_plain="""Unfortunately, you were not successful in passing the theory exam in this attempt. We hope that this does not dissuade you, and that you try again in the future.
"""
revision_plain=f"""Based on your answers, we would also suggest you brush up on the following topics for your next attempt:\n\n
{','.join(tag_output)}\n\n
"""
revision_html=f"""<p>Based on your answers, we would also suggest you brush up on the following topics for your next attempt:</p>