Skip to content

Commit 1c41ba6

Browse files
committed
last question or not check function in the answer api
1 parent 19d7814 commit 1c41ba6

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

api/views.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,23 @@ def post(self,request):
5959
if active:
6060
day=config.objects.all()[0].current_day
6161
curr_question=player.current_question
62+
if curr_question>config.objects.all()[0].q_no:
63+
response={
64+
"quiz_finished": True
65+
}
66+
return Response(response)
6267
question=Question.objects.filter(day=day,question_no=curr_question)
6368
result=Question.check_ans(Question,answer,question)
6469
if result:
6570
player.new_score(player)
71+
quiz_ended=False
72+
if curr_question==config.objects.all()[0].q_no:
73+
quiz_ended=True
6674
response={
67-
'status_code':status.HTTP_200_OK,
68-
'result':result
69-
}
75+
'status_code':status.HTTP_200_OK,
76+
'result':result,
77+
'quiz_ended':quiz_ended
78+
}
7079
else:
7180
response= {
7281
"error":"quiz has ended"

0 commit comments

Comments
 (0)