@@ -23,18 +23,23 @@ def join_quiz(participant: quizEntry_schema.Participant):
23
23
raise HTTPException (status_code = status .HTTP_500_INTERNAL_SERVER_ERROR , detail = f"Failed to register participant: { e } " )
24
24
25
25
# Fetch quiz questions
26
- questions = supabase .table ("questions" ).select ("question" , "answers" , "correct_answer" ).eq ("room_key" , participant .room_key ).execute ()
26
+ questions = supabase .table ("questions" ).select ("question" , "answers" , "correct_answer" , "time" ).eq ("room_key" , participant .room_key ).execute ()
27
27
if not questions .data :
28
28
raise HTTPException (status_code = status .HTTP_404_NOT_FOUND , detail = "No questions found for the quiz" )
29
29
30
+ response = [quizEntry_schema .questionResponse (
31
+ question = question ["question" ],
32
+ answers = question ["answers" ]["answers" ],
33
+ correct_answer = question ["correct_answer" ],
34
+ time = question ["time" ]
35
+ ) for question in questions .data ]
36
+
30
37
# Return list of questions
31
- return [ quizEntry_schema .Question (
38
+ return quizEntry_schema .Question (
32
39
id = result .data [0 ]["id" ],
33
40
room_key = participant .room_key ,
34
- question = question ["question" ],
35
- answers = question ["answers" ]["answers" ],
36
- correct_answer = question ["correct_answer" ]
37
- ) for question in questions .data ]
41
+ questions = response
42
+ )
38
43
39
44
except Exception as e :
40
45
raise HTTPException (status_code = status .HTTP_500_INTERNAL_SERVER_ERROR , detail = f"Failed to join quiz: { e } " )
@@ -76,7 +81,7 @@ def create_room(host_id: int):
76
81
except Exception as e :
77
82
raise HTTPException (status_code = status .HTTP_500_INTERNAL_SERVER_ERROR , detail = f"Failed to create room: { e } " )
78
83
79
- def add_questions (questions : List [quizEntry_schema .AddQuestion ], user_id : int ):
84
+ def add_questions (questions : List [quizEntry_schema .AddQuestion ], user_id : int , time : int ):
80
85
try :
81
86
# create a new room
82
87
room_key = create_room (user_id )["room_key" ]
@@ -90,7 +95,8 @@ def add_questions(questions: List[quizEntry_schema.AddQuestion], user_id: int):
90
95
"room_key" : room_key ,
91
96
"question" : question .question ,
92
97
"answers" : answers_json ,
93
- "correct_answer" : question .correct_answer
98
+ "correct_answer" : question .correct_answer ,
99
+ "time" : time
94
100
}).execute ()
95
101
96
102
print ("Questions added successfully" )
0 commit comments