예제 #1
0
        public FubuContinuation Post(QuizTakeInputModel input)
        {
            var quiz = _quizService.GetById(input.QuizId);
            var take = _quizTakeFactory.GetOrCreate(input.TakeId, input.QuizId, _securityContext.CurrentUser.Identity.Name);
            var answer = new Answer(input.Question, quiz.IsAnswer(input.Question, input.SelectedAlternative), input.SelectedAlternative);

            take.UpdateAnswer(answer);

            if (quiz.Questions.Any(x => x.QuestionNumber == input.Question + 1))
            {
                return FubuContinuation.RedirectTo(input.Next, "GET");
            }

            _quizTakeService.Save(take);

            return FubuContinuation.RedirectTo(new QuizTakeResultsInputModel
                {
                    QuizId = input.QuizId,
                    TakeId = input.TakeId
                });
        }
예제 #2
0
파일: QuizTake.cs 프로젝트: emiaj/YouGrade
 public void UpdateAnswer(Answer answer)
 {
     lock (Answers)
     {
         if (Answers.Contains(answer))
         {
             Answers.Remove(answer);
         }
         Answers.Add(answer);
     }
 }