def raiseError(error_message) -> None: """ Raise an error and send it to connected users. :param error_message: String - The error message to raise. """ emit( SOCKET_EVENT_NOTIFICATION_MESSAGE, { "message": 'Error raised: ' + error_message, "level": NOTIFICATION_LEVEL_ERROR })
def sendNextQuestion() -> None: """ Send event to frontend the next question. """ emit( SOCKET_EVENT_QUIZ_NEXT_QUESTION, { "index": quiz_store.currentQuestionIndex, "question": quiz_store.listQuestions[quiz_store.currentQuestionIndex - 1].toJson() })
def sendStatsAnswersOngoing() -> None: """ Send stats to frontend containing the number of player which gave an answer. """ emit( SOCKET_EVENT_STATS_ANSWERS_ONGOING, { "numberAnswers": len( list( filter( lambda contestant: contestant.selected_answer is not None, quiz_store.listContestants))) })
def sendEventStopQuiz() -> None: """ Send an event to stop the quiz. """ emit(SOCKET_EVENT_QUIZ_STOP)
def sendStatsAnswerQuestion() -> None: """ Send stats of the last question. (Each number of vote for each answer) """ # TODO emit(SOCKET_EVENT_STATS_ANSWERS_QUESTION, {})
def sendContestantCheckInStatistics() -> None: """ Send contestants check-in statistics to front-end clients. """ emit(SOCKET_EVENT_STATS_CONSTESTANTS_CHECK_IN, {"number_contestants": len(quiz_store.listContestants)})