示例#1
0
        public void LeaveQuiz()
        {
            var player = GetCurrentPlayer();
            var quiz   = GetCurrentQuiz();

            if (quiz == null)
            {
                Clients.Caller.message("You are not in a room");
            }
            else
            {
                // Delete Quiz room if no players are in it
                if (quiz.Players.Count - 1 == 0)
                {
                    Groups.Remove(Context.ConnectionId, quiz.Name);
                    Quizzes.Remove(quiz);
                }
                else
                {
                    quiz.Players.Remove(player);
                    PlayersInLobby(quiz);
                    MessageGroup(player.Name + " left the room", quiz.Name);
                    Groups.Remove(Context.ConnectionId, quiz.Name);
                }

                player.Score = 0;
                player.Ready = false;
                Clients.Caller.reset();
                Clients.Caller.message("Left room '" + quiz.Name + "'");
            }
        }
示例#2
0
        public async Task <IActionResult> Remove(long id)
        {
            if (!await Quizzes.CheckIfQuizExists(id))
            {
                return(NotFound());
            }

            await Quizzes.Remove(id);

            return(Ok());
        }
示例#3
0
        private void QuizWindowClosed(object sender, EventArgs e)
        {
            if (!Repo.DoesGradeExcist(SelectedQuizId, LoggedInUserId))
            {
                Quizzes.Remove(UtilityTestVerktyg.SelectedQuiz);

                var userGrade = new Grade
                {
                    CompletionDate = DateTime.Now,
                    QuizId         = SelectedQuizId,
                    UserId         = LoggedInUserId,
                    UserScore      = CurrentPoints.Sum(),
                    UserGrade      = (CurrentPoints.Sum() > QuizLength / 2) ? "G" : "IG"
                };
                Repo.SaveUserQuizScore(userGrade);
            }
            UtilityTestVerktyg.GetUserGrade(LoggedInUserId);
            lv_Result.ItemsSource           = UtilityTestVerktyg.UserGrades;
            UtilityTestVerktyg.SelectedQuiz = null;
        }