This commit is contained in:
Ross
2021-09-09 12:29:38 +01:00
parent fd7ecf287c
commit 857340947e
4 changed files with 30 additions and 1 deletions
+26
View File
@@ -75,6 +75,26 @@ import os
logger = logging.getLogger(__name__)
def normaliseScore(score):
if score >= 25.5 and score <= 28:
return 4.5
elif score >= 28.5 and score <= 31:
return 5
elif score >= 31.5 and score <= 34:
return 5.5
elif score >= 34.5 and score <= 37:
return 6
elif score >= 37.5 and score <= 40:
return 6.5
elif score >= 40.5 and score <= 43:
return 7
elif score >= 43.5 and score <= 46:
return 7.5
elif score >= 46.5 and score <= 48:
return 7.5
return 4
class AuthorOrCheckerRequiredMixin(object):
def get_object(self, *args, **kwargs):
@@ -822,10 +842,13 @@ def exam_scores_cid(request, pk):
by_question[q].append((ans, answer_score))
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 != ""]
)
user_scores_normalised = normaliseScore(user_scores[user])
user_scores_list = list(user_scores.values())
@@ -867,6 +890,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,
@@ -924,6 +948,7 @@ def exam_scores_cid_user(request, pk, sk):
total_score = "{} ({} unmarked)".format(total_score, unmarked_number)
else:
total_score = sum(answered)
normalised_score = normaliseScore(total_score)
max_score = len(questions) * 2
@@ -937,6 +962,7 @@ def exam_scores_cid_user(request, pk, sk):
#"answers": answers,
"answers_marks": answers_marks,
"total_score": total_score,
"normalised_score": normalised_score,
"max_score": max_score,
"answer_text": answer_text
#"answers_and_marks": answers_and_marks,