public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string strMsg = "error"; string strData = Basic.RequestHelper.GetFormString("yjl"); string strZuBie = Basic.RequestHelper.GetFormString("zubie"); int intStudentId = Basic.RequestHelper.GetFormInt("studentid", 0); if (strData != "") { string[] arr = strData.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (arr.Length > 0) { for (int i = 0; i < arr.Length; i++) { string[] arr2 = arr[i].Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (arr2.Length == 2) { int intId = Basic.Utils.StrToInt(arr2[0], 0); //判断对错 Entity.TiMuNeiRong infonr = DAL.TiMuNeiRong.TiMuNeiRongEntityGet(intId); if (infonr != null) { //判断对错 int intResult = 2; if (infonr.objective_answer.Trim() == arr2[1]) { intResult = 1; } //更改题目组中该题对应的答题结果 DataTable dt = DAL.student2tm.student2tmList(" ZuBie = '" + strZuBie + "' AND StudentId = " + intStudentId + " AND TiMuId = " + arr2[0]); if (dt != null && dt.Rows.Count > 0) { Entity.student2tm infotm = DAL.student2tm.student2tmEntityGet(Basic.Utils.StrToInt(dt.Rows[0]["id"].ToString(), 0)); infotm.Result = intResult; infotm.Answer = arr2[1]; DAL.student2tm.student2tmEdit(infotm); } //如果错题本中没有该题目,添加该题目 DataTable dtcuoti = DAL.cuotiben.cuotibenList("TiMuId = " + intId + " and Wid = " + intStudentId); if (dtcuoti == null || dtcuoti.Rows.Count == 0) { //添加 Entity.cuotiben infost = new Entity.cuotiben(); infost.TiMuId = intId; infost.Wid = intStudentId; infost.Answer = arr2[1]; infost.RightAnswer = infonr.objective_answer; if (DAL.cuotiben.cuotibenAdd(infost) > 0) { strMsg = "success"; } } else { //删除 DAL.cuotiben.cuotibenDel(Basic.Utils.StrToInt(dtcuoti.Rows[0]["id"].ToString(), 0)); //添加 Entity.cuotiben infost = new Entity.cuotiben(); infost.TiMuId = intId; infost.Wid = intStudentId; infost.Answer = arr2[1]; infost.RightAnswer = infonr.objective_answer; if (DAL.cuotiben.cuotibenAdd(infost) > 0) { strMsg = "success"; } } } } } } } context.Response.Write(strMsg); }
/// <summary> /// 绑定数据 /// </summary> void Bind() { string strFirstWhere = " TiMuSuoYin.subject_id = " + intSubjectId + " AND edu_question_type.id = " + intTypeId; int intCount = DAL.tengxb.zhenti.TiMuCount(strFirstWhere); if (intCount > 0) { string strWhere = " ("; //随机选出十条数据 string strList = Basic.StringHelper.GetList(intCount, 10); string[] arr = strList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); //答题卡号 BindDaTiKaHao(arr.Length); for (int i = 0; i < arr.Length; i++) { //拼接筛选条件 if (i == arr.Length - 1) { strWhere += " xuhao = " + arr[i]; } else { strWhere += " xuhao = " + arr[i] + " OR "; } } strWhere += " )"; DataTable dt = DAL.tengxb.zhenti.TiMuList(strFirstWhere, strWhere); strZuBie = DateTime.Now.ToString("yyyyMMddHHmmss"); //保存这些产生的题目到数据库中 for (int i = 0; i < dt.Rows.Count; i++) { int intTiMuId = Basic.Utils.StrToInt(dt.Rows[i]["id"].ToString(), 0); Entity.TiMuNeiRong infonr = DAL.TiMuNeiRong.TiMuNeiRongEntityGet(intTiMuId); if (infonr == null) { //数据有问题呀!!! } //保存这些题目 Entity.student2tm infotm = new Entity.student2tm(); infotm.Answer = ""; infotm.RightAnswer = infonr.objective_answer; infotm.Result = 0; infotm.StudentId = intStudentId; infotm.TiMuId = infonr.Id; infotm.Type = 2;//1表示知识点;2表示题型 infotm.ZuBie = strZuBie; infotm.sx = i + 1; DAL.student2tm.student2tmAdd(infotm); } rpt_List.DataSource = dt; rpt_List.DataBind(); } }