Only show topics to revise if failed

This commit is contained in:
Vivek Santayana 2021-12-08 12:46:33 +00:00
parent 7c70da4b5c
commit ce07bdf8b2
2 changed files with 13 additions and 7 deletions

View File

@ -30,7 +30,7 @@
</div> </div>
{% if entry.results.grade == 'fail' %} {% if entry.results.grade == 'fail' %}
Unfortunately, you have not passed the theory exam in this attempt. For your next attempt, it might help to revise the following topics: Unfortunately, you have not passed the theory exam in this attempt. For your next attempt, it might help to brush up on the following topics:
<ul> <ul>
{% for tag in tag_output %} {% for tag in tag_output %}

View File

@ -176,6 +176,8 @@ def result():
tags_low = { tag: tag_result['max'] - tag_result['scored'] for tag, tag_result in entry['results']['tags'].items() } tags_low = { tag: tag_result['max'] - tag_result['scored'] for tag, tag_result in entry['results']['tags'].items() }
sorted_low_tags = sorted(tags_low.items(), key=lambda x: x[1], reverse=True) sorted_low_tags = sorted(tags_low.items(), key=lambda x: x[1], reverse=True)
tag_output = [ tag[0] for tag in sorted_low_tags[0:3] if tag[1] > 3] tag_output = [ tag[0] for tag in sorted_low_tags[0:3] if tag[1] > 3]
revision_plain = ''
revision_html = ''
if entry['results']['grade'] == 'pass': if entry['results']['grade'] == 'pass':
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. 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.
""" """
@ -185,6 +187,14 @@ def result():
elif entry['results']['grade'] == 'fail': elif entry['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. 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>
<ul>
<li>{'</li><li>'.join(tag_output)}</li>
</ul>
"""
if not entry['status'] == 'late': if not entry['status'] == 'late':
email = Message( email = Message(
subject="SKA Refereeing Theory Exam Results", subject="SKA Refereeing Theory Exam Results",
@ -200,8 +210,7 @@ def result():
Score: {score}%\n Score: {score}%\n
Grade: {entry['results']['grade']}\n\n Grade: {entry['results']['grade']}\n\n
{flavour_text_plain}\n\n {flavour_text_plain}\n\n
Based on your answers, we would also suggest you brush up on the following topics as you continue refereeing:\n\n {revision_plain}
{','.join(tag_output)}\n\n
Thank you for taking the time to get qualified as a referee.\n\n Thank you for taking the time to get qualified as a referee.\n\n
Best wishes,\n Best wishes,\n
SKA Refereeing SKA Refereeing
@ -217,10 +226,7 @@ def result():
<h1>{score}%</h1> <h1>{score}%</h1>
<h2>{entry['results']['grade']}</h2> <h2>{entry['results']['grade']}</h2>
<p>{flavour_text_plain}</p> <p>{flavour_text_plain}</p>
<p>Based on your answers, we would also suggest you revise the following topics as you continue refereeing:</p> {revision_html}
<ul>
<li>{'</li><li>'.join(tag_output)}</li>
</ul>
<p>Thank you for taking the time to get qualified as a referee.</p> <p>Thank you for taking the time to get qualified as a referee.</p>
<p>Best wishes,<br /> <p>Best wishes,<br />
SKA Refereeing</p> SKA Refereeing</p>