Ejemplo n.º 1
0
        public void UpdateCurrentState(ContextStateType state)
        {
            using (var db = new QuizWebAppDb())
            {
                var context = db.Contexts.First();
                context.CurrentState = state;

                // if change state to "3:show answer", judge to all players.
                if (state == ContextStateType.ShowCorrectAnswer)
                {
                    var answers = db
                        .Answers
                        .Where(a => a.QuestionID == context.CurrentQuestionID)
                        .ToList();
                    var currentQuestion = db.Questions.Find(context.CurrentQuestionID);

                    answers
                        .ForEach(a => a.Status =
                            a.ChoosedOptionIndex == currentQuestion.IndexOfCorrectOption
                            ? AnswerStateType.Correct : AnswerStateType.Incorrect);
                }

                db.SaveChanges();
            }

            Clients.All.CurrentStateChanged(state.ToString());
        }
Ejemplo n.º 2
0
        public void UpdateCurrentState(ContextStateType state)
        {
            using (var db = new QuizWebAppDb())
            {
                var context = db.Contexts.First();
                context.CurrentState = state;

                // if change state to "3:show answer", judge to all players.
                if (state == ContextStateType.ShowCorrectAnswer)
                {
                    var answers = db
                                  .Answers
                                  .Where(a => a.QuestionID == context.CurrentQuestionID)
                                  .ToList();
                    var currentQuestion = db.Questions.Find(context.CurrentQuestionID);

                    answers
                    .ForEach(a => a.Status =
                                 a.ChoosedOptionIndex == currentQuestion.IndexOfCorrectOption
                            ? AnswerStateType.Correct : AnswerStateType.Incorrect);
                }

                db.SaveChanges();
            }

            Clients.All.CurrentStateChanged(state.ToString());
        }
Ejemplo n.º 3
0
        public void Reset()
        {
            State = ContextStateType.Begin;

            ObjectIndex = -1;
            MemberIndex = -1;

            m_Refs = new List <NomadData>();
            m_Ptrs = new List <long>();
        }
        public ActionResult CurrentState(ContextStateType state)
        {
            var context = DB.Contexts.First();
            context.CurrentState = state;

            // if change state to "3:show answer", judge to all players.
            if (state == ContextStateType.ShowCorrectAnswer)
            {
                var answers = DB
                    .Answers
                    .Where(a => a.QuestionId == context.CurrentQuestionId)
                    .ToList();
                var currentQuestion = DB.Questions.Find(context.CurrentQuestionId);

                answers
                    .ForEach(a => a.Status =
                        a.ChosenOptionIndex == currentQuestion.IndexOfCorrectOption
                        ? AnswerStateType.Correct : AnswerStateType.Incorrect);
            }
            DB.SaveChanges();

            return Json(new { });
        }
Ejemplo n.º 5
0
 public void End()
 {
     State = ContextStateType.End;
 }
Ejemplo n.º 6
0
 public void UpdateCurrentState(ContextStateType state)
 {            
     Clients.All.CurrentStateChanged(state.ToString());
 }