public ActionResult Result() { int sid = getSid(); if (sid == -1) { return Redirect("/Index/Index"); } var model = new ResultModel(); var data = model.getResultByStudentId(sid); ViewBag.data = data; assignTitle(); return View(); }
public ActionResult Result() { if (loginStatus() == false) { return Redirect("Login"); } ViewBag.resultList = new List<ResultEntity>(); try { int examid = int.Parse(Request["exam"]); ResultModel model = new ResultModel(); ExamModel examModel = new ExamModel(); ViewBag.resultList = model.getExamResultByExamId(examid); ViewBag.examInfo = examModel.getExamById(examid); } catch { } return View(); }
public ActionResult ResultDetail(int id) { int sid = getSid(); if (sid == -1) { return Redirect("/Index/Index"); } var model = new ResultModel(); var data = model.getResultById(id); var decoder = new JavaScriptSerializer(); ViewBag.sQuestion = decoder.Deserialize< List< Dictionary<string,string> > >(data.sQuestion); ViewBag.mQuestion = decoder.Deserialize<List<Dictionary<string, string>>>(data.mQuestion); ViewBag.tQuestion = decoder.Deserialize<List<Dictionary<string, string>>>(data.tQuestion); ViewBag.data = data; assignTitle(); return View(); }
public ActionResult Submit() { if (getSid() == -1) { return Redirect("/Index/Index"); } var endTime = (DateTime)Session["end_time"]; if (System.DateTime.Now.CompareTo(endTime.AddMinutes(1)) > 0) // 多等一分钟以免网络延迟的影响 { return Json("{status:error,message:考试时间已过}"); } else { var sc = new List<Dictionary<string,string>>(); var mc = new List<Dictionary<string, string>>(); var tf = new List<Dictionary<string, string>>(); double scScore = 0, mcScore = 0, tfScore = 0; var data = Request.Params["data"]; var ansList = new JavaScriptSerializer().Deserialize< ArrayList>(data); var question = Session["exam"] as List<QuestionEntity>; var exam_info = (ExamEntity)Session["exam_info"]; foreach (Dictionary<String,Object> ans in ansList) { int id = (int)ans["id"]; var correctAns = question[id].ans; var getAns = ans["choice"] as String; var tmp_dic = new Dictionary<string, string>(); //tmp_dic["problem_id"] = String.Format("{0}",ans["id"]); tmp_dic["ans"] = correctAns; tmp_dic["is_correct"] = "false"; tmp_dic["id"] = String.Format("{0}", question[id].id ); if (question[id].type == "SC") { String tmp = ""; try { tmp = ( (char)(Int32.Parse(getAns) + 'A')).ToString(); } catch (Exception e) { //ignore } tmp_dic["choice"] = tmp; if (tmp == correctAns) { scScore += exam_info.sScore; tmp_dic["is_correct"] = "true"; } sc.Add(tmp_dic); } else if (question[id].type == "MC") { var l = from c in getAns.Split(';') orderby c select ( (char)(Int32.Parse(c) + 'A')).ToString() ; var tmp = String.Join("", l); tmp_dic["choice"] = tmp; if (tmp == correctAns) { mcScore +=exam_info.mScore; tmp_dic["is_correct"] = "true"; } mc.Add(tmp_dic); } else { tmp_dic["choice"] = getAns.ToUpper(); if (correctAns.ToUpper() == getAns.ToUpper()) { tfScore+=exam_info.tScore; tmp_dic["is_correct"] = "true"; } tf.Add(tmp_dic); } } var resultModel = new ResultModel(); JavaScriptSerializer serializer = new JavaScriptSerializer(); resultModel.insertResult(getSid(), exam_info.id, serializer.Serialize(sc), serializer.Serialize(mc), serializer.Serialize(tf), scScore, mcScore, tfScore); return Json(String.Format("{{status:'success',redirct:'/Student/ResultDetail/{0}'}}", resultModel.lastId()) ); } }
public ActionResult delResult() { if (loginStatus() == false) { return Redirect("Login"); } Dictionary<string, String> ret = new Dictionary<string, string>(); try { int id = int.Parse(Request["id"]); ResultModel model = new ResultModel(); int row = model.delResultByExamId(id); if (row > 0) { ret.Add("status", "success"); } else { ret.Add("status", "failed"); ret.Add("error", "delete error!"); } } catch { ret.Add("status", "failed"); ret.Add("error", "bad param!"); } return Json(ret); }