sajith-0701 commited on
Commit
d56d27f
·
1 Parent(s): 662e9fa
backend/services/interview_service.py CHANGED
@@ -1,5 +1,6 @@
1
  import json
2
  import asyncio
 
3
  from bson import ObjectId
4
  from database import get_db, get_redis
5
  from models.collections import SESSIONS, USERS, JOB_ROLES, SKILLS, QUESTIONS, TOPICS, TOPIC_QUESTIONS, ROLE_REQUIREMENTS, RESUMES
@@ -431,7 +432,7 @@ async def _start_topic_interview(user_id: str, topic_id: str) -> dict:
431
  if not topic.get("is_published", False):
432
  raise ValueError("This topic interview is not published yet")
433
 
434
- topic_questions = await db[TOPIC_QUESTIONS].find({"topic_id": topic_id}).sort("created_at", -1).to_list(length=200)
435
  if not topic_questions:
436
  raise ValueError("No questions found for selected topic")
437
 
@@ -439,6 +440,8 @@ async def _start_topic_interview(user_id: str, topic_id: str) -> dict:
439
  timer_seconds = topic.get("timer_seconds") if timer_enabled else None
440
 
441
  total_questions = min(MAX_QUESTIONS, len(topic_questions))
 
 
442
  selected = topic_questions[:total_questions]
443
 
444
  session_id = generate_id()
 
1
  import json
2
  import asyncio
3
+ import random
4
  from bson import ObjectId
5
  from database import get_db, get_redis
6
  from models.collections import SESSIONS, USERS, JOB_ROLES, SKILLS, QUESTIONS, TOPICS, TOPIC_QUESTIONS, ROLE_REQUIREMENTS, RESUMES
 
432
  if not topic.get("is_published", False):
433
  raise ValueError("This topic interview is not published yet")
434
 
435
+ topic_questions = await db[TOPIC_QUESTIONS].find({"topic_id": topic_id}).to_list(length=200)
436
  if not topic_questions:
437
  raise ValueError("No questions found for selected topic")
438
 
 
440
  timer_seconds = topic.get("timer_seconds") if timer_enabled else None
441
 
442
  total_questions = min(MAX_QUESTIONS, len(topic_questions))
443
+ # Randomize question selection for each interview session
444
+ random.shuffle(topic_questions)
445
  selected = topic_questions[:total_questions]
446
 
447
  session_id = generate_id()