Jekyll2000 commited on
Commit
6c961d1
·
verified ·
1 Parent(s): f9fd05d

Create utils/evaluator.py

Browse files
Files changed (1) hide show
  1. utils/evaluator.py +23 -0
utils/evaluator.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def evaluate_answers(answers):
2
+ """Calculate final score from all answers"""
3
+ if not answers:
4
+ return {"score": 0, "band": "N/A"}
5
+
6
+ total = sum(a["evaluation"]["score"] for a in answers)
7
+ avg_score = total / len(answers)
8
+
9
+ bands = [
10
+ (9, "Excellent"),
11
+ (7, "Good"),
12
+ (5, "Average"),
13
+ (3, "Below Average"),
14
+ (0, "Poor")
15
+ ]
16
+
17
+ band = next((b[1] for b in bands if avg_score >= b[0]), "N/A")
18
+
19
+ return {
20
+ "score": round(avg_score, 1),
21
+ "band": band,
22
+ "total_questions": len(answers)
23
+ }