From db5169bfcecec4c304fc302a6841c058b2831b46 Mon Sep 17 00:00:00 2001 From: Ross Date: Thu, 9 Sep 2021 12:17:02 +0100 Subject: [PATCH] . --- rapids/templates/rapids/exam_scores.html | 2 +- rapids/views.py | 27 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/rapids/templates/rapids/exam_scores.html b/rapids/templates/rapids/exam_scores.html index 41d3f092..a37a588d 100644 --- a/rapids/templates/rapids/exam_scores.html +++ b/rapids/templates/rapids/exam_scores.html @@ -34,7 +34,7 @@ {{user}} {{user_scores|get_item:user}} - {{value}} + {{user_scores_normalised|get_item:user}} {% endfor %} diff --git a/rapids/views.py b/rapids/views.py index aba94b2e..eca0cd70 100755 --- a/rapids/views.py +++ b/rapids/views.py @@ -849,11 +849,37 @@ def exam_scores_cid(request, pk): by_question[q].append((ans, answer_score)) + def normaliseScore(score): + if score == 49: + return 4.5 + elif score in [50, 51]: + return 5 + elif score in [52, 53]: + return 5.5 + elif score in [54]: + return 6 + elif score in [55, 56]: + return 6.5 + elif score in [57, 58]: + return 7 + elif score in [59]: + return 7.5 + elif score in [60]: + return 7.5 + + return 4 + + + user_scores = {} + user_scores_normalised = {} for user in user_answers_marks: user_scores[user] = sum( [i for i in user_answers_marks[user] if i != "unmarked"] ) + user_scores_normalised[user] = normaliseScore(sum( + [i for i in user_answers_marks[user] if i != "unmarked"] + )) user_scores_list = list(user_scores.values()) @@ -895,6 +921,7 @@ def exam_scores_cid(request, pk): "user_answers": dict(user_answers), "user_answers_marks": dict(user_answers_marks), "user_scores": user_scores, + "user_scores_normalised": user_scores_normalised, "user_scores_list": user_scores_list, "user_names": user_names, "user_answers_and_marks": user_answers_and_marks,