protected void Page_Load(object sender, EventArgs e) { string strId = Request.QueryString.Get("PaperId"); string strExamId = Request.QueryString.Get("ExamId"); ViewState["BeginTime"] = DateTime.Now.ToString(); ViewState["OrgID"] = PrjPub.CurrentStudent.OrgID; ViewState["StudentID"] = PrjPub.StudentID; if (strId != null && strId != "") { try { ExamResultBLL examResultBLL = new ExamResultBLL(); RailExam.Model.ExamResult examResults = examResultBLL.GetExamResult(int.Parse(strId), int.Parse(strExamId), PrjPub.CurrentStudent.EmployeeID); if (examResults != null) { Response.Write("<script>alert('您已经参加过该考试!'); top.window.close();</script>"); return; } } catch { Pub.ShowErrorPage("无法连接路局服务器,请检查站段服务器网络连接是否正常!"); } ExamBLL examBLL = new ExamBLL(); RailExam.Model.Exam exam = examBLL.GetExam(int.Parse(strExamId)); HiddenFieldExamTime.Value = DateTime.Now.AddMinutes(exam.ExamTime).ToString(); HfExamTime.Value = (exam.ExamTime * 60).ToString(); FillPage(strId); } }
protected void FillHeading(string strId) { ExamResultBLL examResultBLL = new ExamResultBLL(); PaperBLL kBLL = new PaperBLL(); RailExam.Model.ExamResult examResult = examResultBLL.GetExamResultByOrgID(Convert.ToInt32(strId), Convert.ToInt32(ViewState["OrgID"].ToString())); RailExam.Model.Paper paper = null; EmployeeBLL ebLL = new EmployeeBLL(); RailExam.Model.Employee Employee = ebLL.GetEmployee(examResult.ExamineeId); string strOrgName = Employee.OrgName; string strStationName = ""; string strOrgName1 = ""; int n = strOrgName.IndexOf("-"); if (n != -1) { strStationName = strOrgName.Substring(0, n); strOrgName1 = strOrgName.Substring(n + 1); } else { strStationName = strOrgName; strOrgName1 = ""; } lblOrg.Text = strStationName; lblWorkShop.Text = strOrgName1; lblPost.Text = Employee.PostName; lblName.Text = Employee.EmployeeName; lblTime.Text = examResult.BeginDateTime.ToString("yyyy-MM-dd HH:mm"); lblScore.Text = examResult.Score.ToString(); if (examResult != null) { paper = kBLL.GetPaper(examResult.PaperId); } PaperItemBLL paperItemBLL = new PaperItemBLL(); IList <RailExam.Model.PaperItem> paperItems = paperItemBLL.GetItemsByPaperId(paper.PaperId); int nItemCount = paperItems.Count; decimal nTotalScore = 0; for (int i = 0; i < paperItems.Count; i++) { nTotalScore += paperItems[i].Score; } if (paper != null) { lblTitle.Text = paper.PaperName; lblTitleRight.Text = "总共 " + nItemCount + " 题,共 " + nTotalScore + " 分"; } }
protected void gradesGrid_UpdateCommand(Object s, ComponentArt.Web.UI.GridItemEventArgs e) { RailExam.Model.ExamResult examResult = new RailExam.Model.ExamResult(); examResult.ExamResultId = (int)e.Item["ExamResultId"]; examResult.BeginDateTime = (DateTime)e.Item["BeginDateTime"]; examResult.EndDateTime = (DateTime)e.Item["EndDateTime"]; examResult.Score = (decimal)e.Item["Score"]; examResult.StatusId = int.Parse((string)e.Item["StatusName"]); ExamResultBLL bllExamResult = new ExamResultBLL(); bllExamResult.UpdateExamResult(examResult); gradesGrid.DataSource = GetDataSet(); gradesGrid.DataBind(); }
protected void FillHeading(string strId) { ExamResultBLL examResultBLL = new ExamResultBLL(); PaperBLL kBLL = new PaperBLL(); RailExam.Model.ExamResult examResult = examResultBLL.GetExamResult(int.Parse(strId)); RailExam.Model.Paper paper = null; if (examResult != null) { paper = kBLL.GetPaper(examResult.PaperId); lblExamBeginDateTime.Text = examResult.BeginDateTime.ToString(); lblExamEndDateTime.Text = examResult.EndDateTime.ToString(); lblExamineeName.Text = examResult.ExamineeName; HiddenFieldEmployeeName.Value = lblExamineeName.Text; lblJudgeBeginDateTime.Text = examResult.JudgeBeginDateTime.ToString(); lblJudgeEndDateTime.Text = examResult.JudgeEndDateTime.ToString(); lblJudgerName.Text = examResult.JudgeName; if (examResult.Score <= 0M) { lblScore.Text = examResult.AutoScore.ToString(); ViewState["Score"] = examResult.AutoScore; lblScore.Text += "分"; } else { lblScore.Text = examResult.Score.ToString(); ViewState["Score"] = examResult.Score; lblScore.Text += "分"; } HiddenFieldScore.Value = lblScore.Text; examResultBLL.UpdateJudgeBeginTime(int.Parse(strId), DateTime.Now); } if (paper != null) { this.lblTitle.Text = paper.PaperName; this.lblTitleRight.Text = "总共 " + paper.ItemCount + " 题,共 " + paper.TotalScore + " 分"; } }
protected void FillPaper() { // QueryString id stands for EXAM_RESULT_ID string strId = Request.QueryString.Get("id"); // Not pass id if (string.IsNullOrEmpty(strId)) { return; } PaperItemBLL kBLL = new PaperItemBLL(); PaperSubjectBLL kBSLL = new PaperSubjectBLL(); ExamResultBLL examResultBLL = new ExamResultBLL(); ExamResultAnswerBLL examResultAnswerBLL = new ExamResultAnswerBLL(); RailExam.Model.ExamResult examResult = examResultBLL.GetExamResult(int.Parse(strId)); // Not found if (examResult == null) { return; } IList <PaperSubject> PaperSubjects = kBSLL.GetPaperSubjectByPaperId(examResult.PaperId); PaperSubject paperSubject = null; IList <PaperItem> PaperItems = null; IList <ExamResultAnswer> examResultAnswers = examResultAnswerBLL.GetExamResultAnswers(examResult.ExamResultId); if (PaperSubjects != null) { for (int i = 0; i < PaperSubjects.Count; i++) { paperSubject = PaperSubjects[i]; PaperItems = kBLL.GetItemsByPaperSubjectId(paperSubject.PaperSubjectId); Response.Write("<table width='100%'>"); Response.Write(" <tr > <td class='ExamBigTitle' >"); Response.Write(" " + GetNo(i) + ""); Response.Write(". " + paperSubject.SubjectName + ""); Response.Write(" (共" + paperSubject.ItemCount + "题,共" + paperSubject.TotalScore + "分)</td></tr >"); // 用于前台JS判断是否完成全部试题 hfPaperItemsCount.Value = paperSubject.ItemCount.ToString(); 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 + " (" + paperItem.Score + "分)</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 = "数据错误!"; return; } // 否则组织考生答案 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></td></tr>"); Response.Write(" <tr score='" + paperItem.Score + "'><td class='ExamJudge'>★评分结果:" + GetJudgeInputs(paperItem.PaperItemId, theExamResultAnswer.JudgeStatusId) + " " + "得分<input type='text' id='txtScore" + "-" + paperItem.PaperItemId + "' name='txtScore" + "-" + paperItem.PaperItemId + "' value='" + theExamResultAnswer.JudgeScore.ToString(".00") + "' size='8'></input> " + "评语<input type='text' id='txtMemo" + "-" + paperItem.PaperItemId + "' name='txtMemo" + "-" + paperItem.PaperItemId + "' size='40' value='" + theExamResultAnswer.JudgeRemark + "'></input>" + "</td></tr>"); } } Response.Write(" </table> "); } } }
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); }
private string GetExamOutString(string strId, string orgid) { ExamResultBLL examResultBLL = new ExamResultBLL(); PaperBLL kBLL = new PaperBLL(); 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)); } RailExam.Model.Paper paper = null; EmployeeBLL ebLL = new EmployeeBLL(); RailExam.Model.Employee Employee = ebLL.GetEmployee(examResult.ExamineeId); paper = kBLL.GetPaper(examResult.PaperId); PaperItemBLL paperItemBLL = new PaperItemBLL(); IList <RailExam.Model.PaperItem> paperItems = paperItemBLL.GetItemsByPaperId(paper.PaperId); int nItemCount = paperItems.Count; decimal nTotalScore = 0; for (int i = 0; i < paperItems.Count; i++) { nTotalScore += paperItems[i].Score; } string strOrgName = Employee.OrgName; string strStationName = ""; string strOrgName1 = ""; int n = strOrgName.IndexOf("-"); if (n != -1) { strStationName = strOrgName.Substring(0, n); strOrgName1 = strOrgName.Substring(n + 1); } else { strStationName = strOrgName; strOrgName1 = ""; } string str = "<div style='text-align:center;font-size:18pt;'>" + PrjPub.GetRailName() + "考试试卷</div>"; str += "<div style='text-align:left;font-size:10.5pt;'>考试名称:" + paper.PaperName + " </div>"; str += "<div style='text-align:right;font-size:10.5pt;'>总共" + nItemCount + "题,共 " + nTotalScore + "分</div>"; str += "<div style='text-align:center;'><table width='100%' border='1' cellpadding='0' cellspacing='0' >"; str += "<tr><td width='7%' style='font-size:10.5pt' >单位:</td>"; str += "<td width='26%' style='font-size:10.5pt' align='left' >" + strStationName + "</td>"; str += "<td width='7%' style='font-size:10.5pt' >车间:</td>"; str += "<td width='27%' style='font-size:10.5pt' align='left' >" + strOrgName1 + "</td>"; str += "<td width='7%' style='font-size:10.5pt' >职名:</td>"; str += "<td width='26%' style='font-size:10.5pt' align='left' >" + Employee.PostName + "</td></tr>"; str += "<tr><td width='7%' style='font-size:10.5pt' >姓名:</td>"; str += "<td width='26%' style='font-size:10.5pt' align='left' >" + Employee.EmployeeName + "</td>"; str += "<td width='7%' style='font-size:10.5pt' >时间:</td>"; str += "<td width='27%' style='font-size:10.5pt' align='left' >" + examResult.BeginDateTime.ToString("yyyy-MM-dd HH:mm") + "</td>"; str += "<td width='7%' style='font-size:10.5pt' >成绩:</td>"; str += "<td width='26%' style='font-size:10.5pt' align='left' >" + examResult.Score + "</td></tr></table></div>"; str += "<br>"; str += GetFillExamPaperString(strId, orgid); string strReplace; if (PrjPub.IsServerCenter) { strReplace = "http://" + ConfigurationManager.AppSettings["ServerIP"] + "/RailExamBao/"; } else { strReplace = "http://" + ConfigurationManager.AppSettings["StationIP"] + "/RailExamBao/"; } str = str.Replace("/RailExamBao/", strReplace); return(str); }