Refactor score count variable names for clarity in exam review question summary logic

This commit is contained in:
Ross
2025-11-10 11:06:55 +00:00
parent 486a897e64
commit fdc60bf2e9
2 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -376,7 +376,7 @@ def exam_review_question_summary(request, pk: int, q_index: int):
top_answers = []
for ans, meta in answer_map.items():
# pick dominant score by highest count; tie-break prefer higher numeric score
score_counts = meta["score_counts"]
ans_score_counts = meta["score_counts"]
# sort by (count desc, score desc) where 'empty' maps to -1
def score_key(item):
s, c = item
@@ -390,7 +390,7 @@ def exam_review_question_summary(request, pk: int, q_index: int):
s_val = -1
return (c, s_val)
dominant = max(score_counts.items(), key=score_key)[0]
dominant = max(ans_score_counts.items(), key=score_key)[0]
top_answers.append({"answer_compare": ans, "count": meta["total"], "dominant_score": dominant})
top_answers.sort(key=lambda x: x["count"], reverse=True)