public ActionResult QuizStartPage() { if (Session["STD_ID"] == null) { return(RedirectToAction("StudentLogin")); } TBL_QUESTION questions = null; if (TempData["Question"] != null) { Queue <TBL_QUESTION> qlist = (Queue <TBL_QUESTION>)TempData["Question"]; if (qlist.Count > 0) { questions = qlist.Peek(); qlist.Dequeue(); TempData["Question"] = qlist; TempData.Keep(); } else { return(RedirectToAction("EndExam")); } } else { return(RedirectToAction("StudentExam")); } return(View(questions)); }
public ActionResult QuizStartPage(TBL_QUESTION question) { string correctAns = null; if (question.OPA != null) { correctAns = "A"; } else if (question.OPB != null) { correctAns = "B"; } else if (question.OPC != null) { correctAns = "C"; } else if (question.OPD != null) { correctAns = "D"; } if (correctAns.Equals(question.COP)) { TempData["Score"] = Convert.ToInt32(TempData["Score"]) + 1; } TempData.Keep(); return(RedirectToAction("QuizStartPage")); }
public ActionResult AddQuestions(TBL_QUESTION question) { int sid = Convert.ToInt32(Session["AD_ID"]); List <TBL_CATEGORY> cat = onlineExamDB.TBL_CATEGORY.Where(x => x.CAT_PK_ADID == sid).ToList(); ViewBag.list = new SelectList(cat, "CAT_ID", "CAT_NAME"); TBL_QUESTION quest = new TBL_QUESTION(); quest.Q_TEXT = question.Q_TEXT; quest.OPA = question.OPA; quest.OPB = question.OPB; quest.OPC = question.OPC; quest.OPD = question.OPD; quest.COP = question.COP; quest.Q_FK_CATID = question.Q_FK_CATID; onlineExamDB.TBL_QUESTION.Add(quest); onlineExamDB.SaveChanges(); TempData["msg"] = "Question added Successfully.....!"; TempData.Keep(); return(RedirectToAction("AddQuestions")); }