Spaces:
Running
Running
def evaluate_answers(answers): | |
"""Calculate final score from all answers""" | |
if not answers: | |
return {"score": 0, "band": "N/A"} | |
total = sum(a["evaluation"]["score"] for a in answers) | |
avg_score = total / len(answers) | |
bands = [ | |
(9, "Excellent"), | |
(7, "Good"), | |
(5, "Average"), | |
(3, "Below Average"), | |
(0, "Poor") | |
] | |
band = next((b[1] for b in bands if avg_score >= b[0]), "N/A") | |
return { | |
"score": round(avg_score, 1), | |
"band": band, | |
"total_questions": len(answers) | |
} |