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; } PaperItemBLL kBLL = new PaperItemBLL(); PaperSubjectBLL kBSLL = new PaperSubjectBLL(); ExamResultBLL examResultBLL = new ExamResultBLL(); ExamResultAnswerBLL examResultAnswerBLL = new ExamResultAnswerBLL(); RailExam.Model.ExamResult examResult = new RailExam.Model.ExamResult(); if (ViewState["NowOrgID"].ToString() == orgid) { examResult = examResultBLL.GetExamResult(Convert.ToInt32(strId)); } else { examResult = examResultBLL.GetExamResultByOrgID(Convert.ToInt32(strId), Convert.ToInt32(orgid)); } // Not found if (examResult == null) { SessionSet.PageMessage = "数据错误!"; return; } IList <PaperSubject> PaperSubjects = new List <PaperSubject>(); if (ViewState["NowOrgID"].ToString() == orgid) { PaperSubjects = kBSLL.GetPaperSubjectByPaperId(examResult.PaperId); } else { PaperSubjects = kBSLL.GetPaperSubjectByPaperIdByOrgID(examResult.PaperId, Convert.ToInt32(orgid)); } PaperSubject paperSubject = null; IList <PaperItem> PaperItems = null; IList <ExamResultAnswer> examResultAnswers = new List <ExamResultAnswer>(); if (ViewState["NowOrgID"].ToString() == orgid) { examResultAnswers = examResultAnswerBLL.GetExamResultAnswers(examResult.ExamResultIDStation); } else { examResultAnswers = examResultAnswerBLL.GetExamResultAnswersByOrgID(examResult.ExamResultIDStation, Convert.ToInt32(orgid)); } if (PaperSubjects != null) { for (int i = 0; i < PaperSubjects.Count; i++) { paperSubject = PaperSubjects[i]; if (ViewState["NowOrgID"].ToString() == orgid) { PaperItems = kBLL.GetItemsByPaperSubjectId(paperSubject.PaperSubjectId); } else { PaperItems = kBLL.GetItemsByPaperSubjectIdByOrgID(paperSubject.PaperSubjectId, Convert.ToInt32(orgid)); } Response.Write("<table width='100%'>"); Response.Write(" <tr > <td class='ExamBigTitle' >"); Response.Write(" " + GetNo(i) + ""); Response.Write(". " + paperSubject.SubjectName + ""); Response.Write(" (共" + paperSubject.ItemCount + "题,共" + paperSubject.ItemCount * paperSubject.UnitScore + "分)</td></tr >"); if (PaperItems != null) { for (int j = 0; j < PaperItems.Count; j++) { PaperItem paperItem = PaperItems[j]; int k = j + 1; Response.Write("<tr > <td class='ExamResultItem'> " + k + ". " + paperItem.Content + " (" + paperSubject.UnitScore + "分)</td></tr >"); // 组织用户答案 ExamResultAnswer theExamResultAnswer = null; string[] strUserAnswers = new string[0]; string strUserAnswer = string.Empty; foreach (ExamResultAnswer resultAnswer in examResultAnswers) { if (resultAnswer.PaperItemId == paperItem.PaperItemId) { theExamResultAnswer = resultAnswer; break; } } // 若子表无记录,结束页面输出 if (theExamResultAnswer == null) { SessionSet.PageMessage = "数据错误!"; } // 否则组织考生答案 if (theExamResultAnswer.Answer != null) { 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.PaperItemId + "-" + i.ToString() + "-" + j.ToString() + "-" + n.ToString(); string strName = i.ToString() + j.ToString(); Response.Write(" <tr ><td class='ExamItemAnswer'> " + "<input type='checkbox' id='Answer" + strij + "' name='Answer" + strName + "' " + (Array.IndexOf(strUserAnswers, n) > -1 ? "checked" : "") + " disabled/> " + 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.PaperItemId + "-" + i.ToString() + "-" + j.ToString() + "-" + n.ToString(); string strName = i.ToString() + j.ToString(); Response.Write("<tr > <td class='ExamItemAnswer'> " + "<input type='Radio' id='RAnswer" + strij + "' name='RAnswer" + strName + "' " + (Array.IndexOf(strUserAnswers, n) > -1 ? "checked" : "") + " disabled/> " + 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; } } Response.Write(" <tr><td class='ExamAnswer'> ★标准答案:" + "<span id='span-" + paperItem.PaperItemId + "-0' name='span-" + paperItem.PaperItemId + "'>" + strRightAnswer + "</span> 考生答案:" + "<span id='span-" + paperItem.PaperItemId + "-1' name='span-" + paperItem.PaperItemId + "'>" + strUserAnswer + "</span> 得分: " + theExamResultAnswer.JudgeScore.ToString() + "</td></tr>"); } } Response.Write(" </table> "); } } else { SessionSet.PageMessage = "数据错误!"; return; } }
protected string GetFillExamPaperString(string strId, string orgid) { string strPaperString = ""; PaperItemBLL kBLL = new PaperItemBLL(); PaperSubjectBLL kBSLL = new PaperSubjectBLL(); ExamResultBLL examResultBLL = new ExamResultBLL(); ExamResultAnswerBLL examResultAnswerBLL = new ExamResultAnswerBLL(); RailExam.Model.ExamResult examResult = new RailExam.Model.ExamResult(); if (ViewState["NowOrgID"].ToString() == orgid) { examResult = examResultBLL.GetExamResult(Convert.ToInt32(strId)); } else { examResult = examResultBLL.GetExamResultByOrgID(Convert.ToInt32(strId), Convert.ToInt32(orgid)); } IList <PaperSubject> PaperSubjects = new List <PaperSubject>(); if (ViewState["NowOrgID"].ToString() == orgid) { PaperSubjects = kBSLL.GetPaperSubjectByPaperId(examResult.PaperId); } else { PaperSubjects = kBSLL.GetPaperSubjectByPaperIdByOrgID(examResult.PaperId, Convert.ToInt32(orgid)); } RailExam.Model.PaperSubject paperSubject = null; IList <RailExam.Model.PaperItem> PaperItems = null; IList <ExamResultAnswer> examResultAnswers = new List <ExamResultAnswer>(); if (ViewState["NowOrgID"].ToString() == orgid) { examResultAnswers = examResultAnswerBLL.GetExamResultAnswers(examResult.ExamResultIDStation); } else { examResultAnswers = examResultAnswerBLL.GetExamResultAnswersByOrgID(examResult.ExamResultIDStation, Convert.ToInt32(orgid)); } for (int i = 0; i < PaperSubjects.Count; i++) { paperSubject = PaperSubjects[i]; if (ViewState["NowOrgID"].ToString() == orgid) { PaperItems = kBLL.GetItemsByPaperSubjectId(paperSubject.PaperSubjectId); } else { PaperItems = kBLL.GetItemsByPaperSubjectIdByOrgID(paperSubject.PaperSubjectId, Convert.ToInt32(orgid)); } strPaperString += " <table width='100%' border='0' cellpadding='0' cellspacing='0'>"; strPaperString += " <tr><td style='font-size:14pt'>"; strPaperString += " " + GetNo(i) + ""; strPaperString += ". " + paperSubject.SubjectName + ""; strPaperString += " (共" + paperSubject.ItemCount + "题,共" + paperSubject.ItemCount * paperSubject.UnitScore + "分)</td></tr >"; if (PaperItems != null) { for (int j = 0; j < PaperItems.Count; j++) { RailExam.Model.PaperItem paperItem = PaperItems[j]; int k = j + 1; strPaperString += "<tr > <td style='font-size:10.5pt'> " + k + ". " + paperItem.Content + " (" + paperSubject.UnitScore + "分)</td></tr >"; // 组织用户答案 RailExam.Model.ExamResultAnswer theExamResultAnswer = null; string[] strUserAnswers = new string[0]; string strUserAnswer = string.Empty; foreach (RailExam.Model.ExamResultAnswer resultAnswer in examResultAnswers) { if (resultAnswer.PaperItemId == paperItem.PaperItemId) { theExamResultAnswer = resultAnswer; break; } } // 若子表无记录,结束页面输出 if (theExamResultAnswer == null) { SessionSet.PageMessage = "数据错误!"; } // 否则组织考生答案 if (theExamResultAnswer.Answer != null) { 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.PaperItemId + "-" + i.ToString() + "-" + j.ToString() + "-" + n.ToString(); string strName = i.ToString() + j.ToString(); strPaperString += " <tr ><td style='font-size:10.5pt'> " + 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.PaperItemId + "-" + i.ToString() + "-" + j.ToString() + "-" + n.ToString(); string strName = i.ToString() + j.ToString(); strPaperString += "<tr > <td style='font-size:10.5pt'> " + 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; } } strPaperString += " <tr><td style='font-size:10.5pt'> ★标准答案:" + "<span id='span-" + paperItem.PaperItemId + "-0' name='span-" + paperItem.PaperItemId + "'>" + strRightAnswer + "</span> 考生答案:" + "<span id='span-" + paperItem.PaperItemId + "-1' name='span-" + paperItem.PaperItemId + "'>" + strUserAnswer + "</span> 得分: " + theExamResultAnswer.JudgeScore.ToString() + "</td></tr>"; } } strPaperString += " </table> "; } return(strPaperString); }