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; } }
public void FillPaper() { string strId = Request.QueryString.Get("id"); RandomExamBLL randomExamBLL = new RandomExamBLL(); RailExam.Model.RandomExam randomExam = randomExamBLL.GetExam(int.Parse(strId)); ViewState["Year"] = randomExam.BeginTime.Year.ToString(); RandomExamResultCurrentBLL objResultCurrentBll = new RandomExamResultCurrentBLL(); RailExam.Model.RandomExamResultCurrent randomExamResult = objResultCurrentBll.GetNowRandomExamResultInfo(Convert.ToInt32(Request.QueryString.Get("employeeID")), Convert.ToInt32(strId)); int RandomExamId = Convert.ToInt32(strId); int randomExamResultId = randomExamResult.RandomExamResultId; RandomExamItemBLL randomItemBLL = new RandomExamItemBLL(); RandomExamSubjectBLL subjectBLL = new RandomExamSubjectBLL(); IList <RandomExamSubject> randomExamSubjects = subjectBLL.GetRandomExamSubjectByRandomExamId(RandomExamId); RandomExamResultAnswerCurrentBLL randomExamResultAnswerBLL = new RandomExamResultAnswerCurrentBLL(); IList <RandomExamResultAnswerCurrent> examResultAnswers = new List <RandomExamResultAnswerCurrent>(); examResultAnswers = randomExamResultAnswerBLL.GetExamResultAnswersCurrent(randomExamResultId); OracleAccess db = new OracleAccess(); 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, Convert.ToInt32(ViewState["Year"].ToString())); Response.Write("<br>"); Response.Write("<span class='StudentLeftInfo'><b> 第" + GetNo(i) + "大题:" + paperSubject.SubjectName + "</b></span>"); Response.Write("<br>"); if (PaperItems != null) { Response.Write("<table width='100%' border='1'>"); int z = 1; int tempK = 0; int count = 1; for (int j = 0; j < PaperItems.Count; j++) { RandomExamItem paperItem = PaperItems[j]; int k = j + 1; if (paperItem.TypeId != PrjPub.ITEMTYPE_FILLBLANKDETAIL && paperItem.TypeId != PrjPub.ITEMTYPE_FILLBLANK) { z = 1; if (k % 5 == 1) { Response.Write("</tr >"); Response.Write("<tr><td class='StudentTableInfo' id='Item" + i + j + "' >" + "<a href='AttendExamNew.aspx?id=" + strId + "&employeeID=" + Request.QueryString.Get("employeeID") + "#Test" + i + j + "' target='ifExamInfo' style='cursor: hand;'><b>" + k + "</b></a></td>"); } else { Response.Write("<td class='StudentTableInfo' id='Item" + i + j + "' >" + "<a href='AttendExamNew.aspx?id=" + strId + "&employeeID=" + Request.QueryString.Get("employeeID") + "#Test" + i + j + "' target='ifExamInfo' style='cursor: hand;'><b>" + k + "</b></a></td>"); } } else { if (paperItem.TypeId == PrjPub.ITEMTYPE_FILLBLANK) { z = 1; tempK++; } if (count % 3 == 1) { Response.Write("</tr >"); Response.Write("<tr><td class='StudentTableInfo' id='Item" + i + j + "' >" + "<a href='AttendExamNew.aspx?id=" + strId + "&employeeID=" + Request.QueryString.Get("employeeID") + "#Test" + i + j + "' target='ifExamInfo' style='cursor: hand;'><b>" + tempK + "-(" + z + ")</b></a></td>"); } else { Response.Write("<td class='StudentTableInfo' id='Item" + i + j + "' >" + "<a href='AttendExamNew.aspx?id=" + strId + "&employeeID=" + Request.QueryString.Get("employeeID") + "#Test" + i + j + "' target='ifExamInfo' style='cursor: hand;'><b>" + tempK + "-(" + z + ")</b></a></td>"); } z++; count++; } } Response.Write("</tr >"); Response.Write("</table>"); } } //ClientScript.RegisterStartupScript(GetType(), "StartStyle", "<script>StartStyle()</script>"); } else { SessionSet.PageMessage = "未找到记录!"; } }
protected void FillPaper() { string strId = Request.QueryString.Get("id"); if (string.IsNullOrEmpty(strId)) { SessionSet.PageMessage = "缺少参数!"; return; } int RandomExamId = Convert.ToInt32(strId); int randomExamResultId = Convert.ToInt32(ViewState["RandomExamResultID"]); RandomExamItemBLL randomItemBLL = new RandomExamItemBLL(); RandomExamSubjectBLL subjectBLL = new RandomExamSubjectBLL(); IList <RandomExamSubject> randomExamSubjects = subjectBLL.GetRandomExamSubjectByRandomExamId(RandomExamId); //RandomExamResultAnswerCurrentBLL randomExamResultAnswerBLL = new RandomExamResultAnswerCurrentBLL(); //IList<RandomExamResultAnswerCurrent> examResultAnswers = new List<RandomExamResultAnswerCurrent>(); //examResultAnswers = randomExamResultAnswerBLL.GetExamResultAnswersCurrent(randomExamResultId); IList <RandomExamItem> totalItems = randomItemBLL.GetItemsCurrent(0, randomExamResultId, Convert.ToInt32(ViewState["Year"].ToString())); 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, Convert.ToInt32(ViewState["Year"].ToString())); PaperItems = GetSubjectItems(totalItems, paperSubject.RandomExamSubjectId); int itemCount = 0; if (paperSubject.ItemTypeId == PrjPub.ITEMTYPE_FILLBLANK) { foreach (RandomExamItem randomExamItem in PaperItems) { if (randomExamItem.TypeId == PrjPub.ITEMTYPE_FILLBLANK) { itemCount++; } } } else { itemCount = PaperItems.Count; } Response.Write("<table width='95%' class='ExamContent'>"); Response.Write(" <tr> <td class='ExamBigTitle' colspan='3'>"); Response.Write(" " + GetNo(i) + ""); Response.Write("、" + paperSubject.SubjectName + ""); Response.Write(" (共" + itemCount + "题,共" + System.String.Format("{0:0.##}", itemCount * paperSubject.UnitScore) + "分)</td></tr >"); if (PaperItems != null) { int z = 1; int x = 1; for (int j = 0; j < PaperItems.Count; j++) { RandomExamItem paperItem = PaperItems[j]; int k = j + 1; if (paperItem.TypeId != PrjPub.ITEMTYPE_FILLBLANKDETAIL) { z = 1; if (paperItem.TypeId == PrjPub.ITEMTYPE_FILLBLANK) { k = x; x++; IList <RandomExamItem> randomExamItems = randomItemBLL.GetItemsByParentItemID(paperItem.ItemId, RandomExamId, Convert.ToInt32(ViewState["Year"].ToString())); Response.Write("<tr><td id='Item" + i + j + "' class='ExamItem' colspan='3'><a name='Test" + i + j + "' id='Test" + i + j + "'></a> " + k + ". " + paperItem.Content + " (共" + System.String.Format("{0:0.##}", paperSubject.UnitScore) + "分,其中" + "每题" + System.String.Format("{0:0.##}", (randomExamItems.Count != 0 ? (decimal)paperSubject.UnitScore / (decimal)randomExamItems.Count : 0)) + "分)" + "</td></tr >"); } else { Response.Write("<tr><td id='Item" + i + j + "' class='ExamItem' colspan='3'><a name='Test" + i + j + "' id='Test" + i + j + "'></a> " + k + ". " + paperItem.Content + " (" + System.String.Format("{0:0.##}", paperSubject.UnitScore) + "分) " + "<a href='#Test" + i + j + "' id='Empty" + i + j + "' onclick='clickEmpty(this)'style='cursor: hand;' title='清空选择'>" + "<img src='../images/clear.png' style='border:0'/></a>" + "</td></tr >"); } } //else //{ // string strSql = "select * from Random_Exam_Item_" + ViewState["Year"] + " where Item_ID='" + // paperItem.ItemId + "' and Random_Exam_ID=" + strId; // DataRow dr = db.RunSqlDataSet(strSql).Tables[0].Rows[0]; // IList<RandomExamItem> randomExamItems = randomItemBLL.GetItemsByParentItemID(Convert.ToInt32(dr["Parent_Item_ID"]),RandomExamId,Convert.ToInt32(ViewState["Year"].ToString())); // Response.Write("<tr><td id='Item" + i + j + "' class='ExamItem' colspan='2'><a name='Test" + i + j + "' id='Test" + i + j + "'></a>" // +" (" + z + "). " + paperItem.Content + // " (" + System.String.Format("{0:0.##}", (decimal)paperSubject.UnitScore / (decimal)randomExamItems.Count) + "分) " // + "<a href='#Test" + i + j + "' id='Empty" + i + j + "' onclick='clickEmpty(this)'style='cursor: hand;' title='清空选择'>" // + "<img src='../images/clear.png' style='border:0'/></a>" // +"</td></tr >"); // z++; //} // 组织用户答案 string[] strUserAnswers = new string[0]; string strUserAnswer = string.Empty; //RandomExamResultAnswerCurrent theExamResultAnswer = null; //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[] { '|' }); //} if (paperItem.Answer == null) { SessionSet.PageMessage = "数据错误!"; } if (!string.IsNullOrEmpty(paperItem.Answer)) { strUserAnswers = paperItem.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 == PrjPub.ITEMTYPE_MULTICHOOSE) //多选 { 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(); if (("," + strUserAnswer + ",").IndexOf("," + strN + ",") != -1) { Response.Write( "<tr><td class='ExamItemAnswer' colspan='3'> <input onclick='CheckStyle(this)' type='checkbox' checked='checked' id='Answer" + strij + "' name='Answer" + strName + "'><label for='Answer" + strij + "'> " + strN + "." + strAnswer[n] + "</label></td></tr>"); } else { Response.Write( "<tr><td class='ExamItemAnswer' colspan='3'> <input onclick='CheckStyle(this)' type='checkbox' id='Answer" + strij + "' name='Answer" + strName + "'><label for='Answer" + strij + "'> " + strN + "." + strAnswer[n] + "</label></td></tr>"); } } } else if (paperSubject.ItemTypeId == PrjPub.ITEMTYPE_SINGLECHOOSE || paperSubject.ItemTypeId == PrjPub.ITEMTYPE_JUDGE) //单选 { 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(); if (strUserAnswer == strN) { Response.Write( "<tr><td class='ExamItemAnswer' colspan='3'> <input onclick='CheckStyle(this)' type='Radio' checked='checked' id='RAnswer" + strij + "' name='RAnswer" + strName + "'> <label for='RAnswer" + strij + "' >" + strN + "." + strAnswer[n] + "</label></td></tr>"); } else { Response.Write( "<tr><td class='ExamItemAnswer' colspan='3'> <input onclick='CheckStyle(this)' type='Radio' id='RAnswer" + strij + "' name='RAnswer" + strName + "'> <label for='RAnswer" + strij + "' >" + strN + "." + strAnswer[n] + "</label></td></tr>"); } } } else if (paperItem.TypeId == PrjPub.ITEMTYPE_FILLBLANKDETAIL) { 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(); if (n == 0) { int row = strAnswer.Length % 2 == 0 ? strAnswer.Length / 2 : strAnswer.Length / 2 + 1; Response.Write("<tr><td id='Item" + i + j + "' class='ExamItem' style='width:10%;vertical-align: top' RowSpan='" + row + "'><a name='Test" + i + j + "' id='Test" + i + j + "'></a>" + " (" + z + "). " + "<a href='#Test" + i + j + "' id='Empty" + i + j + "' onclick='clickEmpty(this)'style='cursor: hand;' title='清空选择'>" + "<img src='../images/clear.png' style='border:0'/></a>" + "</td>"); } if (n % 2 == 0 && n != 0) { Response.Write("<tr>"); } if (strUserAnswer == strN) { Response.Write( "<td class='ExamItemAnswer'> <input onclick='CheckStyle(this)' type='Radio' checked='checked' id='RAnswer" + strij + "' name='RAnswer" + strName + "'><label for='RsAnswer" + strij + "'>" + strN + "." + strAnswer[n] + "</label></td>"); } else { Response.Write( "<td class='ExamItemAnswer'> <input onclick='CheckStyle(this)' type='Radio' id='RAnswer" + strij + "' name='RAnswer" + strName + "'><label for='RAnswer" + strij + "'> " + strN + "." + strAnswer[n] + "</label></td>"); } if (n % 2 == 1) { Response.Write("</tr>"); } } z++; } } } Response.Write("</table>"); } //<input id='btnEmpty' class='buttonLong' name='btnEmpty' type='button' value='标记未做试题' onclick='CheckEmpty()'/> Response.Write(" <div class='ExamButton'><input id='btnClose' class='button' name='btnSave' type='button' value='提交答卷' onclick='SaveRecord()'/> </div><br><br><br><br><br><br>"); ClientScript.RegisterStartupScript(GetType(), "StartStyle", "<script>StartStyle()</script>"); } else { SessionSet.PageMessage = "未找到记录!"; } }