示例#1
0
        public ResultsViewModel(TestViewModel submission)
        {
            this.CheckedAnswers = new List <CheckedAnswerViewModel>();
            var answers    = submission.Questions;
            var answerDtos = new List <SubmissionDTO>();


            foreach (var answer in answers)
            {
                answerDtos.Add(answer.ToDto());
            }

            var dtos = TestService.CheckSubmission(answerDtos);

            Title = SubtopicsService.GetOne(submission.TopicId).Name;
            int rightAnswersCount = 0;

            foreach (var answer in dtos)
            {
                rightAnswersCount += Convert.ToInt32(answer.Correctness);
            }

            Title += ". Результат: " + rightAnswersCount.ToString() + "/" + dtos.Count;

            dtos.ForEach(d => CheckedAnswers.Add(new CheckedAnswerViewModel(d)));
        }
示例#2
0
        public SubtopicViewModel(int id)
        {
            this.SubtopicId = id;
            var dto = SubtopicsService.GetOne(id);

            this.Title       = dto.Name + " (номер " + dto.TopicId + " из ОГЭ)";
            this.Name        = dto.Name;
            this.Description = HttpUtility.HtmlDecode(dto.Description);
            this.VideoLink   = dto.VideoLink;
        }
示例#3
0
        public SubtopicsListViewModel()
        {
            this.Subtopics = new List <SubtopicBasicViewModel>();

            var dtos = SubtopicsService.GetBasics();

            foreach (var dto in dtos)
            {
                this.Subtopics.Add(new SubtopicBasicViewModel(dto));
            }
        }
示例#4
0
        public TestViewModel(int id, TestType type)
        {
            this.Questions = new List <QuestionViewModel>();
            this.TopicId   = id;

            if (type == TestType.Subtopic)
            {
                this.Title = SubtopicsService.GetOne(id).Name + " - тест";
                var dtos = TestService.GetQuestionsForSubtopic(id);

                foreach (var dto in dtos)
                {
                    this.Questions.Add(new QuestionViewModel(dto));
                }
            }
        }