Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -149,7 +149,13 @@ def generate_feedback(user_profile):
|
|
| 149 |
questions = user_profile.get('questions', [])
|
| 150 |
answers = user_profile.get('user_answers', [])
|
| 151 |
|
| 152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
correct_answers = questions[i]['answers']
|
| 154 |
match = any(ans.lower() in user_ans.lower() for ans in correct_answers)
|
| 155 |
if match:
|
|
@@ -157,6 +163,7 @@ def generate_feedback(user_profile):
|
|
| 157 |
else:
|
| 158 |
fb = f"Question {i+1}: β You missed some key points: {correct_answers[0]}"
|
| 159 |
feedback.append(fb)
|
|
|
|
| 160 |
return "\n".join(feedback)
|
| 161 |
|
| 162 |
# ---- Gradio Interface ----
|
|
|
|
| 149 |
questions = user_profile.get('questions', [])
|
| 150 |
answers = user_profile.get('user_answers', [])
|
| 151 |
|
| 152 |
+
num_questions = min(len(questions), len(answers)) # avoid index error
|
| 153 |
+
|
| 154 |
+
if num_questions == 0:
|
| 155 |
+
return "No completed interview found. Please complete the interview first."
|
| 156 |
+
|
| 157 |
+
for i in range(num_questions):
|
| 158 |
+
user_ans = answers[i]
|
| 159 |
correct_answers = questions[i]['answers']
|
| 160 |
match = any(ans.lower() in user_ans.lower() for ans in correct_answers)
|
| 161 |
if match:
|
|
|
|
| 163 |
else:
|
| 164 |
fb = f"Question {i+1}: β You missed some key points: {correct_answers[0]}"
|
| 165 |
feedback.append(fb)
|
| 166 |
+
|
| 167 |
return "\n".join(feedback)
|
| 168 |
|
| 169 |
# ---- Gradio Interface ----
|