Added results CRUD and result detailed view
This commit is contained in:
		@@ -172,6 +172,11 @@ body {
 | 
			
		||||
    font-size: 26pt;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.button-icon {
 | 
			
		||||
    font-size: 20px;
 | 
			
		||||
    margin-right: 2px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Change Autocomplete styles in Chrome*/
 | 
			
		||||
input:-webkit-autofill,
 | 
			
		||||
input:-webkit-autofill:hover, 
 | 
			
		||||
 
 | 
			
		||||
@@ -363,7 +363,7 @@ function render_question() {
 | 
			
		||||
function check_answered() {
 | 
			
		||||
    var question = questions[current_question];
 | 
			
		||||
    var name = question.q_no;
 | 
			
		||||
    if (question_status[current_question] == 0) {
 | 
			
		||||
    if (question_status[current_question] == 0 || question_status[current_question] == -1) {
 | 
			
		||||
        if (!$(`input[name='${name}']:checked`).val()) {
 | 
			
		||||
            question_status[current_question] = -1;
 | 
			
		||||
        } else {
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,9 @@
 | 
			
		||||
        The presentation of the questions is just a start, and we acknowledge we still have a long way to go. We welcome any feedback on how we can further improve this test.
 | 
			
		||||
    </p>
 | 
			
		||||
    <div class="button-container">
 | 
			
		||||
        <a href="{{ url_for('quiz_views.instructions') }}" class="btn btn-success">Read the Instructions</a>
 | 
			
		||||
        <a href="{{ url_for('quiz_views.instructions') }}" class="btn btn-success">
 | 
			
		||||
            <i class="bi bi-book-fill button-icon"></i>
 | 
			
		||||
            Read the Instructions
 | 
			
		||||
        </a>
 | 
			
		||||
    </div>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
@@ -50,6 +50,9 @@
 | 
			
		||||
        </p>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="button-container">
 | 
			
		||||
        <a href="{{ url_for('quiz_views.start') }}" class="btn btn-success">Take the Quiz</a>
 | 
			
		||||
        <a href="{{ url_for('quiz_views.start') }}" class="btn btn-success">
 | 
			
		||||
            <i class="bi bi-pencil-fill button-icon"></i>
 | 
			
		||||
            Take the Exam
 | 
			
		||||
        </a>
 | 
			
		||||
    </div>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
@@ -9,10 +9,10 @@
 | 
			
		||||
        <span class="surname">{{ entry.name.surname }}</span>, {{ entry.name.first_name }}
 | 
			
		||||
    </h3>
 | 
			
		||||
 | 
			
		||||
    <strong class="results-details">Email Address</strong>: {{ entry.email }}
 | 
			
		||||
    <strong class="results-details">Email Address</strong>: {{ entry.email }} <br />
 | 
			
		||||
 | 
			
		||||
    {% if entry.club %}
 | 
			
		||||
        <strong class="results-details">Club</strong>: {{ entry.club }}
 | 
			
		||||
        <strong class="results-details">Club</strong>: {{ entry.club }} <br />
 | 
			
		||||
    {% endif%}
 | 
			
		||||
 | 
			
		||||
    {% if entry.status == 'late' %}
 | 
			
		||||
@@ -34,7 +34,7 @@
 | 
			
		||||
 | 
			
		||||
            <ul>
 | 
			
		||||
                {% for tag in tag_output %}
 | 
			
		||||
                    <li>{{ tag[0] }}</li>
 | 
			
		||||
                    <li>{{ tag }}</li>
 | 
			
		||||
                {% endfor %}
 | 
			
		||||
            </ul>
 | 
			
		||||
        {% endif %}
 | 
			
		||||
 
 | 
			
		||||
@@ -34,7 +34,10 @@
 | 
			
		||||
            <div class="container form-submission-button">
 | 
			
		||||
                <div class="row">
 | 
			
		||||
                    <div class="col text-center">
 | 
			
		||||
                        <button class="btn btn-md btn-success btn-block" type="submit">Start Quiz</button>
 | 
			
		||||
                        <button class="btn btn-md btn-success btn-block" type="submit">
 | 
			
		||||
                            <i class="bi bi-pencil-fill button-icon"></i>
 | 
			
		||||
                            Start Exam
 | 
			
		||||
                        </button>
 | 
			
		||||
                    </div>
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
 
 | 
			
		||||
@@ -104,6 +104,7 @@ def fetch_questions():
 | 
			
		||||
        'end_time': end_time
 | 
			
		||||
    }
 | 
			
		||||
    entry = db.entries.find_one_and_update({'_id': _id}, {'$set': update}, upsert=False, return_document=ReturnDocument.AFTER)
 | 
			
		||||
    db.tests.find_one_and_update({'_id': test['_id']}, {'$push': {'entries': _id}})
 | 
			
		||||
    dataset = test['dataset']
 | 
			
		||||
    dataset_path = os.path.join(app.config['DATA_FILE_DIRECTORY'], dataset)
 | 
			
		||||
    with open(dataset_path, 'r') as data_file:
 | 
			
		||||
@@ -172,47 +173,48 @@ def result():
 | 
			
		||||
    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.
 | 
			
		||||
        """
 | 
			
		||||
    email = Message(
 | 
			
		||||
        subject="SKA Refereeing Theory Exam Results",
 | 
			
		||||
        recipients=[entry['email']],
 | 
			
		||||
        body=f"""SKA Refereeing Theory Exam\n\n
 | 
			
		||||
        Candidate Results\n\n
 | 
			
		||||
        Dear {entry['name']['first_name']},\n\n
 | 
			
		||||
        This email is to confirm that you have took the SKA Refereeing Theory Exam. Your test has been evaluated and your results have been generated.\n\n
 | 
			
		||||
        {entry['name']['surname']}, {entry['name']['first_name']}\n\n
 | 
			
		||||
        Email Address: {entry['email']}\n
 | 
			
		||||
        {f"Club: {entry['club']}" if entry['club'] else ''}\n
 | 
			
		||||
        Date of Test: {entry['submission_time'].strftime('%d %b %Y')}\n
 | 
			
		||||
        Score: {score}%\n
 | 
			
		||||
        Grade: {entry['results']['grade']}\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
 | 
			
		||||
        {','.join(tag_output)}\n\n
 | 
			
		||||
        Thank you for taking the time to get qualified as a referee.\n\n
 | 
			
		||||
        Best wishes,\n
 | 
			
		||||
        SKA Refereeing
 | 
			
		||||
        """,
 | 
			
		||||
        html=f"""<h1>SKA Refereeing Theory Exam</h1>
 | 
			
		||||
        <h2>Candidate Results</h2>
 | 
			
		||||
        <p>Dear {entry['name']['first_name']},</p>
 | 
			
		||||
        <p>This email is to confirm that you have took the SKA Refereeing Theory Exam. Your test has been evaluated and your results have been generated.</p>
 | 
			
		||||
        <h3>{entry['name']['surname']}, {entry['name']['first_name']}</h3>
 | 
			
		||||
        <p><strong>Email Address</strong>: {entry['email']}</p>
 | 
			
		||||
        {f"<p><strong>Club</strong>: {entry['club']}</p>" if entry['club'] else ''}
 | 
			
		||||
        <p><strong>Date of Test</strong>: {entry['submission_time'].strftime('%d %b %Y')}</p>
 | 
			
		||||
        <h1>{score}%</h1>
 | 
			
		||||
        <h2>{entry['results']['grade']}</h2>
 | 
			
		||||
        <p>{flavour_text_plain}</p>
 | 
			
		||||
        <p>Based on your answers, we would also suggest you revise the following topics as you continue refereeing:</p>
 | 
			
		||||
        <ul>
 | 
			
		||||
        <li>{'</li><li>'.join(tag_output)}</li>
 | 
			
		||||
        </ul>
 | 
			
		||||
        <p>Thank you for taking the time to get qualified as a referee.</p>
 | 
			
		||||
        <p>Best wishes,<br />
 | 
			
		||||
        SKA Refereeing</p>
 | 
			
		||||
        """,
 | 
			
		||||
    )
 | 
			
		||||
    mail.send(email)
 | 
			
		||||
    if not entry['status'] == 'late':
 | 
			
		||||
        email = Message(
 | 
			
		||||
            subject="SKA Refereeing Theory Exam Results",
 | 
			
		||||
            recipients=[entry['email']],
 | 
			
		||||
            body=f"""SKA Refereeing Theory Exam\n\n
 | 
			
		||||
            Candidate Results\n\n
 | 
			
		||||
            Dear {entry['name']['first_name']},\n\n
 | 
			
		||||
            This email is to confirm that you have took the SKA Refereeing Theory Exam. Your test has been evaluated and your results have been generated.\n\n
 | 
			
		||||
            {entry['name']['surname']}, {entry['name']['first_name']}\n\n
 | 
			
		||||
            Email Address: {entry['email']}\n
 | 
			
		||||
            {f"Club: {entry['club']}" if entry['club'] else ''}\n
 | 
			
		||||
            Date of Test: {entry['submission_time'].strftime('%d %b %Y')}\n
 | 
			
		||||
            Score: {score}%\n
 | 
			
		||||
            Grade: {entry['results']['grade']}\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
 | 
			
		||||
            {','.join(tag_output)}\n\n
 | 
			
		||||
            Thank you for taking the time to get qualified as a referee.\n\n
 | 
			
		||||
            Best wishes,\n
 | 
			
		||||
            SKA Refereeing
 | 
			
		||||
            """,
 | 
			
		||||
            html=f"""<h1>SKA Refereeing Theory Exam</h1>
 | 
			
		||||
            <h2>Candidate Results</h2>
 | 
			
		||||
            <p>Dear {entry['name']['first_name']},</p>
 | 
			
		||||
            <p>This email is to confirm that you have took the SKA Refereeing Theory Exam. Your test has been evaluated and your results have been generated.</p>
 | 
			
		||||
            <h3>{entry['name']['surname']}, {entry['name']['first_name']}</h3>
 | 
			
		||||
            <p><strong>Email Address</strong>: {entry['email']}</p>
 | 
			
		||||
            {f"<p><strong>Club</strong>: {entry['club']}</p>" if entry['club'] else ''}
 | 
			
		||||
            <p><strong>Date of Test</strong>: {entry['submission_time'].strftime('%d %b %Y')}</p>
 | 
			
		||||
            <h1>{score}%</h1>
 | 
			
		||||
            <h2>{entry['results']['grade']}</h2>
 | 
			
		||||
            <p>{flavour_text_plain}</p>
 | 
			
		||||
            <p>Based on your answers, we would also suggest you revise the following topics as you continue refereeing:</p>
 | 
			
		||||
            <ul>
 | 
			
		||||
            <li>{'</li><li>'.join(tag_output)}</li>
 | 
			
		||||
            </ul>
 | 
			
		||||
            <p>Thank you for taking the time to get qualified as a referee.</p>
 | 
			
		||||
            <p>Best wishes,<br />
 | 
			
		||||
            SKA Refereeing</p>
 | 
			
		||||
            """,
 | 
			
		||||
        )
 | 
			
		||||
        mail.send(email)
 | 
			
		||||
    return render_template('/quiz/result.html', entry=entry, score=score, tag_output=tag_output)
 | 
			
		||||
 | 
			
		||||
@views.route('/privacy/')
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user