Exemple #1
0
        public ActionResult Results(ResultModel result)
        {
            var tempInfo = SessionTempinfo.GetValue();
            var incorrectQuestions = tempInfo.IncorrectQuestions;

            int[] ids = GetIds(incorrectQuestions);
            var questions = questionService.GetQuestions(ids);

            if (result.TestTitle == null)
                result = FillResult();

            result.Questions = questions;
            result.IncorrectQuestions = incorrectQuestions;
            int left = tempInfo.AmountOfQuestions - tempInfo.NumOfCurrentQuestion;
            var _questions = questionService.GetQuestions(tempInfo.TestId, tempInfo.NumOfCurrentQuestion, left);
            result.Questions.AddRange(_questions);

            userService.FillTestResult(result.ToTestResultEntity());

            SessionTempinfo.Clear();

            return PartialView("Results", result);
        }
Exemple #2
0
        private ResultModel FillResult()
        {
            var res = SessionTempinfo.GetValue();

            int testId = res.TestId;
            int amountOfCorrAnswers = res.CorrectAnswers;
            var amountOfQuestions = res.AmountOfQuestions;
            int resOfTest;

            var result = new ResultModel
            {
                AmountOfCorrectAnswers = amountOfCorrAnswers,
                AmountOfQuestions = amountOfQuestions,
                IsPassed = testService.TestPassed(testId, amountOfCorrAnswers, out resOfTest),
                ResultOfTest = resOfTest,
                TestId = testId,
                TestTitle = testService.GetTestEntityById(testId).Title,
                UserId = userService.GetIdByLogin(HttpContext.User.Identity.Name),
            };

            return result;
        }