public ActionResult DoQuestion(int id) { //Session["exam"] = 2; //Response.Cookies["m"].Value = "0"; //Response.Cookies["s"].Value = "5"; string user = OperateContext.Current.User; Session["CurrentUsrTime"] = "60"; ViewData["CurrentUsrTime"] = Session["CurrentUsrTime"]; if (id == 1) { //第一次访问 ViewData["typeId"] = id; if (Session["questionList1"] == null) { //找到正在发布中的试卷id int paperId = OperateContext.Current.BLLSession .IPaperBLL.GetListBy(p => p.IsPublished == true && p.typeId == id).Select(p => p.ID).First(); //根据试卷id找到对应的试题id集合 List <int> questionList = OperateContext.Current.BLLSession .IPaperQuestionBLL.GetListBy(p => p.PaperID == paperId) .OrderBy(p => p.T_Question.QuestionTypeID) .Select(p => p.QuestionID).ToList(); //保存题目总数 Session["questionCount1"] = questionList.Count; ViewData["questionCount"] = questionList.Count; ViewData["questionIndex"] = 1; //保存列表中第一题的题号 ViewData["questionID"] = questionList[0]; //题号列表保存到Session Session["questionList1"] = questionList; //生成答卷 //从Session中取出面试者信息 MODEL.T_InterviewerInfo interviewerInfo = (MODEL.T_InterviewerInfo)Session["interviewerInfo"]; MODEL.T_AnswerSheet asModel = new MODEL.T_AnswerSheet() { InterviewerID = interviewerInfo.ID, PaperID = paperId }; OperateContext.Current.BLLSession.IAnswerSheetBLL.Add(asModel); } else { //从Session中取出题号列表 List <int> questionList = (List <int>)Session["questionList1"]; if (questionList.Count > 0) { //取出列表中第一题的题号 ViewData["questionID"] = questionList[0]; ViewData["questionCount"] = (int)Session["questionCount1"]; ViewData["questionIndex"] = (int)Session["questionCount1"] - questionList.Count + 1; } else { Session["questionList1"] = null; Session["questionCount1"] = null; Session["interviewerInfo"] = null; return(Redirect("/JoinUs/BeginTest/AccessCommit")); } } return(View()); } else if (id == 2) { //第一次访问 ViewData["typeId"] = id; if (Session["questionList2"] == null) { //找到正在发布中的试卷id int paperId = OperateContext.Current.BLLSession .IPaperBLL.GetListBy(p => p.IsPublished == true && p.typeId == id).Select(p => p.ID).First(); //根据试卷id找到对应的试题id集合 List <int> questionList = OperateContext.Current.BLLSession .IPaperQuestionBLL.GetListBy(p => p.PaperID == paperId) .OrderBy(p => p.T_Question.QuestionTypeID) .Select(p => p.QuestionID).ToList(); //保存题目总数 Session["questionCount2"] = questionList.Count; ViewData["questionCount"] = questionList.Count; ViewData["questionIndex"] = 1; //保存列表中第一题的题号 ViewData["questionID"] = questionList[0]; //题号列表保存到Session Session["questionList2"] = questionList; //生成答卷 //从Session中取出面试者信息 MODEL.T_InterviewerInfo interviewerInfo = (MODEL.T_InterviewerInfo)Session["interviewerInfo"]; MODEL.T_AnswerSheet asModel = new MODEL.T_AnswerSheet() { InterviewerID = interviewerInfo.ID, PaperID = paperId }; OperateContext.Current.BLLSession.IAnswerSheetBLL.Add(asModel); } else { //从Session中取出题号列表 List <int> questionList = (List <int>)Session["questionList2"]; if (questionList.Count > 0) { //取出列表中第一题的题号 ViewData["questionID"] = questionList[0]; ViewData["questionCount"] = (int)Session["questionCount2"]; ViewData["questionIndex"] = (int)Session["questionCount2"] - questionList.Count + 1; } else { Session["questionList2"] = null; Session["questionCount2"] = null; Session["interviewerInfo"] = null; return(Redirect("/JoinUs/BeginTest/AccessCommit")); } } return(View()); } else { //第一次访问 ViewData["typeId"] = id; if (Session["questionList3"] == null) { //找到正在发布中的试卷id int paperId = OperateContext.Current.BLLSession .IPaperBLL.GetListBy(p => p.IsPublished == true && p.typeId == id).Select(p => p.ID).First(); //根据试卷id找到对应的试题id集合 List <int> questionList = OperateContext.Current.BLLSession .IPaperQuestionBLL.GetListBy(p => p.PaperID == paperId) .OrderBy(p => p.T_Question.QuestionTypeID) .Select(p => p.QuestionID).ToList(); //保存题目总数 Session["questionCount3"] = questionList.Count; ViewData["questionCount"] = questionList.Count; ViewData["questionIndex"] = 1; //保存列表中第一题的题号 ViewData["questionID"] = questionList[0]; //题号列表保存到Session Session["questionList3"] = questionList; //生成答卷 //从Session中取出面试者信息 MODEL.T_InterviewerInfo interviewerInfo = (MODEL.T_InterviewerInfo)Session["interviewerInfo"]; MODEL.T_AnswerSheet asModel = new MODEL.T_AnswerSheet() { InterviewerID = interviewerInfo.ID, PaperID = paperId }; OperateContext.Current.BLLSession.IAnswerSheetBLL.Add(asModel); } else { //从Session中取出题号列表 List <int> questionList = (List <int>)Session["questionList3"]; if (questionList.Count > 0) { //取出列表中第一题的题号 ViewData["questionID"] = questionList[0]; ViewData["questionCount"] = (int)Session["questionCount3"]; ViewData["questionIndex"] = (int)Session["questionCount3"] - questionList.Count + 1; } else { Session["questionList3"] = null; Session["questionCount3"] = null; Session["interviewerInfo"] = null; return(Redirect("/JoinUs/BeginTest/AccessCommit")); } } return(View()); } }
public ActionResult DoQuestion(int id) { //Session["exam"] = 2; //Response.Cookies["m"].Value = "0"; //Response.Cookies["s"].Value = "5"; string user = OperateContext.Current.User; Session["CurrentUsrTime"] = "60"; ViewData["CurrentUsrTime"] = Session["CurrentUsrTime"]; if (id == 1) { //第一次访问 ViewData["typeId"]=id; if (Session["questionList1"] == null) { //找到正在发布中的试卷id int paperId = OperateContext.Current.BLLSession .IPaperBLL.GetListBy(p => p.IsPublished == true && p.typeId == id).Select(p => p.ID).First(); //根据试卷id找到对应的试题id集合 List<int> questionList = OperateContext.Current.BLLSession .IPaperQuestionBLL.GetListBy(p => p.PaperID == paperId) .OrderBy(p => p.T_Question.QuestionTypeID) .Select(p => p.QuestionID).ToList(); //保存题目总数 Session["questionCount1"] = questionList.Count; ViewData["questionCount"] = questionList.Count; ViewData["questionIndex"] = 1; //保存列表中第一题的题号 ViewData["questionID"] = questionList[0]; //题号列表保存到Session Session["questionList1"] = questionList; //生成答卷 //从Session中取出面试者信息 MODEL.T_InterviewerInfo interviewerInfo = (MODEL.T_InterviewerInfo)Session["interviewerInfo"]; MODEL.T_AnswerSheet asModel = new MODEL.T_AnswerSheet() { InterviewerID = interviewerInfo.ID, PaperID = paperId }; OperateContext.Current.BLLSession.IAnswerSheetBLL.Add(asModel); } else { //从Session中取出题号列表 List<int> questionList = (List<int>)Session["questionList1"]; if (questionList.Count > 0) { //取出列表中第一题的题号 ViewData["questionID"] = questionList[0]; ViewData["questionCount"] = (int)Session["questionCount1"]; ViewData["questionIndex"] = (int)Session["questionCount1"] - questionList.Count + 1; } else { Session["questionList1"] = null; Session["questionCount1"] = null; Session["interviewerInfo"] = null; return Redirect("/JoinUs/BeginTest/AccessCommit"); } } return View(); } else if (id == 2) { //第一次访问 ViewData["typeId"] = id; if (Session["questionList2"] == null) { //找到正在发布中的试卷id int paperId = OperateContext.Current.BLLSession .IPaperBLL.GetListBy(p => p.IsPublished == true && p.typeId == id).Select(p => p.ID).First(); //根据试卷id找到对应的试题id集合 List<int> questionList = OperateContext.Current.BLLSession .IPaperQuestionBLL.GetListBy(p => p.PaperID == paperId) .OrderBy(p => p.T_Question.QuestionTypeID) .Select(p => p.QuestionID).ToList(); //保存题目总数 Session["questionCount2"] = questionList.Count; ViewData["questionCount"] = questionList.Count; ViewData["questionIndex"] = 1; //保存列表中第一题的题号 ViewData["questionID"] = questionList[0]; //题号列表保存到Session Session["questionList2"] = questionList; //生成答卷 //从Session中取出面试者信息 MODEL.T_InterviewerInfo interviewerInfo = (MODEL.T_InterviewerInfo)Session["interviewerInfo"]; MODEL.T_AnswerSheet asModel = new MODEL.T_AnswerSheet() { InterviewerID = interviewerInfo.ID, PaperID = paperId }; OperateContext.Current.BLLSession.IAnswerSheetBLL.Add(asModel); } else { //从Session中取出题号列表 List<int> questionList = (List<int>)Session["questionList2"]; if (questionList.Count > 0) { //取出列表中第一题的题号 ViewData["questionID"] = questionList[0]; ViewData["questionCount"] = (int)Session["questionCount2"]; ViewData["questionIndex"] = (int)Session["questionCount2"] - questionList.Count + 1; } else { Session["questionList2"] = null; Session["questionCount2"] = null; Session["interviewerInfo"] = null; return Redirect("/JoinUs/BeginTest/AccessCommit"); } } return View(); } else { //第一次访问 ViewData["typeId"] = id; if (Session["questionList3"] == null) { //找到正在发布中的试卷id int paperId = OperateContext.Current.BLLSession .IPaperBLL.GetListBy(p => p.IsPublished == true && p.typeId == id).Select(p => p.ID).First(); //根据试卷id找到对应的试题id集合 List<int> questionList = OperateContext.Current.BLLSession .IPaperQuestionBLL.GetListBy(p => p.PaperID == paperId) .OrderBy(p => p.T_Question.QuestionTypeID) .Select(p => p.QuestionID).ToList(); //保存题目总数 Session["questionCount3"] = questionList.Count; ViewData["questionCount"] = questionList.Count; ViewData["questionIndex"] = 1; //保存列表中第一题的题号 ViewData["questionID"] = questionList[0]; //题号列表保存到Session Session["questionList3"] = questionList; //生成答卷 //从Session中取出面试者信息 MODEL.T_InterviewerInfo interviewerInfo = (MODEL.T_InterviewerInfo)Session["interviewerInfo"]; MODEL.T_AnswerSheet asModel = new MODEL.T_AnswerSheet() { InterviewerID = interviewerInfo.ID, PaperID = paperId }; OperateContext.Current.BLLSession.IAnswerSheetBLL.Add(asModel); } else { //从Session中取出题号列表 List<int> questionList = (List<int>)Session["questionList3"]; if (questionList.Count > 0) { //取出列表中第一题的题号 ViewData["questionID"] = questionList[0]; ViewData["questionCount"] = (int)Session["questionCount3"]; ViewData["questionIndex"] = (int)Session["questionCount3"] - questionList.Count + 1; } else { Session["questionList3"] = null; Session["questionCount3"] = null; Session["interviewerInfo"] = null; return Redirect("/JoinUs/BeginTest/AccessCommit"); } } return View(); } }