public bool Add(Model_Student_HomeWorkAnswer model) { StringBuilder builder = new StringBuilder(); builder.Append("insert into Student_HomeWorkAnswer("); builder.Append("Student_HomeWorkAnswer_Id,Student_HomeWork_Id,TestQuestions_Score_ID,TestQuestions_Id,Student_Id,HomeWork_Id,TestQuestions_Num,TestQuestions_Detail_OrderNum,Student_Answer,Student_Score,Student_Answer_Status,CreateTime,TestQuestions_NumStr,Comment,isRead)"); builder.Append(" values ("); builder.Append("@Student_HomeWorkAnswer_Id,@Student_HomeWork_Id,@TestQuestions_Score_ID,@TestQuestions_Id,@Student_Id,@HomeWork_Id,@TestQuestions_Num,@TestQuestions_Detail_OrderNum,@Student_Answer,@Student_Score,@Student_Answer_Status,@CreateTime,@TestQuestions_NumStr,@Comment,@isRead)"); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@Student_HomeWorkAnswer_Id", SqlDbType.Char, 0x24), new SqlParameter("@Student_HomeWork_Id", SqlDbType.Char, 0x24), new SqlParameter("@TestQuestions_Score_ID", SqlDbType.Char, 0x24), new SqlParameter("@TestQuestions_Id", SqlDbType.Char, 0x24), new SqlParameter("@Student_Id", SqlDbType.Char, 0x24), new SqlParameter("@HomeWork_Id", SqlDbType.Char, 0x24), new SqlParameter("@TestQuestions_Num", SqlDbType.Int, 4), new SqlParameter("@TestQuestions_Detail_OrderNum", SqlDbType.Int, 4), new SqlParameter("@Student_Answer", SqlDbType.NVarChar, 0x3e8), new SqlParameter("@Student_Score", SqlDbType.Decimal, 5), new SqlParameter("@Student_Answer_Status", SqlDbType.VarChar, 50), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@TestQuestions_NumStr", SqlDbType.VarChar, 100), new SqlParameter("@Comment", SqlDbType.NVarChar, 500), new SqlParameter("@isRead", SqlDbType.Int, 4) }; cmdParms[0].Value = model.Student_HomeWorkAnswer_Id; cmdParms[1].Value = model.Student_HomeWork_Id; cmdParms[2].Value = model.TestQuestions_Score_ID; cmdParms[3].Value = model.TestQuestions_Id; cmdParms[4].Value = model.Student_Id; cmdParms[5].Value = model.HomeWork_Id; cmdParms[6].Value = model.TestQuestions_Num; cmdParms[7].Value = model.TestQuestions_Detail_OrderNum; cmdParms[8].Value = model.Student_Answer; cmdParms[9].Value = model.Student_Score; cmdParms[10].Value = model.Student_Answer_Status; cmdParms[11].Value = model.CreateTime; cmdParms[12].Value = model.TestQuestions_NumStr; cmdParms[13].Value = model.Comment; cmdParms[14].Value = model.isRead; return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0); }
public List <Model_Student_HomeWorkAnswer> DataTableToList(DataTable dt) { List <Model_Student_HomeWorkAnswer> list = new List <Model_Student_HomeWorkAnswer>(); int count = dt.Rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { Model_Student_HomeWorkAnswer item = this.dal.DataRowToModel(dt.Rows[i]); if (item != null) { list.Add(item); } } } return(list); }
public bool Update(Model_Student_HomeWorkAnswer model) { StringBuilder builder = new StringBuilder(); builder.Append("update Student_HomeWorkAnswer set "); builder.Append("Student_HomeWork_Id=@Student_HomeWork_Id,"); builder.Append("TestQuestions_Score_ID=@TestQuestions_Score_ID,"); builder.Append("TestQuestions_Id=@TestQuestions_Id,"); builder.Append("Student_Id=@Student_Id,"); builder.Append("HomeWork_Id=@HomeWork_Id,"); builder.Append("TestQuestions_Num=@TestQuestions_Num,"); builder.Append("TestQuestions_Detail_OrderNum=@TestQuestions_Detail_OrderNum,"); builder.Append("Student_Answer=@Student_Answer,"); builder.Append("Student_Score=@Student_Score,"); builder.Append("Student_Answer_Status=@Student_Answer_Status,"); builder.Append("CreateTime=@CreateTime,"); builder.Append("TestQuestions_NumStr=@TestQuestions_NumStr,"); builder.Append("Comment=@Comment,"); builder.Append("isRead=@isRead"); builder.Append(" where Student_HomeWorkAnswer_Id=@Student_HomeWorkAnswer_Id "); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@Student_HomeWork_Id", SqlDbType.Char, 0x24), new SqlParameter("@TestQuestions_Score_ID", SqlDbType.Char, 0x24), new SqlParameter("@TestQuestions_Id", SqlDbType.Char, 0x24), new SqlParameter("@Student_Id", SqlDbType.Char, 0x24), new SqlParameter("@HomeWork_Id", SqlDbType.Char, 0x24), new SqlParameter("@TestQuestions_Num", SqlDbType.Int, 4), new SqlParameter("@TestQuestions_Detail_OrderNum", SqlDbType.Int, 4), new SqlParameter("@Student_Answer", SqlDbType.NVarChar, 0x3e8), new SqlParameter("@Student_Score", SqlDbType.Decimal, 5), new SqlParameter("@Student_Answer_Status", SqlDbType.VarChar, 50), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@TestQuestions_NumStr", SqlDbType.VarChar, 100), new SqlParameter("@Comment", SqlDbType.NVarChar, 500), new SqlParameter("@isRead", SqlDbType.Int, 4), new SqlParameter("@Student_HomeWorkAnswer_Id", SqlDbType.Char, 0x24) }; cmdParms[0].Value = model.Student_HomeWork_Id; cmdParms[1].Value = model.TestQuestions_Score_ID; cmdParms[2].Value = model.TestQuestions_Id; cmdParms[3].Value = model.Student_Id; cmdParms[4].Value = model.HomeWork_Id; cmdParms[5].Value = model.TestQuestions_Num; cmdParms[6].Value = model.TestQuestions_Detail_OrderNum; cmdParms[7].Value = model.Student_Answer; cmdParms[8].Value = model.Student_Score; cmdParms[9].Value = model.Student_Answer_Status; cmdParms[10].Value = model.CreateTime; cmdParms[11].Value = model.TestQuestions_NumStr; cmdParms[12].Value = model.Comment; cmdParms[13].Value = model.isRead; cmdParms[14].Value = model.Student_HomeWorkAnswer_Id; return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0); }
public bool Add(Model_Student_HomeWorkAnswer model) { return(this.dal.Add(model)); }
public bool Update(Model_Student_HomeWorkAnswer model) { return(this.dal.Update(model)); }
public Model_Student_HomeWorkAnswer DataRowToModel(DataRow row) { Model_Student_HomeWorkAnswer answer = new Model_Student_HomeWorkAnswer(); if (row != null) { if (row["Student_HomeWorkAnswer_Id"] != null) { answer.Student_HomeWorkAnswer_Id = row["Student_HomeWorkAnswer_Id"].ToString(); } if (row["Student_HomeWork_Id"] != null) { answer.Student_HomeWork_Id = row["Student_HomeWork_Id"].ToString(); } if (row["TestQuestions_Score_ID"] != null) { answer.TestQuestions_Score_ID = row["TestQuestions_Score_ID"].ToString(); } if (row["TestQuestions_Id"] != null) { answer.TestQuestions_Id = row["TestQuestions_Id"].ToString(); } if (row["Student_Id"] != null) { answer.Student_Id = row["Student_Id"].ToString(); } if (row["HomeWork_Id"] != null) { answer.HomeWork_Id = row["HomeWork_Id"].ToString(); } if ((row["TestQuestions_Num"] != null) && (row["TestQuestions_Num"].ToString() != "")) { answer.TestQuestions_Num = new int?(int.Parse(row["TestQuestions_Num"].ToString())); } if ((row["TestQuestions_Detail_OrderNum"] != null) && (row["TestQuestions_Detail_OrderNum"].ToString() != "")) { answer.TestQuestions_Detail_OrderNum = new int?(int.Parse(row["TestQuestions_Detail_OrderNum"].ToString())); } if (row["Student_Answer"] != null) { answer.Student_Answer = row["Student_Answer"].ToString(); } if ((row["Student_Score"] != null) && (row["Student_Score"].ToString() != "")) { answer.Student_Score = new decimal?(decimal.Parse(row["Student_Score"].ToString())); } if (row["Student_Answer_Status"] != null) { answer.Student_Answer_Status = row["Student_Answer_Status"].ToString(); } if ((row["CreateTime"] != null) && (row["CreateTime"].ToString() != "")) { answer.CreateTime = new DateTime?(DateTime.Parse(row["CreateTime"].ToString())); } if (row["TestQuestions_NumStr"] != null) { answer.TestQuestions_NumStr = row["TestQuestions_NumStr"].ToString(); } if (row["Comment"] != null) { answer.Comment = row["Comment"].ToString(); } if ((row["isRead"] != null) && (row["isRead"].ToString() != "")) { answer.isRead = new int?(int.Parse(row["isRead"].ToString())); } } return(answer); }
public void SubmitStudentAnswer() { string StrSql = string.Empty; if (string.IsNullOrEmpty(SchoolId)) { StrSql = @"select hw.HomeWork_Id,hw.CreateTime,shw.Student_HomeWork_Id,shw.HomeWork_Id,shw.Student_Id,shw.CreateTime,shwSubmit.Student_HomeWork_Status,shwSubmit.OpenTime,shwSubmit.StudentIP,shwSubmit.Student_Answer_Time from Student_HomeWork shw inner join Student_HomeWork_Submit shwSubmit on shwSubmit.Student_HomeWork_Id=shw.Student_HomeWork_Id and shwSubmit.Student_HomeWork_Status='2' inner join HomeWork hw on hw.HomeWork_Id=shw.HomeWork_Id order by hw.CreateTime"; } else { StrSql = string.Format(@"select hw.HomeWork_Id,hw.CreateTime,shw.Student_HomeWork_Id,shw.HomeWork_Id,shw.Student_Id,shw.CreateTime,shwSubmit.Student_HomeWork_Status,shwSubmit.OpenTime,shwSubmit.StudentIP,shwSubmit.Student_Answer_Time from Student_HomeWork shw inner join Student_HomeWork_Submit shwSubmit on shwSubmit.Student_HomeWork_Id=shw.Student_HomeWork_Id and shwSubmit.Student_HomeWork_Status='2' inner join HomeWork hw on hw.HomeWork_Id=shw.HomeWork_Id where shw.Student_Id in(select UserId from VW_UserOnClassGradeSchool vw where vw.SchoolId='{0}') order by hw.CreateTime", SchoolId); } DataTable dtShw = Rc.Common.DBUtility.DbHelperSQL.Query(StrSql).Tables[0]; if (dtShw.Rows.Count == 0) { #region 记录执行结束信息并保存数据 model_FileSyncExecRecordDetail.Detail_TimeEnd = DateTime.Now; model_FileSyncExecRecordDetail.Detail_Status = "1"; model_FileSyncExecRecordDetail.Detail_Remark = "执行完成.没有待执行数据"; bll_FileSyncExecRecordDetail.Update(model_FileSyncExecRecordDetail); #endregion return; } try { #region 自动提交学生答案 int sucNum = 0; int failNum = 0; string resInfo = string.Empty; foreach (DataRow itemShw in dtShw.Rows) { try { #region 提交单份学生作业 string savePath = string.Empty; Model_HomeWork modelHW = new BLL_HomeWork().GetModel(itemShw["HomeWork_Id"].ToString()); string homeWorkId = modelHW.HomeWork_Id; string rtrfId = modelHW.ResourceToResourceFolder_Id; string resourceId = itemShw["Student_HomeWork_Id"].ToString(); //学生作业ID string userId = itemShw["Student_Id"].ToString(); //学生ID Model_ResourceToResourceFolder modelRTRFolder = new BLL_ResourceToResourceFolder().GetModel(rtrfId); string filePath = pfunction.ConvertToLongDateTime(itemShw["CreateTime"].ToString(), "yyyy-MM-dd") + "\\" + itemShw["HomeWork_Id"] + "\\" + itemShw["Student_HomeWork_Id"].ToString() + ".txt"; if (File.Exists(Server.MapPath(uploadAnswerPath) + filePath)) { resInfo = File.ReadAllText(Server.MapPath(uploadAnswerPath) + filePath); Rc.Interface.testPaperAnswerSubmitModel resModel = Newtonsoft.Json.JsonConvert.DeserializeObject <Rc.Interface.testPaperAnswerSubmitModel>(resInfo); Rc.Common.SystemLog.SystemLog.AddLogFromBS("", resourceId, string.Format("开始自动提交学生作业|操作人{0}|学生作业Id{1}|方法{2}", userId, resourceId, "testpaperanswersubmit")); #region 学生作业表 Model_Student_HomeWork_Submit modelSHWSubmit = new Model_Student_HomeWork_Submit(); modelSHWSubmit = new BLL_Student_HomeWork_Submit().GetModel(itemShw["Student_HomeWork_Id"].ToString()); modelSHWSubmit.Student_HomeWork_Status = 1; #endregion #region 学生作业答案表 if (modelRTRFolder.Resource_Class == Rc.Common.Config.Resource_ClassConst.云资源) { savePath = string.Format("{0}\\{1}\\{2}\\{3}\\{4}\\" , pfunction.ToShortDate(modelHW.CreateTime.ToString())//作业布置时间 , modelRTRFolder.ParticularYear, modelRTRFolder.GradeTerm , modelRTRFolder.Resource_Version, modelRTRFolder.Subject); } if (modelRTRFolder.Resource_Class == Rc.Common.Config.Resource_ClassConst.自有资源) { savePath = string.Format("{0}\\" , pfunction.ToShortDate(modelHW.CreateTime.ToString()));//作业布置时间); } //获取这个试卷的所有试题分值 string strSqlScore = string.Empty; strSqlScore = string.Format(@"select [TestQuestions_Score_ID],TestQuestions_ID ,TestQuestions_Score,TestQuestions_OrderNum,TestType FROM TestQuestions_Score where ResourceToResourceFolder_Id='{0}' ", rtrfId); DataTable dtTQ_Score = Rc.Common.DBUtility.DbHelperSQL.Query(strSqlScore).Tables[0]; List <Model_Student_HomeWorkAnswer> listSHWA = new List <Model_Student_HomeWorkAnswer>(); List <Rc.Interface.TestPaperAnswerModel> listTestPaperAnswerModel = resModel.answerJson; //普通题型 List <Rc.Interface.TestPaperAnswerModelBig> TestPaperAnswerModelBig = resModel.listBig; //综合题型 #region 普通题型 list int num = 0; if (listTestPaperAnswerModel != null) { foreach (var item in listTestPaperAnswerModel) { if (item != null && item.list != null) { num++; int detailNum = 0; foreach (var itemSub in item.list) { if (itemSub != null) { detailNum++; DataRow[] drTQ_Score = dtTQ_Score.Select(string.Format(" TestQuestions_ID='{0}' and TestQuestions_OrderNum={1} ", item.Testid, detailNum)); if (drTQ_Score != null && drTQ_Score.Length > 0) { #region 学生答题表 Model_Student_HomeWorkAnswer modelSHWA = new Model_Student_HomeWorkAnswer(); modelSHWA.TestQuestions_Id = item.Testid; string student_HomeWorkAnswer_Id = Guid.NewGuid().ToString(); modelSHWA.TestQuestions_Score_ID = drTQ_Score[0]["TestQuestions_Score_ID"].ToString(); modelSHWA.Student_HomeWorkAnswer_Id = student_HomeWorkAnswer_Id; modelSHWA.Student_HomeWork_Id = resourceId; modelSHWA.Student_Id = userId; modelSHWA.HomeWork_Id = homeWorkId; modelSHWA.TestQuestions_Num = num; modelSHWA.TestQuestions_Detail_OrderNum = detailNum; if (itemSub.isHTML == "F")//是否以HTML提交 F: 文本提交; T: HTML提交(选择题,文本提交, 其余均为HTML提交) { modelSHWA.Student_Answer = itemSub.answerChooses; } else if (itemSub.isHTML == "T")//HTML提交 { Model_TestQuestions modelTQ = new BLL_TestQuestions().GetModel(item.Testid); if (modelTQ.TestQuestions_Type == "truefalse")//判断题答案保存到数据库 { modelSHWA.Student_Answer = itemSub.answerHTML; } else { #region 学生答案 保存文件 if (!String.IsNullOrEmpty(itemSub.answerHTML)) { pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerHTML, true); } if (!String.IsNullOrEmpty(itemSub.answerImageBase64)) { pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.i.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerImageBase64, true); } if (!String.IsNullOrEmpty(itemSub.answerDocBase64)) { pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.d.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerDocBase64, true); } #endregion } } else //默认存HTML { #region 学生答案 保存文件 if (!String.IsNullOrEmpty(itemSub.answerHTML)) { pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerHTML, true); } if (!String.IsNullOrEmpty(itemSub.answerImageBase64)) { pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.i.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerImageBase64, true); } if (!String.IsNullOrEmpty(itemSub.answerDocBase64)) { pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.d.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerDocBase64, true); } #endregion } //写入客户端的判卷 modelSHWA.Student_Score = 0;//学生得分默认值(NULL的话统计的时候会出现数据不正确) if (itemSub.isRight == "true") { modelSHWA.Student_Answer_Status = "right"; decimal temp_decimal = 0; decimal.TryParse(drTQ_Score[0]["TestQuestions_Score"].ToString(), out temp_decimal); modelSHWA.Student_Score = temp_decimal; modelSHWA.isRead = 1; } else if (itemSub.isRight == "false") { modelSHWA.Student_Answer_Status = "wrong"; modelSHWA.isRead = 1; } else { modelSHWA.Student_Answer_Status = "unknown"; modelSHWA.isRead = 0; } modelSHWA.CreateTime = DateTime.Now; string strTestQuestions_NumStr = item.topicNumber.Filter(); if (!string.IsNullOrEmpty(strTestQuestions_NumStr)) { if (strTestQuestions_NumStr.Length >= 10) { strTestQuestions_NumStr = strTestQuestions_NumStr.Substring(0, 10); } } modelSHWA.TestQuestions_NumStr = strTestQuestions_NumStr;//item.topicNumber listSHWA.Add(modelSHWA); #endregion } } } } } } #endregion #region 综合题型 listBig if (TestPaperAnswerModelBig != null) { num = 0; foreach (var itemBig in TestPaperAnswerModelBig) { if (itemBig != null && itemBig.list != null) { foreach (var item in itemBig.list) { if (item != null && item.list != null) { num++; int detailNum = 0; foreach (var itemSub in item.list) { if (itemSub != null) { detailNum++; DataRow[] drTQ_Score = dtTQ_Score.Select(string.Format(" TestQuestions_ID='{0}' and TestQuestions_OrderNum={1} ", item.Testid, detailNum)); if (drTQ_Score != null && drTQ_Score.Length > 0) { #region 学生答题表 Model_Student_HomeWorkAnswer modelSHWA = new Model_Student_HomeWorkAnswer(); modelSHWA.TestQuestions_Id = item.Testid; string student_HomeWorkAnswer_Id = Guid.NewGuid().ToString(); modelSHWA.TestQuestions_Score_ID = drTQ_Score[0]["TestQuestions_Score_ID"].ToString(); modelSHWA.Student_HomeWorkAnswer_Id = student_HomeWorkAnswer_Id; modelSHWA.Student_HomeWork_Id = resourceId; modelSHWA.Student_Id = userId; modelSHWA.HomeWork_Id = homeWorkId; modelSHWA.TestQuestions_Num = num; modelSHWA.TestQuestions_Detail_OrderNum = detailNum; //if (modelRTRFolder.Resource_Class == Rc.Common.Config.Resource_ClassConst.云资源) //{ // savePath = string.Format("{0}\\{1}\\{2}\\{3}\\{4}\\" // , pfunction.ToShortDate(modelHW.CreateTime.ToString())//作业布置时间 // , modelRTRFolder.ParticularYear, modelRTRFolder.GradeTerm // , modelRTRFolder.Resource_Version, modelRTRFolder.Subject); //} //if (modelRTRFolder.Resource_Class == Rc.Common.Config.Resource_ClassConst.自有资源) //{ // savePath = string.Format("{0}\\" // , pfunction.ToShortDate(modelHW.CreateTime.ToString()));//作业布置时间); //} if (itemSub.isHTML == "F")//是否以HTML提交 F: 文本提交; T: HTML提交(选择题,文本提交, 其余均为HTML提交) { modelSHWA.Student_Answer = itemSub.answerChooses; } else if (itemSub.isHTML == "T")//HTML提交 { Model_TestQuestions modelTQ = new BLL_TestQuestions().GetModel(item.Testid); if (modelTQ.TestQuestions_Type == "truefalse")//判断题答案保存到数据库 { modelSHWA.Student_Answer = itemSub.answerHTML; } else { #region 学生答案 保存文件 if (!String.IsNullOrEmpty(itemSub.answerHTML)) { pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerHTML, true); } if (!String.IsNullOrEmpty(itemSub.answerImageBase64)) { pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.i.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerImageBase64, true); } if (!String.IsNullOrEmpty(itemSub.answerDocBase64)) { pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.d.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerDocBase64, true); } #endregion } } else //默认存HTML { #region 学生答案 保存文件 if (!String.IsNullOrEmpty(itemSub.answerHTML)) { pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerHTML, true); } if (!String.IsNullOrEmpty(itemSub.answerImageBase64)) { pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.i.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerImageBase64, true); } if (!String.IsNullOrEmpty(itemSub.answerDocBase64)) { pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.d.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerDocBase64, true); } #endregion } //写入客户端的判卷 modelSHWA.Student_Score = 0;//学生得分默认值(NULL的话统计的时候会出现数据不正确) if (itemSub.isRight == "true") { modelSHWA.Student_Answer_Status = "right"; decimal temp_decimal = 0; decimal.TryParse(drTQ_Score[0]["TestQuestions_Score"].ToString(), out temp_decimal); modelSHWA.Student_Score = temp_decimal; modelSHWA.isRead = 1; } else if (itemSub.isRight == "false") { modelSHWA.Student_Answer_Status = "wrong"; modelSHWA.isRead = 1; } else { modelSHWA.Student_Answer_Status = "unknown"; modelSHWA.isRead = 0; } modelSHWA.CreateTime = DateTime.Now; string strTestQuestions_NumStr = item.topicNumber.Filter(); if (!string.IsNullOrEmpty(strTestQuestions_NumStr)) { if (strTestQuestions_NumStr.Length >= 10) { strTestQuestions_NumStr = strTestQuestions_NumStr.Substring(0, 10); } } modelSHWA.TestQuestions_NumStr = strTestQuestions_NumStr;//item.topicNumber listSHWA.Add(modelSHWA); #endregion } } } } } } } } #endregion #endregion if (new BLL_Student_HomeWorkAnswer().StudentAnswerSubmit(modelSHWSubmit, listSHWA) > 0) { sucNum++; #region 保存学生答题JSON串 //重置answerHTML为空,保存分值 List <Model_Student_HomeWorkAnswer> listStuScore = new BLL_Student_HomeWorkAnswer().GetModelList("Student_HomeWork_Id='" + resourceId + "'"); #region 普通题型 list if (resModel.answerJson != null) { foreach (var item in resModel.answerJson) { if (item != null && item.list != null) { int sNum = 0; foreach (var itemTQ_S in item.list) { if (itemTQ_S != null) { itemTQ_S.answerHTML = ""; sNum++; List <Model_Student_HomeWorkAnswer> listStuScoreSub = listStuScore.Where(o => o.TestQuestions_Id == item.Testid && o.TestQuestions_Detail_OrderNum == sNum).ToList(); if (listStuScoreSub.Count > 0) { itemTQ_S.studentScore = listStuScoreSub[0].Student_Score.ToString(); } } } } } } #endregion #region 综合题型 listBig if (resModel.listBig != null) { foreach (var item in resModel.listBig) { if (item != null && item.list != null) { foreach (var itemSub in item.list) { if (itemSub != null && itemSub.list != null) { int sNum = 0; foreach (var itemTQ_S in itemSub.list) { if (itemTQ_S != null) { itemTQ_S.answerHTML = ""; sNum++; List <Model_Student_HomeWorkAnswer> listStuScoreSub = listStuScore.Where(o => o.TestQuestions_Id == itemSub.Testid && o.TestQuestions_Detail_OrderNum == sNum).ToList(); if (listStuScoreSub.Count > 0) { itemTQ_S.studentScore = listStuScoreSub[0].Student_Score.ToString(); } } } } } } } } #endregion string savePathForTch = string.Format("{0}\\", pfunction.ToShortDate(modelHW.CreateTime.ToString())); savePathForTch = "{0}{1}\\" + savePathForTch + "{2}\\{2}.txt"; object stuAnswer = new { list = resModel.answerJson, listBig = resModel.listBig }; pfunction.WriteToFile(string.Format(savePathForTch, uploadPath, "studentAnswerForMarking", resourceId) , Newtonsoft.Json.JsonConvert.SerializeObject(stuAnswer), true); #endregion Rc.Common.SystemLog.SystemLog.AddLogFromBS("", resourceId, string.Format("成功-自动提交学生作业|操作人{0}|学生作业Id{1}|方法{2}", userId, resourceId, "testpaperanswersubmit")); } else { failNum++; Rc.Common.SystemLog.SystemLog.AddLogFromBS("", resourceId, string.Format("失败-自动提交学生作业|操作人{0}|学生作业Id{1}|方法{2}", userId, resourceId, "testpaperanswersubmit")); } } #endregion } catch (Exception ex) { failNum++; Rc.Common.SystemLog.SystemLog.AddLogFromBS("", itemShw["Student_HomeWork_Id"].ToString() , string.Format("失败-自动提交学生作业|操作人{0}|学生作业Id{1}|方法{2}。错误:{3}" , itemShw["Student_Id"].ToString() , itemShw["Student_HomeWork_Id"].ToString() , "testpaperanswersubmit" , ex.Message.ToString().Filter() ) ); } Rc.Common.SystemLog.SystemLog.AddLogFromBS("", itemShw["Student_HomeWork_Id"].ToString(), string.Format("完成-自动提交学生作业|操作人{0}|学生作业Id{1}|方法{2}", itemShw["Student_Id"].ToString(), itemShw["Student_HomeWork_Id"].ToString(), "testpaperanswersubmit")); } #endregion #region 记录执行结束信息并保存数据 model_FileSyncExecRecordDetail.Detail_TimeEnd = DateTime.Now; model_FileSyncExecRecordDetail.Detail_Status = "1"; model_FileSyncExecRecordDetail.Detail_Remark = string.Format("执行完成.数据总数{0},成功数{1},失败数{2}", dtShw.Rows.Count, sucNum, failNum); bll_FileSyncExecRecordDetail.Update(model_FileSyncExecRecordDetail); #endregion } catch (Exception ex) { model_FileSyncExecRecordDetail.Detail_TimeEnd = DateTime.Now; model_FileSyncExecRecordDetail.Detail_Status = "2"; model_FileSyncExecRecordDetail.Detail_Remark = "执行失败:" + ex.Message.ToString(); bll_FileSyncExecRecordDetail.Update(model_FileSyncExecRecordDetail); } }
protected void btnSubmit_Click(object sender, EventArgs e) { string userId = FloginUser.UserId; try { BLL_Student_HomeWorkAnswer bll = new BLL_Student_HomeWorkAnswer(); Rc.Common.SystemLog.SystemLog.AddLogFromBS(HomeWork_Id, "", string.Format("开始解析按试题批改数据|操作人{0}|作业Id{1}|方法{2}", userId, HomeWork_Id, "ExerciseCorrect")); string correctData = hidCorrect.Value; JavaScriptSerializer json = new JavaScriptSerializer(); List <StudentAnswerData> listCorrect = json.Deserialize <List <StudentAnswerData> >(correctData); Rc.Common.SystemLog.SystemLog.AddLogFromBS(HomeWork_Id, "", string.Format("完成解析按试题批改数据|操作人{0}|学生作业Id{1}|方法{2}", userId, HomeWork_Id, "ExerciseCorrect")); List <Model_Student_HomeWorkAnswer> listSHWA = new List <Model_Student_HomeWorkAnswer>(); Rc.Common.SystemLog.SystemLog.AddLogFromBS(HomeWork_Id, "", string.Format("开始处理按试题批改数据|操作人{0}|学生作业Id{1}|方法{2}", userId, HomeWork_Id, "ExerciseCorrect")); foreach (var item in listCorrect) { #region 学生答题表 Model_Student_HomeWorkAnswer modelSHWA = bll.GetModel(item.Student_HomeWorkAnswer_Id); modelSHWA.Student_Score = item.score; modelSHWA.Comment = item.comment.Filter(); if (item.score == item.actualscore) { modelSHWA.Student_Answer_Status = "right";//对 } else if (item.score == 0) { modelSHWA.Student_Answer_Status = "wrong";//错 } else { modelSHWA.Student_Answer_Status = "partright";//部分对 } listSHWA.Add(modelSHWA); #endregion } #region 作业试题批改确认表 Model_HomeWorkQuestionConfirm modelHWQC = new Model_HomeWorkQuestionConfirm(); modelHWQC.HomeWorkQuestionConfirm_ID = Guid.NewGuid().ToString(); modelHWQC.HomeWork_Id = HomeWork_Id; modelHWQC.TestQuestions_Id = TestQuestions_Id; modelHWQC.Confirm_Status = "1"; modelHWQC.CreateUser = userId; modelHWQC.CreateTime = DateTime.Now; #endregion int result = bll.TeacherCorrectStuHomeWorkByTQ(listSHWA, modelHWQC); if (result > 0) { Rc.Common.SystemLog.SystemLog.AddLogFromBS(HomeWork_Id, "", string.Format("完成处理按试题批改数据|操作人{0}|学生作业Id{1}|方法{2}", userId, HomeWork_Id, "ExerciseCorrect")); string strWhere = string.Format(@"TestQuestions_Type!='title' and ResourceToResourceFolder_Id='{0}' and TestQuestions_Num>(select TestQuestions_Num from TestQuestions where TestQuestions_Id='{1}') and TestQuestions_Id not in( select TestQuestions_Id from HomeWorkQuestionConfirm hwqc where hwqc.HomeWork_Id='{2}' ) order by TestQuestions_Num", ResourceToResourceFolder_Id, TestQuestions_Id, HomeWork_Id); List <Model_TestQuestions> listTQ = new BLL_TestQuestions().GetModelList(strWhere); if (listTQ.Count == 0) { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>window.opener.loadHomeWorkTQData('" + HomeWork_Id + "');window.close();</script>"); } else { Response.Redirect("ExerciseCorrectView.aspx?HomeWork_Id=" + HomeWork_Id + "&ResourceToResourceFolder_Id=" + ResourceToResourceFolder_Id + "&TestQuestions_Id=" + listTQ[0].TestQuestions_Id); } } else { Rc.Common.SystemLog.SystemLog.AddLogFromBS(HomeWork_Id, "", string.Format("按试题批改失败:result 为0,|操作人{0}|学生作业Id{1}|方法{2}", userId, HomeWork_Id, "ExerciseCorrect")); ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('批改失败',{icon:2,time:2000});</script>"); } } catch (Exception ex) { Rc.Common.SystemLog.SystemLog.AddLogFromBS(HomeWork_Id, "", string.Format("按试题批改失败:|操作人{0}|学生作业Id{1}|方法{2}|错误信息{3}", userId, HomeWork_Id, "ExerciseCorrect", ex.Message.ToString())); ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('批改失败err',{icon:2,time:2000});</script>"); } }