Ejemplo n.º 1
0
        public IActionResult ExamCreate(ExamDTO exam)
        {
            List <Post> postList = RSSHelper.GetAllPost(Url).ToList();

            Exam newExam = new Exam();

            newExam.Header      = postList.Where(a => a.Description == exam.Description).FirstOrDefault().Header;
            newExam.Description = exam.Description;
            examService.Insert(newExam);

            int k = 0;

            for (int i = 0; i < 4; i++)
            {
                Question newQuestion = new Question();
                newQuestion.ExamID       = newExam.ID;
                newQuestion.QuestionText = exam.Questions[i].QuestionText;
                questionService.Insert(newQuestion);

                for (int j = 0; j < 4; j++)
                {
                    Option newOption = new Option();
                    newOption.QuestionID = newQuestion.ID;
                    newOption.OptionText = exam.Options[k].OptionText;
                    newOption.IsCorrect  = (j + 65 == exam.Answers[i] ? true : false);
                    optionService.Insert(newOption);
                    k++;
                }
            }

            return(RedirectToAction("Login", "Account"));
        }
Ejemplo n.º 2
0
        public IActionResult ExamCreate()
        {
            List <Post>           postList    = RSSHelper.GetAllPost(Url).ToList();
            List <SelectListItem> selectLists = new List <SelectListItem>();

            foreach (var item in postList.Take(5))
            {
                selectLists.Add(new SelectListItem
                {
                    Text  = item.Header,
                    Value = item.Description
                });
            }
            ViewBag.Post = selectLists;
            return(View());
        }