Merge branch '141-richtig-schones-cooles-siegerpodest-2' into 'master'
Resolve "Richtig schönes, cooles Siegerpodest." Closes #141 See merge request enrichment-2024/qivip!106
This commit is contained in:
@@ -128,6 +128,15 @@ class GameConsumer(AsyncWebsocketConsumer):
|
||||
host_id = text_data_json['host_id']
|
||||
if await self.verify_host(host_id):
|
||||
await self.advance_to_next_question()
|
||||
elif message_type == 'winner_podest':
|
||||
host_id = text_data_json['host_id']
|
||||
if await self.verify_host(host_id):
|
||||
await self.show_winner_podest()
|
||||
|
||||
elif message_type == 'scoreboard':
|
||||
host_id = text_data_json['host_id']
|
||||
if await self.verify_host(host_id):
|
||||
await self.show_scoreboard()
|
||||
|
||||
elif message_type == 'finish_game':
|
||||
host_id = text_data_json['host_id']
|
||||
@@ -431,6 +440,26 @@ class GameConsumer(AsyncWebsocketConsumer):
|
||||
'redirect_url': reverse('play:question', kwargs={'join_code': self.join_code})
|
||||
}
|
||||
)
|
||||
elif result == 'winner_podest':
|
||||
# Notify clients to redirect to next question
|
||||
await self.channel_layer.group_send(
|
||||
self.game_group_name,
|
||||
{
|
||||
'type': 'game_state_update',
|
||||
'action': 'show_winner_podest',
|
||||
'redirect_url': reverse('play:winner_podest', kwargs={'join_code': self.join_code})
|
||||
}
|
||||
)
|
||||
elif result == 'scoreboard':
|
||||
# Notify clients to redirect to next question
|
||||
await self.channel_layer.group_send(
|
||||
self.game_group_name,
|
||||
{
|
||||
'type': 'game_state_update',
|
||||
'action': 'show_scoreboard',
|
||||
'redirect_url': reverse('play:scoreboard', kwargs={'join_code': self.join_code})
|
||||
}
|
||||
)
|
||||
|
||||
@database_sync_to_async
|
||||
def _show_scores(self):
|
||||
@@ -477,3 +506,48 @@ class GameConsumer(AsyncWebsocketConsumer):
|
||||
'redirect_url': reverse('play:finished', kwargs={'join_code': self.join_code})
|
||||
}
|
||||
)
|
||||
@database_sync_to_async
|
||||
def _show_winner_podest(self):
|
||||
try:
|
||||
quiz_game = QuizGame.objects.get(join_code=self.join_code)
|
||||
quiz_game.current_state = 'winner_podest'
|
||||
quiz_game.save()
|
||||
return True
|
||||
except QuizGame.DoesNotExist:
|
||||
return False
|
||||
|
||||
async def show_winner_podest(self):
|
||||
success = await self._show_winner_podest()
|
||||
if success:
|
||||
# Notify clients to redirect to finished page
|
||||
await self.channel_layer.group_send(
|
||||
self.game_group_name,
|
||||
{
|
||||
'type': 'game_state_update',
|
||||
'action': 'show_winner_podest',
|
||||
'redirect_url': reverse('play:winner_podest', kwargs={'join_code': self.join_code})
|
||||
}
|
||||
)
|
||||
|
||||
@database_sync_to_async
|
||||
def _show_scoreboard(self):
|
||||
try:
|
||||
quiz_game = QuizGame.objects.get(join_code=self.join_code)
|
||||
quiz_game.current_state = 'scoreboard'
|
||||
quiz_game.save()
|
||||
return True
|
||||
except QuizGame.DoesNotExist:
|
||||
return False
|
||||
|
||||
async def show_scoreboard(self):
|
||||
success = await self._show_scoreboard()
|
||||
if success:
|
||||
# Notify clients to redirect to finished page
|
||||
await self.channel_layer.group_send(
|
||||
self.game_group_name,
|
||||
{
|
||||
'type': 'game_state_update',
|
||||
'action': 'show_scoreboard',
|
||||
'redirect_url': reverse('play:scoreboard', kwargs={'join_code': self.join_code})
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user