From f839ca4ed513ba9a35a2df68d9853ff5978c2013 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 8 Jan 2024 13:52:27 +0000 Subject: [PATCH] . --- generic/views.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/generic/views.py b/generic/views.py index 9e0c6e63..8bd44321 100644 --- a/generic/views.py +++ b/generic/views.py @@ -2131,8 +2131,11 @@ class ExamViews(View, LoginRequiredMixin): else: #Exclude very low scores from statistics lower_score_bound = max_score / 5 - - mean = statistics.mean([i for i in user_scores_list if i > lower_score_bound]) + bounded_scores = [i for i in user_scores_list if i > lower_score_bound] + if bounded_scores: + mean = statistics.mean(bounded_scores) + else: + mean = statistics.mean(user_scores_list) median = statistics.median(user_scores_list) try: mode = statistics.mode(user_scores_list)