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))); }
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; }
public SubtopicsListViewModel() { this.Subtopics = new List <SubtopicBasicViewModel>(); var dtos = SubtopicsService.GetBasics(); foreach (var dto in dtos) { this.Subtopics.Add(new SubtopicBasicViewModel(dto)); } }
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)); } } }