From fd7ecf287cad1f8d8216c9d0c3982a33e5fb1e46 Mon Sep 17 00:00:00 2001 From: Ross Date: Thu, 9 Sep 2021 12:21:08 +0100 Subject: [PATCH] . --- rapids/templates/rapids/exam_scores_user.html | 1 + rapids/views.py | 45 ++++++++++--------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/rapids/templates/rapids/exam_scores_user.html b/rapids/templates/rapids/exam_scores_user.html index d4117d65..48635c6c 100644 --- a/rapids/templates/rapids/exam_scores_user.html +++ b/rapids/templates/rapids/exam_scores_user.html @@ -21,6 +21,7 @@ {% endfor %}
Total mark: {{ total_score }} / {{max_score}} +
Normalised score: {{ normalised_score }}
Other exams
diff --git a/rapids/views.py b/rapids/views.py index eca0cd70..58fd6123 100755 --- a/rapids/views.py +++ b/rapids/views.py @@ -86,6 +86,26 @@ from generic.mixins import SuperuserRequiredMixin logger = logging.getLogger(__name__) +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 + class AuthorOrCheckerRequiredMixin(object): def get_object(self, *args, **kwargs): obj = super().get_object(*args, **kwargs) @@ -849,26 +869,6 @@ 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 = {} @@ -980,7 +980,9 @@ def exam_scores_cid_user(request, pk, cid): else: total_score = sum(answers_marks) - max_score = len(questions) + normalised_score = normaliseScore(total_score) + + max_score = len(questions) * 2 return render( request, @@ -992,6 +994,7 @@ def exam_scores_cid_user(request, pk, cid): "answers": answers, "answers_marks": answers_marks, "total_score": total_score, + "normalised_score": normalised_score, "max_score": max_score, "answers_and_marks": answers_and_marks, },