Added individual result correct/incorrect flag

This commit is contained in:
Vivek Santayana 2021-12-06 13:42:26 +00:00
parent 8ead32c34d
commit 03d419c3fc
3 changed files with 16 additions and 2 deletions

View File

@ -141,6 +141,9 @@
</td>
<td>
{{ answer }}
{% if not correct[question] == answer %}
<span class="badge badge-pill bg-danger badge-danger">Incorrect</span>
{% endif %}
</td>
</tr>
{% endfor %}

View File

@ -223,3 +223,14 @@ def get_datasets():
}
data.append(data_element)
return data
def get_correct_answers(dataset:dict):
output = {}
blocks = dataset['questions']
for block in blocks:
if block['type'] == 'question':
output[str(block['q_no'])] = block['options'][block['correct']]
if block['type'] == 'block':
for question in block['questions']:
output[str(question['q_no'])] = question['options'][question['correct']]
return output

View File

@ -75,7 +75,7 @@ def start():
'test_code': test_code,
'user_code': user_code
}
if db.entries.insert(entry):
if db.entries.insert_one(entry):
session['_id'] = entry['_id']
return jsonify({
'success': 'Received and validated test and/or user code. Redirecting to test client.',