public ActionResult ExamMenu() { JxLib.UserExamController userExamController = new JxLib.UserExamController(); JxLib.ExamController examController = new JxLib.ExamController(); CacheLib.Cookie cookie = new CacheLib.Cookie(); string user_id = cookie.GetCookie("user_id"); System.Collections.Hashtable item = userExamController.getMySequenceExamLog(user_id); int count = examController.getAll().Count; ViewData["count"] = count; if (item == null) ViewData["exam_id"] = "1"; else ViewData["exam_id"] = item["ExamID"].ToString(); ViewData["title"] = "科目一考试练习"; return View(); }
public ActionResult SimulateExamStart() { JxLib.ExamController examController = new JxLib.ExamController(); JxLib.UserExamController userExamController = new JxLib.UserExamController(); CacheLib.Cookie cookie = new CacheLib.Cookie(); System.Collections.Hashtable data = new System.Collections.Hashtable(); string user_id = cookie.GetCookie("user_id"); //深大驾校测试代码 //data.Add("SchoolID", "1"); //data.Add("StudentID", "00001"); data.Add("StudentID", user_id); //插入数据,考试结束 string strExamID = userExamController.ExamStart(data); List<System.Collections.Hashtable> list = examController.getTestExam(); System.Text.StringBuilder strExams = new System.Text.StringBuilder(); int index = 1; foreach (System.Collections.Hashtable item in list) { Models.ExamA exam_a = null; Models.ExamB exam_b = null; if (CommonLib.Common.Validate.IsNullString(item["OptionC"]) == "") { Models.Answer answerA = null; if (item["Answer"].ToString().IndexOf("A") > -1) { answerA = new Models.Answer { title = item["OptionA"].ToString(), correct = true }; } else { answerA = new Models.Answer { title = item["OptionA"].ToString(), correct = false }; } string strAnswerA = Newtonsoft.Json.JsonConvert.SerializeObject(answerA); Models.Answer answerB = null; if (item["Answer"].ToString().IndexOf("B") > -1) { answerB = new Models.Answer { title = item["OptionB"].ToString(), correct = true }; } else { answerB = new Models.Answer { title = item["OptionB"].ToString(), correct = false }; } Models.AnswersA answers = new Models.AnswersA { A = answerA, B = answerB }; exam_a = new Models.ExamA { no = index.ToString(), exam_id = item["ExamID"].ToString(), total = this.EXAMCOUNT.ToString(), title = item["ExamText"].ToString(), img = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["ImgUrl"]), video = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["VideoUrl"]), answers = answers }; if (index > 1) strExams.Append(","); strExams.Append(Newtonsoft.Json.JsonConvert.SerializeObject(exam_a)); } else { Models.Answer answerA = null; if (item["Answer"].ToString().IndexOf("A") > -1) { answerA = new Models.Answer { title = item["OptionA"].ToString(), correct = true }; } else { answerA = new Models.Answer { title = item["OptionA"].ToString(), correct = false }; } Models.Answer answerB = null; if (item["Answer"].ToString().IndexOf("B") > -1) { answerB = new Models.Answer { title = item["OptionB"].ToString(), correct = true }; } else { answerB = new Models.Answer { title = item["OptionB"].ToString(), correct = false }; } Models.Answer answerC = null; if (item["Answer"].ToString().IndexOf("C") > -1) { answerC = new Models.Answer { title = item["OptionC"].ToString(), correct = true }; } else { answerC = new Models.Answer { title = item["OptionC"].ToString(), correct = false }; } Models.Answer answerD = null; if (item["Answer"].ToString().IndexOf("D") > -1) { answerD = new Models.Answer { title = item["OptionD"].ToString(), correct = true }; } else { answerD = new Models.Answer { title = item["OptionD"].ToString(), correct = false }; } Models.AnswersB answers = new Models.AnswersB { A = answerA, B = answerB, C = answerC, D = answerD }; exam_b = new Models.ExamB { no = index.ToString(), exam_id = item["ExamID"].ToString(), total = this.EXAMCOUNT.ToString(), title = item["ExamText"].ToString(), img = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["ImgUrl"]), video = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["VideoUrl"]), answers = answers }; if (index > 1) strExams.Append(","); strExams.Append(Newtonsoft.Json.JsonConvert.SerializeObject(exam_b)); } index++; } string tmp = strExams.ToString().Replace("[", "{").Replace("]", "}"); ViewData["exams"] = tmp; ViewData["exam_id"] = strExamID; ViewData["title"] = "开始考试"; return View(); }
public ActionResult SequenceExam() { JxLib.ExamController examController = new JxLib.ExamController(); List<System.Collections.Hashtable> list = examController.getAll(); //System.Text.StringBuilder strExams = new System.Text.StringBuilder(); //int index = 1; //foreach (System.Collections.Hashtable item in list) //{ // Models.ExamA exam_a = null; // Models.ExamB exam_b = null; // if (CommonLib.Common.Validate.IsNullString(item["OptionC"]) == "") // { // Models.Answer answerA = null; // if (item["Answer"].ToString().IndexOf("A") > -1) // { // answerA = new Models.Answer // { // title = item["OptionA"].ToString(), // correct = true // }; // } // else // { // answerA = new Models.Answer // { // title = item["OptionA"].ToString(), // correct = false // }; // } // string strAnswerA = Newtonsoft.Json.JsonConvert.SerializeObject(answerA); // Models.Answer answerB = null; // if (item["Answer"].ToString().IndexOf("B") > -1) // { // answerB = new Models.Answer // { // title = item["OptionB"].ToString(), // correct = true // }; // } // else // { // answerB = new Models.Answer // { // title = item["OptionB"].ToString(), // correct = false // }; // } // Models.AnswersA answers = new Models.AnswersA // { // A = answerA, // B = answerB // }; // exam_a = new Models.ExamA // { // no = index.ToString(), // exam_id = item["ExamID"].ToString(), // total = list.Count.ToString(), // title = item["ExamText"].ToString(), // img = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["ImgUrl"]), // video = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["VideoUrl"]), // answers = answers // }; // if (index > 1) // strExams.Append(","); // strExams.Append(Newtonsoft.Json.JsonConvert.SerializeObject(exam_a)); // } // else // { // Models.Answer answerA = null; // if (item["Answer"].ToString().IndexOf("A") > -1) // { // answerA = new Models.Answer // { // title = item["OptionA"].ToString(), // correct = true // }; // } // else // { // answerA = new Models.Answer // { // title = item["OptionA"].ToString(), // correct = false // }; // } // Models.Answer answerB = null; // if (item["Answer"].ToString().IndexOf("B") > -1) // { // answerB = new Models.Answer // { // title = item["OptionB"].ToString(), // correct = true // }; // } // else // { // answerB = new Models.Answer // { // title = item["OptionB"].ToString(), // correct = false // }; // } // Models.Answer answerC = null; // if (item["Answer"].ToString().IndexOf("C") > -1) // { // answerC = new Models.Answer // { // title = item["OptionC"].ToString(), // correct = true // }; // } // else // { // answerC = new Models.Answer // { // title = item["OptionC"].ToString(), // correct = false // }; // } // Models.Answer answerD = null; // if (item["Answer"].ToString().IndexOf("D") > -1) // { // answerD = new Models.Answer // { // title = item["OptionD"].ToString(), // correct = true // }; // } // else // { // answerD = new Models.Answer // { // title = item["OptionD"].ToString(), // correct = false // }; // } // Models.AnswersB answers = new Models.AnswersB // { // A = answerA, // B = answerB, // C = answerC, // D = answerD // }; // exam_b = new Models.ExamB // { // no = index.ToString(), // exam_id = item["ExamID"].ToString(), // total = list.Count.ToString(), // title = item["ExamText"].ToString(), // img = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["ImgUrl"]), // video = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["VideoUrl"]), // answers = answers // }; // if (index > 1) // strExams.Append(","); // strExams.Append(Newtonsoft.Json.JsonConvert.SerializeObject(exam_b)); // } // index++; //} //string tmp = strExams.ToString().Replace("[", "{").Replace("]", "}"); //ViewData["exams"] = tmp; CacheLib.Cookie cookie = new CacheLib.Cookie(); JxLib.UserExamController userExamController = new JxLib.UserExamController(); //实际运行代码 string user_id = cookie.GetCookie("user_id"); //开发测试代码 //string user_id = "00001"; //cookie.AddCookie("user_id", "00001"); System.Collections.Hashtable sequenceExamLog = userExamController.getMySequenceExamLog(user_id); string exam_id = "1"; if (sequenceExamLog != null) { exam_id = sequenceExamLog["ExamID"].ToString(); } ViewData["index"] = exam_id; ViewData["count"] = list.Count; ViewData["title"] = "训练习题"; return View(); }
public string GetExam() { JxLib.ExamController examController = new JxLib.ExamController(); HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; Models.Result result = new Models.Result(); string id = context.Request.Params["id"]; if (id == null) { result.code = "0"; result.message = "参数不能为空!"; result.data = ""; return Newtonsoft.Json.JsonConvert.SerializeObject(result).Replace("\"", "'"); } int tmp_id = Int32.Parse(id) + 1; string strResult = ""; System.Collections.Hashtable item = examController.load(tmp_id.ToString()); System.Collections.Hashtable count = examController.getCount(); Models.ExamA exam_a = null; Models.ExamB exam_b = null; if (CommonLib.Common.Validate.IsNullString(item["OptionC"]) == "") { Models.Answer answerA = null; if (item["Answer"].ToString().IndexOf("A") > -1) { answerA = new Models.Answer { title = item["OptionA"].ToString(), correct = true }; } else { answerA = new Models.Answer { title = item["OptionA"].ToString(), correct = false }; } string strAnswerA = Newtonsoft.Json.JsonConvert.SerializeObject(answerA); Models.Answer answerB = null; if (item["Answer"].ToString().IndexOf("B") > -1) { answerB = new Models.Answer { title = item["OptionB"].ToString(), correct = true }; } else { answerB = new Models.Answer { title = item["OptionB"].ToString(), correct = false }; } Models.AnswersA answers = new Models.AnswersA { A = answerA, B = answerB }; exam_a = new Models.ExamA { no = tmp_id.ToString(), exam_id = item["ExamID"].ToString(), total = count["Count"].ToString(), title = item["ExamText"].ToString(), img = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["ImgUrl"]), video = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["VideoUrl"]), answers = answers }; strResult = Newtonsoft.Json.JsonConvert.SerializeObject(exam_a); } else { Models.Answer answerA = null; if (item["Answer"].ToString().IndexOf("A") > -1) { answerA = new Models.Answer { title = item["OptionA"].ToString(), correct = true }; } else { answerA = new Models.Answer { title = item["OptionA"].ToString(), correct = false }; } Models.Answer answerB = null; if (item["Answer"].ToString().IndexOf("B") > -1) { answerB = new Models.Answer { title = item["OptionB"].ToString(), correct = true }; } else { answerB = new Models.Answer { title = item["OptionB"].ToString(), correct = false }; } Models.Answer answerC = null; if (item["Answer"].ToString().IndexOf("C") > -1) { answerC = new Models.Answer { title = item["OptionC"].ToString(), correct = true }; } else { answerC = new Models.Answer { title = item["OptionC"].ToString(), correct = false }; } Models.Answer answerD = null; if (item["Answer"].ToString().IndexOf("D") > -1) { answerD = new Models.Answer { title = item["OptionD"].ToString(), correct = true }; } else { answerD = new Models.Answer { title = item["OptionD"].ToString(), correct = false }; } Models.AnswersB answers = new Models.AnswersB { A = answerA, B = answerB, C = answerC, D = answerD }; exam_b = new Models.ExamB { no = tmp_id.ToString(), exam_id = item["ExamID"].ToString(), total = count["Count"].ToString(), title = item["ExamText"].ToString(), img = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["ImgUrl"]), video = CommonLib.Common.ConfigReader.Read("ResourceUrl") + CommonLib.Common.Validate.IsNullString(item["VideoUrl"]), answers = answers }; strResult = Newtonsoft.Json.JsonConvert.SerializeObject(exam_b); } result.code = "200"; result.message = "success!"; result.data = strResult.ToString().Replace("[", "{").Replace("]", "}"); return Newtonsoft.Json.JsonConvert.SerializeObject(result).Replace("\"", "'"); }