public async Task <ActionResult> StartExam(int?ExamId) { if (ExamId != null && ExamId != 0) { var examId = Convert.ToInt32(ExamId); var examStartResource = new ExamStartResource(); List <QuestionsResource> questionlist = new List <QuestionsResource>(); var exam = await _examservice.GetByIdAsync(examId); examStartResource.ExamResource = Mapper.Map <Exam, ExamResource>(exam); var examQuestions = _examQuestionService.FindBy(i => i.ExamId == ExamId); foreach (var eq in examQuestions) { var questions = await _questionService.GetSingleIncludingAsync(Convert.ToInt32(eq.QuestionId), x => x.QuestionType, x => x.QuestionsLocalized); if (questions != null) { questionlist.Add(Mapper.Map <Questions, QuestionsResource>(questions)); } } examStartResource.QuestionsResource = questionlist; return(View(examStartResource)); } return(Redirect("/")); }
// GET: Admin/Exams/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Exam exam = await _examservice.GetByIdAsync(Convert.ToInt32(id)); if (exam == null) { return(HttpNotFound()); } var examResource = Mapper.Map <Exam, ExamResource>(exam); return(View(examResource)); }
/// <summary> /// Add Questions for Exam. We are adding questions for each exam /// </summary> /// <param name="id"></param> /// <returns></returns> // GET: Admin/ExamQuestions/AddQuestions/5 public async Task <ActionResult> AddQuestions(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var exam = await _examservice.GetByIdAsync(Convert.ToInt32(id)); if (exam == null) { return(RedirectToRoute(new { controller = "Exams", action = "Index", area = "Admin" })); } ExamQuestionViewModel examQuestionViewModel = new ExamQuestionViewModel(); examQuestionViewModel.ExamId = exam.Id; examQuestionViewModel.ExamName = exam.Name; return(View(examQuestionViewModel)); }