示例#1
0
        public ActionResult GetInfoAndStartTest(string testingUrlGuid)
        {
            if (testingUrlGuid != null)
            {
                var domainTest = _getInfoService.GetTestByTestingUrlGuid(testingUrlGuid);

                if (domainTest != null)
                {
                    var questionViewModelList = domainTest
                                                ?.TestQuestions
                                                .Select(q => _mapper.Map <QuestionPassingViewModel>(q))
                                                .ToList();

                    var attepmtGuid = Guid.NewGuid().ToString();

                    var test = new CurrentTestPassingViewModel <QuestionPassingViewModel>()
                    {
                        TestTimeLimit     = domainTest.TestTimeLimit ?? new TimeSpan(),
                        QuestionTimeLimit = domainTest.QuestionTimeLimit ?? new TimeSpan(),
                        Questions         = questionViewModelList,
                        AttemptGuid       = attepmtGuid,
                        QuestionsSize     = questionViewModelList.Count
                    };
                    CurrentTest.AttemptGuid = attepmtGuid;

                    _advancedLogicService.StartQuiz(_getInfoService.GetTestingUrlByGuid(testingUrlGuid), attepmtGuid);

                    // return Json(test, JsonRequestBehavior.AllowGet);
                    return(View(test.Questions));
                }
            }
            return(HttpNotFound());
        }
示例#2
0
        public JsonResult GetInfoAndStartTest(string testingUrlGuid)
        {
            var domainTest = _getInfoService.GetTestByTestingUrlGuid(testingUrlGuid);

            var questionViewModelList = domainTest
                                        ?.TestQuestions
                                        .Select(q => _mapper.Map <QuestionPassingViewModel>(q))
                                        .ToList();

            var attepmtGuid = Guid.NewGuid().ToString();

            var test = new
            {
                TestTimeLimit     = domainTest.TestTimeLimit ?? new TimeSpan(),
                QuestionTimeLimit = domainTest.QuestionTimeLimit ?? new TimeSpan(),
                Questions         = questionViewModelList,
                AttemptGuid       = attepmtGuid
            };

            _advancedLogicService.StartQuiz(_getInfoService.GetTestingUrlByGuid(testingUrlGuid), attepmtGuid);
            return(Json(test, JsonRequestBehavior.AllowGet));
        }