diff --git a/ref-test/admin/templates/admin/result-detail.html b/ref-test/admin/templates/admin/result-detail.html index b737789..72b21eb 100644 --- a/ref-test/admin/templates/admin/result-detail.html +++ b/ref-test/admin/templates/admin/result-detail.html @@ -141,6 +141,9 @@ {{ answer }} + {% if not correct[question] == answer %} + Incorrect + {% endif %} {% endfor %} diff --git a/ref-test/common/data_tools.py b/ref-test/common/data_tools.py index 7a42ffe..0dfadf1 100644 --- a/ref-test/common/data_tools.py +++ b/ref-test/common/data_tools.py @@ -222,4 +222,15 @@ def get_datasets(): 'use': len(load['meta']['tests']) } data.append(data_element) - return data \ No newline at end of file + 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 \ No newline at end of file diff --git a/ref-test/quiz/views.py b/ref-test/quiz/views.py index fcc87ca..03a0dd6 100644 --- a/ref-test/quiz/views.py +++ b/ref-test/quiz/views.py @@ -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.',