public void UpdateExamResultAnswerCurrent(RandomExamResultAnswerCurrent examResultAnswer) { Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_Random_EXAM_ANSWER_Cur_U"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_Random_EXAM_result_id", DbType.Int32, examResultAnswer.RandomExamResultId); db.AddInParameter(dbCommand, "p_Random_EXAM_item_id", DbType.Int32, examResultAnswer.RandomExamItemId); db.AddInParameter(dbCommand, "p_answer", DbType.String, examResultAnswer.Answer); db.AddInParameter(dbCommand, "p_exam_time", DbType.Int32, examResultAnswer.ExamTime); //db.AddInParameter(dbCommand, "p_judge_score", DbType.Decimal, examResultAnswer.JudgeScore); //db.AddInParameter(dbCommand, "p_judge_status_id", DbType.Int32, examResultAnswer.JudgeStatusId); db.AddInParameter(dbCommand, "p_judge_remark", DbType.String, examResultAnswer.JudgeRemark); db.ExecuteNonQuery(dbCommand); }
public RandomExamResultAnswerCurrent GetExamResultAnswerCurrent(int randomExamResultID, int examItemID) { RandomExamResultAnswerCurrent exam = null; Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_Random_EXAM_ANSWER_Cur_G1"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_random_Exam_result_id", DbType.Int32, randomExamResultID); db.AddInParameter(dbCommand, "p_item_id", DbType.Int32, examItemID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { exam = CreateModelObject(dataReader); } } return(exam); }
private void GetPaper() { // 根据 ProgressBar.htm 显示进度条界面 string templateFileName = Path.Combine(Server.MapPath("."), "ProgressBar.htm"); StreamReader reader = new StreamReader(@templateFileName, System.Text.Encoding.GetEncoding("gb2312")); string html = reader.ReadToEnd(); reader.Close(); Response.Write(html); Response.Flush(); System.Threading.Thread.Sleep(200); string jsBlock; ViewState["BeginTime"] = DateTime.Now.ToString(); string strId = Request.QueryString.Get("RandomExamID"); //获取当前考试的生成试卷的状态和次数 RandomExamBLL objBll = new RandomExamBLL(); RailExam.Model.RandomExam obj = objBll.GetExam(Convert.ToInt32(strId)); int year = obj.BeginTime.Year; int ExamCount = obj.MaxExamTimes; RandomExamArrangeBLL eaBll = new RandomExamArrangeBLL(); IList <RailExam.Model.RandomExamArrange> ExamArranges = eaBll.GetRandomExamArranges(int.Parse(strId)); string strChooseID = ""; OracleAccess db = new OracleAccess(); OracleAccess dbCenter = new OracleAccess(System.Configuration.ConfigurationManager.ConnectionStrings["OracleCenter"].ConnectionString); string strSql; if (ExamArranges.Count > 0) { strSql = "select a.* from Random_Exam_Arrange_Detail a " + " inner join Computer_Room b on a.Computer_Room_ID=b.Computer_Room_ID" + " inner join Computer_Server c on c.Computer_server_ID=b.Computer_Server_ID" + " where c.Computer_Server_No='" + PrjPub.ServerNo + "' " + " and Random_Exam_ID=" + strId; DataSet ds = db.RunSqlDataSet(strSql); foreach (DataRow dr in ds.Tables[0].Rows) { if (string.IsNullOrEmpty(strChooseID)) { strChooseID += dr["User_Ids"].ToString(); } else { strChooseID += "," + dr["User_Ids"]; } } } else { strChooseID = ""; } if (strChooseID == "") { Response.Write("<script>top.returnValue='本场考试未在本单位安排考生!';window.close();</script>"); return; } if (db.GetCount("RANDOM_EXAM_ITEM_TEMP_" + year, "TABLE") == 0) { strSql = "create table RANDOM_EXAM_ITEM_TEMP_" + year + " as select * from RANDOM_EXAM_ITEM_" + year + " where 1=2 "; db.ExecuteNonQuery(strSql); } strSql = "insert into RANDOM_EXAM_ITEM_TEMP_" + year + " select * from RANDOM_EXAM_ITEM_" + year + " where Random_Exam_ID=" + strId; db.ExecuteNonQuery(strSql); if (!PrjPub.IsServerCenter) { if (dbCenter.GetCount("RANDOM_EXAM_ITEM_TEMP_" + year, "TABLE") == 0) { strSql = "create table RANDOM_EXAM_ITEM_TEMP_" + year + " as select * from RANDOM_EXAM_ITEM_" + year + " where 1=2 "; dbCenter.ExecuteNonQuery(strSql); } strSql = "insert into RANDOM_EXAM_ITEM_TEMP_" + year + " select * from RANDOM_EXAM_ITEM_" + year + " where Random_Exam_ID=" + strId; dbCenter.ExecuteNonQuery(strSql); } System.Threading.Thread.Sleep(10); jsBlock = "<script>SetPorgressBar('正在计算生成试卷数量,请等待......','" + ((1 * 100) / ((double)2) + "'); </script>"); Response.Write(jsBlock); Response.Flush(); //每次生成试卷之前删除已生成的考试试卷 RandomExamResultCurrentBLL randomExamResultBLL = new RandomExamResultCurrentBLL(); randomExamResultBLL.DelRandomExamResultCurrent(Convert.ToInt32(strId)); System.Threading.Thread.Sleep(10); jsBlock = "<script>SetPorgressBar('正在计算生成试卷数量,请等待......','" + ((2 * 100) / ((double)2) + "'); </script>"); Response.Write(jsBlock); Response.Flush(); System.Threading.Thread.Sleep(200); jsBlock = string.Empty; string[] str = strChooseID.Split(','); RandomExamResultAnswerCurrentBLL randomExamResultAnswerBLL = new RandomExamResultAnswerCurrentBLL(); //定义全局答卷对象List IList <RandomExamResultAnswerCurrent> randomExamResultAnswersCurrentAll = new List <RandomExamResultAnswerCurrent>(); //定义一个考生一次答卷对象List IList <RandomExamResultAnswerCurrent> randomExamResultAnswers = null; int progressNum = 1; for (int n = 1; n <= ExamCount; n++) { for (int m = 0; m < str.Length; m++) { RandomExamResultCurrent randomExamResult = new RandomExamResultCurrent(); randomExamResult.RandomExamId = int.Parse(strId); randomExamResult.AutoScore = 0; randomExamResult.BeginDateTime = DateTime.Parse(ViewState["BeginTime"].ToString()); randomExamResult.CurrentDateTime = DateTime.Parse(ViewState["BeginTime"].ToString()); randomExamResult.ExamTime = 0; randomExamResult.EndDateTime = DateTime.Parse(ViewState["BeginTime"].ToString()); randomExamResult.Score = 0; randomExamResult.OrganizationId = int.Parse(ConfigurationManager.AppSettings["StationID"]); randomExamResult.Memo = ""; randomExamResult.StatusId = 0; randomExamResult.AutoScore = 0; randomExamResult.CorrectRate = 0; randomExamResult.ExamineeId = int.Parse(str[m]); randomExamResult.ExamSeqNo = n; int nRandomExamResultPK = randomExamResultBLL.AddRandomExamResultCurrent(randomExamResult); ViewState["RandomExamResultPK"] = nRandomExamResultPK; strSql = "select a.* from Random_Exam_Arrange_Detail a " + " where ','||User_Ids||',' like '%," + str[m] + ",%' " + " and Random_Exam_ID=" + strId; DataRow dr = db.RunSqlDataSet(strSql).Tables[0].Rows[0]; //strSql = "insert into Random_Exam_Result_Detail(Random_Exam_Result_Detail_ID," // + "Random_Exam_Result_ID,Random_Exam_ID,Employee_ID,Computer_Room_SEAT,Computer_Room_ID) " // + "values(Random_Exam_Result_Detail_SEQ.NextVal," // + nRandomExamResultPK + "," // + randomExamResult.RandomExamId + "," // + randomExamResult.ExamineeId + "," // + "0," + dr["Computer_Room_ID"] + ") "; //db.ExecuteNonQuery(strSql); strSql = "insert into Random_Exam_Result_Detail_Temp(Random_Exam_Result_Detail_ID," + "Random_Exam_Result_ID,Random_Exam_ID,Employee_ID,Computer_Room_SEAT,Computer_Room_ID,Is_Remove) " + "values(Random_Exam_Result_Detail_SEQ.NextVal," + nRandomExamResultPK + "," + randomExamResult.RandomExamId + "," + randomExamResult.ExamineeId + "," + "0," + dr["Computer_Room_ID"] + ",0) "; db.ExecuteNonQuery(strSql); RandomExamItemBLL randomItemBLL = new RandomExamItemBLL(); RandomExamSubjectBLL subjectBLL = new RandomExamSubjectBLL(); RandomExamStrategyBLL strategyBLL = new RandomExamStrategyBLL(); IList <RandomExamSubject> randomExamSubjects = subjectBLL.GetRandomExamSubjectByRandomExamId(int.Parse(strId)); if (randomExamSubjects != null) { Hashtable hashTableItemIds = new Hashtable(); Hashtable htSubjectItemIds = new Hashtable(); for (int i = 0; i < randomExamSubjects.Count; i++) { RandomExamSubject paperSubject = randomExamSubjects[i]; int nSubjectId = paperSubject.RandomExamSubjectId; // int nItemCount = paperSubject.ItemCount; IList <RandomExamStrategy> strategys = strategyBLL.GetRandomExamStrategys(nSubjectId); for (int j = 0; j < strategys.Count; j++) { int nStrategyId = strategys[j].RandomExamStrategyId; int nItemCount = strategys[j].ItemCount; IList <RandomExamItem> itemList = randomItemBLL.GetItemsByStrategyId(nStrategyId, year); // IList<RandomExamItem> itemList = randomItemBLL.GetItemsBySubjectId(nSubjectId); Random ObjRandom = new Random(); Hashtable hashTable = new Hashtable(); Hashtable hashTableCount = new Hashtable(); int index = 0; while (hashTable.Count < nItemCount) { int k = ObjRandom.Next(itemList.Count); hashTableCount[index] = k; index = index + 1; int itemID = itemList[k].ItemId; int examItemID = itemList[k].RandomExamItemId; if (!hashTableItemIds.ContainsKey(itemID)) { hashTable[examItemID] = examItemID; hashTableItemIds[itemID] = itemID; htSubjectItemIds[examItemID] = examItemID; } //if (hashTableCount.Count == itemList.Count && hashTable.Count < nItemCount) //{ // SessionSet.PageMessage = "随机考试在设定的取题范围内的试题量不够,请重新设置取题范围!"; // return; //} } } } foreach (int key in htSubjectItemIds.Keys) { string strItemId = htSubjectItemIds[key].ToString(); RandomExamItem item = randomItemBLL.GetRandomExamItem(Convert.ToInt32(strItemId), year); string nowSelectAnswer = string.Empty; string nowStandardAnswer = string.Empty; if (item.TypeId != PrjPub.ITEMTYPE_FILLBLANK) { Pub.GetNowAnswer(item, out nowSelectAnswer, out nowStandardAnswer); } RandomExamResultAnswerCurrent randomExamResultAnswer = new RandomExamResultAnswerCurrent(); randomExamResultAnswer.RandomExamResultId = nRandomExamResultPK; randomExamResultAnswer.RandomExamItemId = int.Parse(strItemId); randomExamResultAnswer.JudgeStatusId = 0; randomExamResultAnswer.JudgeRemark = string.Empty; randomExamResultAnswer.ExamTime = 0; randomExamResultAnswer.Answer = string.Empty; randomExamResultAnswer.SelectAnswer = nowSelectAnswer; randomExamResultAnswer.StandardAnswer = nowStandardAnswer; randomExamResultAnswerBLL.AddExamResultAnswerCurrent(randomExamResultAnswer); //完型填空子题 IList <RandomExamItem> randomExamItems = randomItemBLL.GetItemsByParentItemID(item.ItemId, obj.RandomExamId, year); foreach (RandomExamItem randomExamItem in randomExamItems) { Pub.GetNowAnswer(randomExamItem, out nowSelectAnswer, out nowStandardAnswer); randomExamResultAnswer = new RandomExamResultAnswerCurrent(); randomExamResultAnswer.RandomExamResultId = nRandomExamResultPK; randomExamResultAnswer.RandomExamItemId = randomExamItem.RandomExamItemId; randomExamResultAnswer.JudgeStatusId = 0; randomExamResultAnswer.JudgeRemark = string.Empty; randomExamResultAnswer.ExamTime = 0; randomExamResultAnswer.Answer = string.Empty; randomExamResultAnswer.SelectAnswer = nowSelectAnswer; randomExamResultAnswer.StandardAnswer = nowStandardAnswer; randomExamResultAnswerBLL.AddExamResultAnswerCurrent(randomExamResultAnswer); } System.Threading.Thread.Sleep(10); jsBlock = "<script>SetPorgressBar('正在生成试卷,请等待......','" + ((progressNum * 100) / ((double)ExamCount * str.Length * htSubjectItemIds.Count)).ToString("0.00") + "'); </script>"; Response.Write(jsBlock); Response.Flush(); progressNum++; } } else { SessionSet.PageMessage = "未找到记录!"; } } } bool isRefresh = true; try { objBll.UpdateHasPaper(Convert.ToInt32(strId), PrjPub.ServerNo, true); } catch { strSql = @" update Random_Exam_Computer_Server set has_paper=1 where random_exam_id=" + strId + @" and Computer_server_no='" + PrjPub.ServerNo + @"'"; dbCenter.ExecuteNonQuery(strSql); strSql = @"select count(*) from Random_Exam_Computer_Server where has_paper=1 and random_exam_id=" + strId; int count = Convert.ToInt32(dbCenter.RunSqlDataSet(strSql).Tables[0].Rows[0][0]); if (count > 0) { strSql = @"update Random_Exam set has_paper=1 where random_exam_id=" + strId; dbCenter.ExecuteNonQuery(strSql); } else { strSql = @"update Random_Exam set has_paper=0 where random_exam_id=" + strId; dbCenter.ExecuteNonQuery(strSql); } } //如果考试是随到随考,考试状态自动变为正在进行 if (obj.StartMode == 1) { try { objBll.UpdateIsStart(Convert.ToInt32(strId), PrjPub.ServerNo, 1); isRefresh = false; } catch { strSql = @" update Random_Exam_Computer_Server set Is_Start=1 where random_exam_id=" + strId + @" and Computer_server_no='" + PrjPub.ServerNo + @"'"; dbCenter.ExecuteNonQuery(strSql); strSql = @"select count(*) from Random_Exam_Computer_Server where random_exam_id=" + strId; int totalcount = Convert.ToInt32(dbCenter.RunSqlDataSet(strSql).Tables[0].Rows[0][0]); strSql = @"select count(*) from Random_Exam_Computer_Server where Is_Start=0 and random_exam_id=" + strId; int count = Convert.ToInt32(dbCenter.RunSqlDataSet(strSql).Tables[0].Rows[0][0]); if (totalcount == count) { strSql = @"update Random_Exam set Is_Start=0 where random_exam_id=" + strId; dbCenter.ExecuteNonQuery(strSql); } else { strSql = @"select count(*) from Random_Exam_Computer_Server where Is_Start=1 and random_exam_id=" + strId; count = Convert.ToInt32(dbCenter.RunSqlDataSet(strSql).Tables[0].Rows[0][0]); if (count > 0) { strSql = @"update Random_Exam set Is_Start=1 where random_exam_id=" + strId; dbCenter.ExecuteNonQuery(strSql); } else { strSql = @"select count(*) from Random_Exam_Computer_Server where Is_Start=2 and random_exam_id=" + strId; count = Convert.ToInt32(dbCenter.RunSqlDataSet(strSql).Tables[0].Rows[0][0]); if (count == totalcount) { strSql = @"update Random_Exam set Is_Start=2 where random_exam_id=" + strId; dbCenter.ExecuteNonQuery(strSql); } } } } } else { isRefresh = false; } if (isRefresh) { objBll.RandomExamRefresh(); } SystemLogBLL objLogBll = new SystemLogBLL(); objLogBll.WriteLog("“" + obj.ExamName + "”生成所有考试试卷"); Response.Write("<script>top.returnValue='true';top.close();</script>"); }
private void GetPaperAfter() { // 根据 ProgressBar.htm 显示进度条界面 string templateFileName = Path.Combine(Server.MapPath("."), "ProgressBar.htm"); StreamReader reader = new StreamReader(@templateFileName, System.Text.Encoding.GetEncoding("gb2312")); string html = reader.ReadToEnd(); reader.Close(); Response.Write(html); Response.Flush(); System.Threading.Thread.Sleep(200); ViewState["BeginTime"] = DateTime.Now.ToString(); string strId = Request.QueryString.Get("RandomExamID"); //获取当前考试的生成试卷的状态和次数 RandomExamBLL objBll = new RandomExamBLL(); RailExam.Model.RandomExam obj = objBll.GetExam(Convert.ToInt32(strId)); int year = obj.BeginTime.Year; int ExamCount = obj.MaxExamTimes; System.Threading.Thread.Sleep(10); string jsBlock = "<script>SetPorgressBar('正在计算生成试卷数量,请等待......','" + ((1 * 100) / ((double)1) + "'); </script>"); Response.Write(jsBlock); Response.Flush(); if (!PrjPub.IsServerCenter) { RandomExamArrangeBLL objArrangeBll = new RandomExamArrangeBLL(); objArrangeBll.RefreshRandomExamArrange(); } //RandomExamArrangeBLL eaBll = new RandomExamArrangeBLL(); //IList<RailExam.Model.RandomExamArrange> ExamArranges = eaBll.GetRandomExamArranges(int.Parse(strId)); //string strChooseID = ""; //if (ExamArranges.Count > 0) //{ // strChooseID = ExamArranges[0].UserIds; //} //else //{ // strChooseID = ""; //} //RandomExamResultCurrentBLL objResultCurrentBll = new RandomExamResultCurrentBLL(); //IList<RandomExamResultCurrent> examResults = objResultCurrentBll.GetRandomExamResultInfo(Convert.ToInt32(strId)); //for (int i = 0; i < examResults.Count; i++) //{ // strChooseID = ("," + strChooseID + ",").Replace("," + examResults[i].ExamineeId + ",", ","); //} //strChooseID = strChooseID.TrimStart(',').TrimEnd(','); string strChooseID = Request.QueryString.Get("addIds"); if (strChooseID == string.Empty) { return; } string[] str = strChooseID.Split('|'); System.Threading.Thread.Sleep(10); jsBlock = "<script>SetPorgressBar('正在计算生成试卷数量,请等待......','" + ((2 * 100) / ((double)2) + "'); </script>"); Response.Write(jsBlock); Response.Flush(); OracleAccess db = new OracleAccess(); string strSql; RandomExamResultAnswerCurrentBLL randomExamResultAnswerBLL = new RandomExamResultAnswerCurrentBLL(); //定义全局答卷对象List IList <RandomExamResultAnswerCurrent> randomExamResultAnswersCurrentAll = new List <RandomExamResultAnswerCurrent>(); //定义一个考生一次答卷对象List IList <RandomExamResultAnswerCurrent> randomExamResultAnswers = null; System.Threading.Thread.Sleep(200); jsBlock = string.Empty; int progressNum = 1; for (int n = 1; n <= ExamCount; n++) { for (int m = 0; m < str.Length; m++) { RandomExamResultCurrentBLL randomExamResultBLL = new RandomExamResultCurrentBLL(); RandomExamResultCurrent randomExamResult = new RandomExamResultCurrent(); randomExamResult.RandomExamId = int.Parse(strId); randomExamResult.AutoScore = 0; randomExamResult.BeginDateTime = DateTime.Parse(ViewState["BeginTime"].ToString()); randomExamResult.CurrentDateTime = DateTime.Parse(ViewState["BeginTime"].ToString()); randomExamResult.ExamTime = 0; randomExamResult.EndDateTime = DateTime.Parse(ViewState["BeginTime"].ToString()); randomExamResult.Score = 0; randomExamResult.OrganizationId = int.Parse(ConfigurationManager.AppSettings["StationID"]); randomExamResult.Memo = ""; randomExamResult.StatusId = 0; randomExamResult.AutoScore = 0; randomExamResult.CorrectRate = 0; randomExamResult.ExamineeId = int.Parse(str[m]); randomExamResult.ExamSeqNo = n; int nRandomExamResultPK = randomExamResultBLL.AddRandomExamResultCurrent(randomExamResult); ViewState["RandomExamResultPK"] = nRandomExamResultPK; strSql = "select a.* from Random_Exam_Arrange_Detail a " + " where ','||User_Ids||',' like '%," + str[m] + ",%' " + " and Random_Exam_ID=" + strId; DataRow dr = db.RunSqlDataSet(strSql).Tables[0].Rows[0]; //strSql = "insert into Random_Exam_Result_Detail(Random_Exam_Result_Detail_ID," // + "Random_Exam_Result_ID,Random_Exam_ID,Employee_ID,Computer_Room_SEAT,Computer_Room_ID) " // + "values(Random_Exam_Result_Detail_SEQ.NextVal," // + nRandomExamResultPK + "," // + randomExamResult.RandomExamId + "," // + randomExamResult.ExamineeId + "," // + "0," + dr["Computer_Room_ID"] + ") "; //db.ExecuteNonQuery(strSql); strSql = "insert into Random_Exam_Result_Detail_Temp(Random_Exam_Result_Detail_ID," + "Random_Exam_Result_ID,Random_Exam_ID,Employee_ID,Computer_Room_SEAT,Computer_Room_ID,Is_Remove) " + "values(Random_Exam_Result_Detail_SEQ.NextVal," + nRandomExamResultPK + "," + randomExamResult.RandomExamId + "," + randomExamResult.ExamineeId + "," + "0," + dr["Computer_Room_ID"] + ",0) "; db.ExecuteNonQuery(strSql); RandomExamItemBLL randomItemBLL = new RandomExamItemBLL(); RandomExamSubjectBLL subjectBLL = new RandomExamSubjectBLL(); RandomExamStrategyBLL strategyBLL = new RandomExamStrategyBLL(); IList <RandomExamSubject> randomExamSubjects = subjectBLL.GetRandomExamSubjectByRandomExamId(int.Parse(strId)); if (randomExamSubjects != null) { Hashtable hashTableItemIds = new Hashtable(); Hashtable htSubjectItemIds = new Hashtable(); for (int i = 0; i < randomExamSubjects.Count; i++) { RandomExamSubject paperSubject = randomExamSubjects[i]; int nSubjectId = paperSubject.RandomExamSubjectId; // int nItemCount = paperSubject.ItemCount; IList <RandomExamStrategy> strategys = strategyBLL.GetRandomExamStrategys(nSubjectId); for (int j = 0; j < strategys.Count; j++) { int nStrategyId = strategys[j].RandomExamStrategyId; int nItemCount = strategys[j].ItemCount; IList <RandomExamItem> itemList = randomItemBLL.GetItemsByStrategyId(nStrategyId, year); // IList<RandomExamItem> itemList = randomItemBLL.GetItemsBySubjectId(nSubjectId); Random ObjRandom = new Random(); Hashtable hashTable = new Hashtable(); Hashtable hashTableCount = new Hashtable(); int index = 0; while (hashTable.Count < nItemCount) { int k = ObjRandom.Next(itemList.Count); hashTableCount[index] = k; index = index + 1; int itemID = itemList[k].ItemId; int examItemID = itemList[k].RandomExamItemId; if (!hashTableItemIds.ContainsKey(itemID)) { hashTable[examItemID] = examItemID; hashTableItemIds[itemID] = itemID; htSubjectItemIds[examItemID] = examItemID; } //if (hashTableCount.Count == itemList.Count && hashTable.Count < nItemCount) //{ // SessionSet.PageMessage = "随机考试在设定的取题范围内的试题量不够,请重新设置取题范围!"; // return; //} } } } randomExamResultAnswers = new List <RandomExamResultAnswerCurrent>(); foreach (int key in htSubjectItemIds.Keys) { string strItemId = htSubjectItemIds[key].ToString(); RandomExamItem item = randomItemBLL.GetRandomExamItem(Convert.ToInt32(strItemId), year); string nowSelectAnswer = string.Empty; string nowStandardAnswer = string.Empty; if (item.TypeId != PrjPub.ITEMTYPE_FILLBLANK) { Pub.GetNowAnswer(item, out nowSelectAnswer, out nowStandardAnswer); } RandomExamResultAnswerCurrent randomExamResultAnswer = new RandomExamResultAnswerCurrent(); randomExamResultAnswer.RandomExamResultId = nRandomExamResultPK; randomExamResultAnswer.RandomExamItemId = int.Parse(strItemId); randomExamResultAnswer.JudgeStatusId = 0; randomExamResultAnswer.JudgeRemark = string.Empty; randomExamResultAnswer.ExamTime = 0; randomExamResultAnswer.Answer = string.Empty; randomExamResultAnswer.SelectAnswer = nowSelectAnswer; randomExamResultAnswer.StandardAnswer = nowStandardAnswer; randomExamResultAnswerBLL.AddExamResultAnswerCurrent(randomExamResultAnswer); //完型填空子题 IList <RandomExamItem> randomExamItems = randomItemBLL.GetItemsByParentItemID(item.ItemId, obj.RandomExamId, year); foreach (RandomExamItem randomExamItem in randomExamItems) { Pub.GetNowAnswer(randomExamItem, out nowSelectAnswer, out nowStandardAnswer); randomExamResultAnswer = new RandomExamResultAnswerCurrent(); randomExamResultAnswer.RandomExamResultId = nRandomExamResultPK; randomExamResultAnswer.RandomExamItemId = randomExamItem.RandomExamItemId; randomExamResultAnswer.JudgeStatusId = 0; randomExamResultAnswer.JudgeRemark = string.Empty; randomExamResultAnswer.ExamTime = 0; randomExamResultAnswer.Answer = string.Empty; randomExamResultAnswer.SelectAnswer = nowSelectAnswer; randomExamResultAnswer.StandardAnswer = nowStandardAnswer; randomExamResultAnswerBLL.AddExamResultAnswerCurrent(randomExamResultAnswer); } System.Threading.Thread.Sleep(10); jsBlock = "<script>SetPorgressBar('正在生成试卷,请等待......','" + ((progressNum * 100) / ((double)ExamCount * str.Length * htSubjectItemIds.Count)).ToString("0.00") + "'); </script>"; Response.Write(jsBlock); Response.Flush(); progressNum++; } } else { SessionSet.PageMessage = "未找到记录!"; } } } //临时添加考生无需更改考试状态,因为考试状态肯定是正在进行和生成试卷 //objBll.UpdateHasPaper(Convert.ToInt32(strId), PrjPub.ServerNo, true); ////如果考试是随到随考,考试状态自动变为正在进行 //if (obj.StartMode == 1) //{ // objBll.UpdateIsStart(Convert.ToInt32(strId), PrjPub.ServerNo, 1); //} SystemLogBLL objLogBll = new SystemLogBLL(); objLogBll.WriteLog("“" + obj.ExamName + "”生成新增考生试卷"); Response.Write("<script>top.returnValue='true';top.close();</script>"); }
public void UpdateExamResultAnswerCurrent(RandomExamResultAnswerCurrent examResultAnswer) { dal.UpdateExamResultAnswerCurrent(examResultAnswer); }
public int AddExamResultAnswerCurrent(RandomExamResultAnswerCurrent examResultAnswer) { return(dal.AddExamResultAnswerCurrent(examResultAnswer)); }
private void SaveAnswerToDB(string strAnswer) { try { string strId = Request.QueryString.Get("ExamID"); RandomExamResultCurrentBLL objResultCurrentBll = new RandomExamResultCurrentBLL(); RailExam.Model.RandomExamResultCurrent objResultCurrent = objResultCurrentBll.GetNowRandomExamResultInfo(Convert.ToInt32(Request.QueryString["StudentID"].ToString()), Convert.ToInt32(strId)); //更新考试成绩表时传入的主键应为站段的成绩表的主键ID objResultCurrent.RandomExamResultId = int.Parse(Request.QueryString["RandomExamResultID"].ToString()); objResultCurrent.RandomExamId = int.Parse(strId); objResultCurrent.AutoScore = 0; objResultCurrent.CurrentDateTime = DateTime.Parse(ViewState["EndTime"].ToString()); objResultCurrent.ExamTime = Convert.ToInt32(Request.QueryString["ExamTime"]); objResultCurrent.EndDateTime = DateTime.Parse(ViewState["EndTime"].ToString()); objResultCurrent.Score = 0; objResultCurrent.OrganizationId = int.Parse(Request.QueryString["OrgID"].ToString()); objResultCurrent.Memo = ""; objResultCurrent.StatusId = 2; objResultCurrent.AutoScore = 0; objResultCurrent.CorrectRate = 0; objResultCurrent.ExamineeId = int.Parse(Request.QueryString["StudentID"].ToString()); string[] str1 = strAnswer.Split(new char[] { '$' }); RandomExamResultAnswerCurrentBLL randomExamResultAnswerBLL = new RandomExamResultAnswerCurrentBLL(); //randomExamResultAnswerBLL.DeleteExamResultAnswerCurrent(Convert.ToInt32(ViewState["RandomExamResultID"].ToString())); IList <RandomExamResultAnswerCurrent> randomExamResultAnswers = new List <RandomExamResultAnswerCurrent>(); int randomExamResultId = int.Parse(Request.QueryString["RandomExamResultID"].ToString()); for (int n = 0; n < str1.Length; n++) { string str2 = str1[n].ToString(); string[] str3 = str2.Split(new char[] { '|' }); string strPaperItemId = str3[0].ToString(); string strTrueAnswer = str2.ToString().Substring(strPaperItemId.Length + 1); RandomExamResultAnswerCurrent randomExamResultAnswer = new RandomExamResultAnswerCurrent(); randomExamResultAnswer.RandomExamResultId = randomExamResultId; randomExamResultAnswer.RandomExamItemId = int.Parse(strPaperItemId); randomExamResultAnswer.JudgeStatusId = 0; randomExamResultAnswer.JudgeRemark = string.Empty; randomExamResultAnswer.ExamTime = 0; randomExamResultAnswer.Answer = strTrueAnswer; randomExamResultAnswers.Add(randomExamResultAnswer); } //将实时考试答卷删除,将最终考试答卷插入 randomExamResultAnswerBLL.AddExamResultAnswerCurrentSave(randomExamResultId, randomExamResultAnswers); //更新实时考试记录 objResultCurrentBll.UpdateRandomExamResultCurrent(objResultCurrent); //将实时考试记录(临时表)转存到正式考试成绩表和答卷表 RandomExamResultBLL objResultBll = new RandomExamResultBLL(); int randomExamResultID = objResultBll.RemoveResultAnswer(Convert.ToInt32(Request.QueryString["RandomExamResultID"].ToString())); //如果在站段是随到随考考试,成绩自动上传至路局 //if(ViewState["NowStartMode"].ToString() == PrjPub.START_MODE_NO_CONTROL.ToString() && !PrjPub.IsServerCenter) //{ // objResultBll.RemoveRandomExamResultToServer(Convert.ToInt32(strId), Convert.ToInt32(ConfigurationManager.AppSettings["StationID"])); //} Response.Write( "<script>window.dialogArguments.parent.location = '/RailExamBao/Online/Exam/ExamSuccess.aspx?ExamType=1&ExamResultID=" + randomExamResultID + "';window.close();</script>"); } catch { SessionSet.PageMessage = "提交失败!"; btnUpload.Visible = true; btnClose.Visible = true; } }
protected void FillPaper() { // QueryString id stands for EXAM_RESULT_ID string strId = Request.QueryString.Get("id"); string orgid = Request.QueryString.Get("orgid"); // Not pass id if (string.IsNullOrEmpty(strId)) { SessionSet.PageMessage = "参数错误!"; return; } RandomExamResultCurrentBLL randomExamResultBLL = new RandomExamResultCurrentBLL(); RandomExamResultCurrent randomExamResult = new RandomExamResultCurrent(); randomExamResult = randomExamResultBLL.GetRandomExamResult(int.Parse(strId)); int RandomExamId = randomExamResult.RandomExamId; int randomExamResultId = int.Parse(strId); RandomExamBLL objBll = new RandomExamBLL(); int year = objBll.GetExam(RandomExamId).BeginTime.Year; RandomExamItemBLL randomItemBLL = new RandomExamItemBLL(); RandomExamSubjectBLL subjectBLL = new RandomExamSubjectBLL(); RandomExamResultAnswerCurrentBLL randomExamResultAnswerBLL = new RandomExamResultAnswerCurrentBLL(); IList <RandomExamSubject> randomExamSubjects = subjectBLL.GetRandomExamSubjectByRandomExamId(RandomExamId); IList <RandomExamResultAnswerCurrent> examResultAnswers = new List <RandomExamResultAnswerCurrent>(); examResultAnswers = randomExamResultAnswerBLL.GetExamResultAnswersCurrent(randomExamResultId); if (randomExamSubjects != null) { for (int i = 0; i < randomExamSubjects.Count; i++) { RandomExamSubject paperSubject = randomExamSubjects[i]; IList <RandomExamItem> PaperItems = new List <RandomExamItem>(); PaperItems = randomItemBLL.GetItemsCurrent(paperSubject.RandomExamSubjectId, randomExamResultId, year); Response.Write("<table width='100%'>"); Response.Write(" <tr > <td class='ExamBigTitle' >"); Response.Write(" " + GetNo(i) + ""); Response.Write(". " + paperSubject.SubjectName + ""); Response.Write(" (共" + paperSubject.ItemCount + "题,共" + System.String.Format("{0:0.##}", paperSubject.ItemCount * paperSubject.UnitScore) + "分)</td></tr >"); if (PaperItems != null) { for (int j = 0; j < PaperItems.Count; j++) { RandomExamItem paperItem = PaperItems[j]; int k = j + 1; Response.Write("<tr > <td class='ExamResultItem'> " + k + ". " + paperItem.Content + " (" + System.String.Format("{0:0.##}", paperSubject.UnitScore) + "分)</td></tr >"); // 组织用户答案 RandomExamResultAnswerCurrent theExamResultAnswer = null; string[] strUserAnswers = new string[0]; string strUserAnswer = string.Empty; foreach (RandomExamResultAnswerCurrent resultAnswer in examResultAnswers) { if (resultAnswer.RandomExamItemId == paperItem.RandomExamItemId) { theExamResultAnswer = resultAnswer; break; } } // 若子表无记录,结束页面输出 if (theExamResultAnswer == null) { SessionSet.PageMessage = "数据错误!"; } // 否则组织考生答案 if (theExamResultAnswer.Answer != null || theExamResultAnswer.Answer == string.Empty) { strUserAnswers = theExamResultAnswer.Answer.Split(new char[] { '|' }); } for (int n = 0; n < strUserAnswers.Length; n++) { string strN = intToString(int.Parse(strUserAnswers[n]) + 1); if (n == 0) { strUserAnswer += strN; } else { strUserAnswer += "," + strN; } } //多选 if (paperSubject.ItemTypeId == 2) { string[] strAnswer = paperItem.SelectAnswer.Split(new char[] { '|' }); for (int n = 0; n < strAnswer.Length; n++) { string strN = intToString(n + 1); string strij = "-" + paperItem.RandomExamItemId + "-" + i.ToString() + "-" + j.ToString() + "-" + n.ToString(); string strName = i.ToString() + j.ToString(); Response.Write(" <tr ><td class='ExamItemAnswer'> " + strN + "." + strAnswer[n] + "</td></tr >"); } } else { //单选 string[] strAnswer = paperItem.SelectAnswer.Split(new char[] { '|' }); for (int n = 0; n < strAnswer.Length; n++) { string strN = intToString(n + 1); string strij = "-" + paperItem.RandomExamItemId + "-" + i.ToString() + "-" + j.ToString() + "-" + n.ToString(); string strName = i.ToString() + j.ToString(); Response.Write("<tr > <td class='ExamItemAnswer'> " + strN + "." + strAnswer[n] + "</td></tr >"); } } // 组织正确答案 string[] strRightAnswers = paperItem.StandardAnswer.Split(new char[] { '|' }); string strRightAnswer = ""; for (int n = 0; n < strRightAnswers.Length; n++) { string strN = intToString(int.Parse(strRightAnswers[n]) + 1); if (n == 0) { strRightAnswer += strN; } else { strRightAnswer += "," + strN; } } string strScore = "0"; if (strRightAnswer == strUserAnswer) { strScore = System.String.Format("{0:0.##}", paperSubject.UnitScore); } Response.Write(" <tr><td class='ExamAnswer'> ★标准答案:" + "<span id='span-" + paperItem.RandomExamItemId + "-0' name='span-" + paperItem.RandomExamItemId + "'>" + strRightAnswer + "</span> 考生答案:" + "<span id='span-" + paperItem.RandomExamItemId + "-1' name='span-" + paperItem.RandomExamItemId + "'>" + strUserAnswer + "</span> 得分:" + strScore + "</td></tr>"); } } Response.Write(" </table> "); } } else { SessionSet.PageMessage = "数据错误!"; return; } }
protected void ItemAnswerChangeCallBack_Callback(object sender, CallBackEventArgs e) { try { RandomExamResultAnswerCurrentBLL objAnswerCurrentBll = new RandomExamResultAnswerCurrentBLL(); RandomExamResultAnswerCurrent objAnswerCurrent = objAnswerCurrentBll.GetExamResultAnswerCurrent( Convert.ToInt32(ViewState["RandomExamResultID"].ToString()), Convert.ToInt32(e.Parameters[0])); //objAnswerCurrent.RandomExamResultId = Convert.ToInt32(ViewState["RandomExamResultID"].ToString()); //objAnswerCurrent.RandomExamItemId = Convert.ToInt32(e.Parameters[0]); objAnswerCurrent.JudgeStatusId = 0; objAnswerCurrent.JudgeRemark = string.Empty; objAnswerCurrent.ExamTime = 0; if (e.Parameters[3] == "radio") { objAnswerCurrent.Answer = e.Parameters[1]; } else { if (e.Parameters[2] == "true") { objAnswerCurrent.Answer = (objAnswerCurrent.Answer + "|" + e.Parameters[1]).TrimStart('|'); } else { objAnswerCurrent.Answer = (("|" + objAnswerCurrent.Answer + "|").Replace("|" + e.Parameters[1] + "|", "|")).TrimStart( '|').TrimEnd('|'); } } objAnswerCurrentBll.UpdateExamResultAnswerCurrent(objAnswerCurrent); RandomExamResultCurrentBLL objResultCurrentBll = new RandomExamResultCurrentBLL(); RailExam.Model.RandomExamResultCurrent objResultCurrent = objResultCurrentBll.GetRandomExamResult(Convert.ToInt32(ViewState["RandomExamResultID"].ToString())); objResultCurrent.ExamTime = Convert.ToInt32(ViewState["LastExamTime"].ToString()) + GetSecondBetweenTwoDate(DateTime.Now, DateTime.Parse(ViewState["BeginTime"].ToString())); objResultCurrentBll.UpdateRandomExamResultCurrent(objResultCurrent); //OracleAccess db = new OracleAccess(); //string sqlCommand = "USP_Random_EXAM_ANSWER_Cur_U"; //OracleParameter para1 = new OracleParameter("p_random_exam_result_id", OracleType.Number); //para1.Value = objAnswerCurrent.RandomExamResultId; //OracleParameter para2 = new OracleParameter("p_random_exam_item_id", OracleType.Number); //para2.Value = objAnswerCurrent.RandomExamItemId; //OracleParameter para3 = new OracleParameter("p_answer", OracleType.NVarChar); //para3.Value = objAnswerCurrent.Answer; //OracleParameter para4 = new OracleParameter("p_exam_time", OracleType.Number); //para4.Value = objAnswerCurrent.ExamTime; //OracleParameter para5 = new OracleParameter("p_judge_remark", OracleType.NVarChar); //para5.Value = objAnswerCurrent.JudgeRemark; //IDataParameter[] paras = new IDataParameter[] { para1, para2, para3, para4, para5}; //db.ExecuteNonQueryPro(sqlCommand, paras); } catch { Response.Write("<script>window.parent.parent.location='/RailExamBao/Common/Error.aspx?error=考试出现异常,请重启微机重新登录考试!'</script>"); } }
private void SaveAnswerToDB(string strAnswer) { string strId = Request.QueryString.Get("id"); RandomExamItemBLL randomItemBLL = new RandomExamItemBLL(); RandomExamResultCurrentBLL objResultCurrentBll = new RandomExamResultCurrentBLL(); RailExam.Model.RandomExamResultCurrent objResultCurrent = objResultCurrentBll.GetNowRandomExamResultInfo(Convert.ToInt32(ViewState["EmployeeID"].ToString()), Convert.ToInt32(strId)); //更新考试成绩表时传入的主键应为站段的成绩表的主键ID objResultCurrent.RandomExamResultId = int.Parse(ViewState["RandomExamResultID"].ToString()); objResultCurrent.RandomExamId = int.Parse(strId); objResultCurrent.AutoScore = 0; objResultCurrent.CurrentDateTime = DateTime.Parse(ViewState["EndTime"].ToString()); objResultCurrent.ExamTime = Convert.ToInt32(ViewState["LastExamTime"].ToString()) + GetSecondBetweenTwoDate(DateTime.Parse(ViewState["EndTime"].ToString()), DateTime.Parse(ViewState["BeginTime"].ToString())); objResultCurrent.EndDateTime = DateTime.Parse(ViewState["EndTime"].ToString()); objResultCurrent.Score = 0; objResultCurrent.OrganizationId = int.Parse(ViewState["OrgID"].ToString()); objResultCurrent.Memo = ""; objResultCurrent.StatusId = 2; objResultCurrent.AutoScore = 0; objResultCurrent.CorrectRate = 0; objResultCurrent.ExamineeId = int.Parse(ViewState["EmployeeID"].ToString()); string[] str1 = strAnswer.Split(new char[] { '$' }); RandomExamResultAnswerCurrentBLL randomExamResultAnswerBLL = new RandomExamResultAnswerCurrentBLL(); //randomExamResultAnswerBLL.DeleteExamResultAnswerCurrent(Convert.ToInt32(ViewState["RandomExamResultID"].ToString())); //IList<RandomExamResultAnswerCurrent> randomExamResultAnswers = new List<RandomExamResultAnswerCurrent>(); int randomExamResultId = int.Parse(ViewState["RandomExamResultID"].ToString()); for (int n = 0; n < str1.Length; n++) { string str2 = str1[n].ToString(); string[] str3 = str2.Split(new char[] { '|' }); string strPaperItemId = str3[0].ToString(); string strTrueAnswer = str2.ToString().Substring(strPaperItemId.Length + 1); RandomExamResultAnswerCurrent randomExamResultAnswer = new RandomExamResultAnswerCurrent(); randomExamResultAnswer.RandomExamResultId = randomExamResultId; randomExamResultAnswer.RandomExamItemId = int.Parse(strPaperItemId); randomExamResultAnswer.JudgeStatusId = 0; randomExamResultAnswer.JudgeRemark = string.Empty; randomExamResultAnswer.ExamTime = 0; randomExamResultAnswer.Answer = strTrueAnswer; //randomExamResultAnswers.Add(randomExamResultAnswer); randomExamResultAnswerBLL.UpdateExamResultAnswerCurrent(randomExamResultAnswer); } try { //将更新答卷信息 //randomExamResultAnswerBLL.AddExamResultAnswerCurrentSave(randomExamResultId, randomExamResultAnswers); //更新实时考试记录 objResultCurrentBll.UpdateRandomExamResultCurrent(objResultCurrent); //获取最后考试成绩 //RandomExamResultCurrent randomExamResultCurrent = objResultCurrentBll.GetRandomExamResult(Convert.ToInt32(ViewState["RandomExamResultID"].ToString())); //decimal nowScore = randomExamResultCurrent.Score; //将实时考试记录(临时表)转存到正式考试成绩表和答卷表 RandomExamResultBLL objResultBll = new RandomExamResultBLL(); //int randomExamResultID = objResultBll.RemoveResultAnswer(Convert.ToInt32(ViewState["RandomExamResultID"].ToString())); //将实时考试记录(临时表)转存到中间考试成绩表和答卷表 int randomExamResultID = objResultBll.RemoveResultAnswerCurrent(Convert.ToInt32(ViewState["RandomExamResultID"].ToString())); //删除登录信息 SystemUserLoginBLL objloginBll = new SystemUserLoginBLL(); objloginBll.DeleteSystemUserLogin(Convert.ToInt32(ViewState["EmployeeID"].ToString())); Response.Write("<script>window.parent.parent.location = '/RailExamBao/Online/Exam/ExamSuccess.aspx?ExamType=1&ExamResultID=" + randomExamResultID + "'</script>"); } catch { SystemUserLoginBLL objloginBll = new SystemUserLoginBLL(); objloginBll.DeleteSystemUserLogin(Convert.ToInt32(ViewState["EmployeeID"].ToString())); string strSql = "update Random_Exam_Result_Current set Exam_Time=Exam_Time-180 where Random_Exam_ID=" + strId + " and Examinee_ID=" + ViewState["EmployeeID"]; OracleAccess db = new OracleAccess(); db.ExecuteNonQuery(strSql); Response.Write("<script>window.parent.parent.location = '/RailExamBao/Common/OtherError.aspx?error=提交试卷失败,请重新进入考试再次进行提交'</script>"); } //如果在站段是随到随考考试,成绩自动上传至路局 //if(ViewState["NowStartMode"].ToString() == PrjPub.START_MODE_NO_CONTROL.ToString() && !PrjPub.IsServerCenter) //{ // objResultBll.RemoveRandomExamResultToServer(Convert.ToInt32(strId), Convert.ToInt32(ConfigurationManager.AppSettings["StationID"])); //} }