public void FillPaper() { RandomExamItemBLL randomItemBLL = new RandomExamItemBLL(); OracleAccess db = new OracleAccess(); IList <RandomExamItem> PaperItems = new List <RandomExamItem>(); PaperItems = randomItemBLL.GetItemsCurrentCheck(); string strSql = "select * from System_Exam where System_Exam_ID=1"; DataTable dt = db.RunSqlDataSet(strSql).Tables[0]; int examNumber; if (dt.Rows.Count > 0) { examNumber = Convert.ToInt32(dt.Rows[0]["Exam_Number"]); } else { examNumber = 10; } int totalCount = examNumber; int otherCount = totalCount / 4; int singleCount = totalCount - otherCount * 3; int m = 4; if (otherCount == 0) { m = 1; } for (int i = 0; i < m; i++) { int itemCount = 0; int b = 0, e = 0; string typeName = string.Empty; if (i == 0) { itemCount = singleCount; typeName = "第一大题:单选"; b = 0; e = singleCount; } else if (i == 1) { itemCount = otherCount; typeName = "第二大题:多选"; b = singleCount; e = singleCount + otherCount; } else if (i == 2) { itemCount = otherCount; typeName = "第三大题:判断"; b = singleCount + otherCount; e = singleCount + otherCount * 2; } else if (i == 3) { itemCount = otherCount; typeName = "第四大题:综合选择题"; b = singleCount + otherCount * 2; e = singleCount + otherCount * 3; } Response.Write("<br>"); Response.Write("<span class='StudentLeftInfo'><b> " + typeName + "</b></span>"); Response.Write("<br>"); if (PaperItems != null) { Response.Write("<table width='100%' border='1' style='background-color:#ffffff'>"); int z = 1; int tempK = 0; int count = 1; for (int j = b; j < e; j++) { if (j >= PaperItems.Count) { continue; } RandomExamItem paperItem = PaperItems[j]; int k = j + 1 - b; 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='CheckAttendExamNew.aspx?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='CheckAttendExamNew.aspx?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++; string str = "select * from Random_Exam_Item_" + DateTime.Today.Year + " where Random_Exam_ID=" + paperItem.RandomExamId + " and Parent_Item_ID=" + paperItem.ItemId + " order by Item_Index"; DataSet ds = db.RunSqlDataSet(str); foreach (DataRow dr in ds.Tables[0].Rows) { if (count % 3 == 1) { Response.Write("</tr >"); Response.Write("<tr><td class='StudentTableInfo' id='Item" + i + j + z + "' >" + "<a href='CheckAttendExamNew.aspx?employeeID=" + Request.QueryString.Get("employeeID") + "#Test" + i + j + z + "' target='ifExamInfo' style='cursor: hand;'><b>" + tempK + "-(" + z + ")</b></a></td>"); } else { Response.Write("<td class='StudentTableInfo' id='Item" + i + j + z + "' >" + "<a href='CheckAttendExamNew.aspx?employeeID=" + Request.QueryString.Get("employeeID") + "#Test" + i + j + z + "' target='ifExamInfo' style='cursor: hand;'><b>" + tempK + "-(" + z + ")</b></a></td>"); } z++; count++; } } } } Response.Write("</tr >"); Response.Write("</table>"); } else { SessionSet.PageMessage = "未找到记录!"; } } }
protected void FillPaper() { OracleAccess db = new OracleAccess(); RandomExamItemBLL randomItemBLL = new RandomExamItemBLL(); IList <RandomExamItem> PaperItems = randomItemBLL.GetItemsCurrentCheck(); int totalCount = Convert.ToInt32(ViewState["ExamNumber"]); int otherCount = totalCount / 4; int singleCount = totalCount - otherCount * 3; int m = 4; if (otherCount == 0) { m = 1; } for (int i = 0; i < m; i++) { int itemCount = 0; int b = 0, e = 0; string typeName = string.Empty; if (i == 0) { itemCount = singleCount; typeName = "单选"; b = 0; e = singleCount; } else if (i == 1) { itemCount = otherCount; typeName = "多选"; b = singleCount; e = singleCount + otherCount; } else if (i == 2) { itemCount = otherCount; typeName = "判断"; b = singleCount + otherCount; e = singleCount + otherCount * 2; } else if (i == 3) { itemCount = otherCount; typeName = "综合选择题"; b = singleCount + otherCount * 2; e = singleCount + otherCount * 3; } Response.Write("<table width='95%' class='ExamContent'>"); Response.Write(" <tr> <td class='ExamBigTitle'"); if (i == 3) { Response.Write(" colspan='3' "); } Response.Write(">" + GetNo(i) + ""); Response.Write("、" + typeName + ""); Response.Write(" (共" + itemCount + "题)</td></tr >"); if (PaperItems != null) { int z = 1; int x = 1; for (int j = b; j < e; j++) { if (j >= PaperItems.Count) { continue; } RandomExamItem paperItem = PaperItems[j]; int k = j + 1 - b; if (paperItem.TypeId != PrjPub.ITEMTYPE_FILLBLANKDETAIL) { z = 1; if (paperItem.TypeId == PrjPub.ITEMTYPE_FILLBLANK) { k = x; x++; 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 + " </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 + " " + "<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 >"); } } // 组织用户答案 if (paperItem.TypeId == 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(); 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 (paperItem.TypeId == PrjPub.ITEMTYPE_SINGLECHOOSE || paperItem.TypeId == 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(); 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_FILLBLANK) { string str = "select * from Random_Exam_Item_" + DateTime.Today.Year + " where Random_Exam_ID=" + paperItem.RandomExamId + " and Parent_Item_ID=" + paperItem.ItemId + " order by Item_Index"; DataSet ds = db.RunSqlDataSet(str); foreach (DataRow dr in ds.Tables[0].Rows) { string[] strAnswer = dr["Select_Answer"].ToString().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() + "-" + z.ToString(); string strName = i.ToString() + j.ToString() + z.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 + z + "' class='ExamItem' style='width:10%' RowSpan='" + row + "'><a name='Test" + i + j + z + "' id='Test" + i + j + z + "'></a>" + " (" + z + "). " + "<a href='#Test" + i + j + z + "' id='Empty" + i + j + z + "' 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>"); } 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>"); } 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>"); }