refactor: improve score distribution display and enhance HTMX handling in exam views
This commit is contained in:
+6
-8
@@ -4066,10 +4066,6 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
pass_rate = 0.0
|
||||
|
||||
if len(user_scores_list) >= 1:
|
||||
lower_score_bound = max_score / 5
|
||||
bounded_scores = [i for i in user_scores_list if i > lower_score_bound]
|
||||
if bounded_scores:
|
||||
user_scores_list = bounded_scores
|
||||
|
||||
mean = round(statistics.mean(user_scores_list), 2)
|
||||
median = round(statistics.median(user_scores_list), 2)
|
||||
@@ -4248,12 +4244,14 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
exam.save()
|
||||
|
||||
from django.urls import reverse
|
||||
from django.http import HttpResponseRedirect
|
||||
url = reverse(f"{self.app_name}:exam_scores_all", kwargs={"pk": pk})
|
||||
response = HttpResponseRedirect(url)
|
||||
if request.htmx:
|
||||
response["HX-Redirect"] = url
|
||||
return response
|
||||
# Return 200 OK with HX-Redirect header to trigger client-side redirect in HTMX
|
||||
return HttpResponse("", headers={"HX-Redirect": url})
|
||||
|
||||
# Standard non-HTMX redirect
|
||||
from django.http import HttpResponseRedirect
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
def toggle_candidate_stats_exclusion(self, request, pk):
|
||||
exam = get_object_or_404(self.Exam, pk=pk)
|
||||
|
||||
Reference in New Issue
Block a user