From 7e3c9bf933e842b1f039cfbe3a4c262574c185e6 Mon Sep 17 00:00:00 2001 From: Ross Date: Wed, 17 Feb 2021 14:33:22 +0000 Subject: [PATCH] . --- longs/models.py | 10 +++++----- longs/views.py | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/longs/models.py b/longs/models.py index 015d66c3..c44bee49 100644 --- a/longs/models.py +++ b/longs/models.py @@ -407,13 +407,13 @@ class CidUserAnswer(models.Model): class ScoreOptions(models.TextChoices): UNMARKED = "", _("Unmarked") FOUR = 4, _("4") - FOUR_HALF = "4.5", _("4.5") + FOUR_HALF = 4.5, _("4.5") FIVE = 5, _("5") - FIVE_HALF = "5.5", _("5.5") + FIVE_HALF = 5.5, _("5.5") SIX = 6, _("6") - SIX_HALF = "6.5", _("6.5") + SIX_HALF = 6.5, _("6.5") SEVEN = 7, _("7") - SEVEN_HALF = "7.5", _("7.5") + SEVEN_HALF = 7.5, _("7.5") EIGHT = 8, _("8") score = models.CharField( @@ -458,4 +458,4 @@ class CidUserAnswer(models.Model): return True def get_answer_score(self): - return self.score + return float(self.score) diff --git a/longs/views.py b/longs/views.py index 33ff7943..c2e86c9b 100755 --- a/longs/views.py +++ b/longs/views.py @@ -807,7 +807,7 @@ def exam_scores_cid(request, pk): user_scores = {} for user in user_answers_marks: user_scores[user] = sum( - [float(i) for i in user_answers_marks[user] if i != ""] + [i for i in user_answers_marks[user] if i != ""] ) user_scores_list = list(user_scores.values()) @@ -894,13 +894,13 @@ def exam_scores_cid_user(request, pk, sk): answers_marks.append(answer_score) #answers_and_marks.append((ans, answer_score, correct_answer)) + answered = [i for i in answers_marks if i != ""] if "" in answers_marks: - answered = [int(i) for i in answers_marks if i != ""] total_score = sum(answered) unmarked_number = len(answers_marks) - len(answered) total_score = "{} ({} unmarked)".format(total_score, unmarked_number) else: - total_score = sum(answers_marks) + total_score = sum(answered) max_score = len(questions) * 2