maahikachitagi commited on
Commit
08fd09d
Β·
verified Β·
1 Parent(s): daad191

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
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
- for i, user_ans in enumerate(answers):
 
 
 
 
 
 
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 ----