protected void btnOk_Click(object sender, EventArgs e) { TestHighManager.JudgingRadio(rdolistS1, r1, lblS1A, btnS1E); TestHighManager.JudgingRadio(rdolistS2, r2, lblS2A, btnS2E); TestHighManager.JudgingRadio(rdolistS3, r3, lblS3A, btnS3E); TestHighManager.JudgingRadio(rdolistS4, r4, lblS4A, btnS4E); TestHighManager.JudgingRadio(rdolistS5, r5, lblS5A, btnS5E); TestHighManager.JudgingJudge(rdolistJ1, j1, lblJ1A, btnJ1E); TestHighManager.JudgingJudge(rdolistJ2, j2, lblJ2A, btnJ2E); TestHighManager.JudgingJudge(rdolistJ3, j3, lblJ3A, btnJ3E); TestHighManager.JudgingJudge(rdolistJ4, j4, lblJ4A, btnJ4E); TestHighManager.JudgingBlank(b1, txtB11, lblB11A, btnB11E); TestHighManager.JudgingBlank(b2, txtB21, lblB21A, btnB21E); TestHighManager.JudgingBlank(b3, txtB21, lblB31A, btnB31E); TestHighManager.JudgingDesign(d1, btnanswer); btnOk.Enabled = false; }
protected void btnOk_Click(object sender, EventArgs e) { btnSuggest.Visible = true; int[] r = new int[5]; //用于存放学习建议 int[] j = new int[4]; int[] b = new int[3]; int[] rr = new int[6]; //用于存放错题的学习建议,有1~5中类型,数字长度选6 //int []jj = new int[6]; //int []bb = new int[6]; btnOk.Enabled = false; btnSave.Enabled = false; correct = TestHighManager.JudgingRadio(rdolistS1, r1, lblS1A, btnS1E); if (correct == false) { r[0] = r1.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), r1.Id, "High", "WrongRadio"); } correct = TestHighManager.JudgingRadio(rdolistS2, r2, lblS2A, btnS2E); if (correct == false) { r[1] = r2.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), r2.Id, "High", "WrongRadio"); } correct = TestHighManager.JudgingRadio(rdolistS3, r3, lblS3A, btnS3E); if (correct == false) { r[2] = r3.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), r3.Id, "High", "WrongRadio"); } correct = TestHighManager.JudgingRadio(rdolistS4, r4, lblS4A, btnS4E); if (correct == false) { r[3] = r4.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), r4.Id, "High", "WrongRadio"); } correct = TestHighManager.JudgingRadio(rdolistS5, r5, lblS5A, btnS5E); if (correct == false) { r[4] = r5.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), r5.Id, "High", "WrongRadio"); } correct = TestHighManager.JudgingJudge(rdolistJ1, j1, lblJ1A, btnJ1E); if (correct == false) { j[0] = j1.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), j1.Id, "High", "WrongJudge"); } correct = TestHighManager.JudgingJudge(rdolistJ2, j2, lblJ2A, btnJ2E); if (correct == false) { j[1] = j2.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), j2.Id, "High", "WrongJudge"); } correct = TestHighManager.JudgingJudge(rdolistJ3, j3, lblJ3A, btnJ3E); if (correct == false) { j[2] = j3.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), j3.Id, "High", "WrongJudge"); } correct = TestHighManager.JudgingJudge(rdolistJ4, j4, lblJ4A, btnJ4E); if (correct == false) { j[3] = j4.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), j4.Id, "High", "WrongJudge"); } correct = TestHighManager.JudgingBlank(b1, txtB11, lblB11A, btnB11E); if (correct == false) { b[0] = b1.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), b1.Id, "High", "WrongBlank"); } correct = TestHighManager.JudgingBlank(b2, txtB21, lblB21A, btnB21E); if (correct == false) { b[1] = b2.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), b2.Id, "High", "WrongBlank"); } correct = TestHighManager.JudgingBlank(b3, txtB21, lblB31A, btnB31E); if (correct == false) { b[2] = b3.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), b3.Id, "High", "WrongBlank"); } correct = TestHighManager.JudgingDesignRadio(rdolistD1S1, rdolistD1S2, d1, lblD1S1A, lblD1S2A); if (correct == false) { WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), d1.Id, "High", "WrongDesign"); } //判断单选错题的学习建议是否重复,同时生成XML文件 System.Xml.XmlTextWriter xmlWriter = new XmlTextWriter(Server.MapPath("./XML/" + Session["stuId"].ToString() + ".xml"), System.Text.Encoding.UTF8); xmlWriter.Formatting = Formatting.Indented; xmlWriter.WriteStartDocument(); xmlWriter.WriteStartElement("学习建议"); for (int i = 0; i <= 4; i++) { if (r[i] != 0) { rr[r[i]] = r[i]; //如果r[i]不为0,表明为错题,就把建议编号放到相应的rr数组中 } } //判断判断错题的学习建议是否重复 for (int i = 0; i <= 3; i++) { if (j[i] != 0) { rr[j[i]] = j[i]; //如果j[i]不为0,表明为错题,就把建议编号放到相应的rr数组中 } } //判断填空错题的学习建议是否重复 for (int i = 0; i <= 2; i++) { if (b[i] != 0) { rr[b[i]] = b[i]; //如果b[i]不为0,表明为错题,就把建议编号放到相应的rr数组中 } } for (int i = 0; i <= 5; i++) { if (rr[i] != 0) { //Msg = Msg + rr[i].ToString() + ","; //写入XML文件 xmlWriter.WriteStartElement("错题"); xmlWriter.WriteAttributeString("类型", rr[i].ToString()); xmlWriter.WriteEndElement(); } } //写文档结束,调用WriteEndDocument方法 xmlWriter.WriteEndDocument(); //关闭textWriter xmlWriter.Close(); string stuId = Session["stuId"].ToString(); bool scoreJudge = TestHighManager.Score(TestHighManager.radioScore(r1, r2, r3, r4, r5, rdolistS1, rdolistS2, rdolistS3, rdolistS4, rdolistS5), TestHighManager.judgeScore(j1, j2, j3, j4, rdolistJ1, rdolistJ2, rdolistJ3, rdolistJ4), TestHighManager.blankScore(b1, b2, b3, txtB11, txtB21, txtB31), TestHighManager.designScore(d1, rdolistD1S1, rdolistD1S2)); if (scoreJudge == true) { //实现设计题上传 Boolean fileOK = false; // 指定路径 String path = Server.MapPath("~/"); // 文件上传控件中如果已经包含文件 if (FUDesignHigh.HasFile) { // 得到文件的后缀 String fileExtension = System.IO.Path.GetExtension(FUDesignHigh.FileName).ToLower(); // 允许的文件后缀 String[] allowedExtensions = { ".cs" }; // 看包含的文件是否是被允许的文件后缀 for (int i = 0; i < allowedExtensions.Length; i++) { if (fileExtension == allowedExtensions[i]) { // 如果是,标志位置为真 fileOK = true; } } } if (fileOK) { try { // 文件另存在服务器指定目录下 FUDesignHigh.PostedFile.SaveAs(Server.MapPath("./DesignWorks/high/") + FUDesignHigh.FileName); lbText.Text = "文件上传成功!"; path = "~/DesignWorks/high/" + FUDesignHigh.FileName; } catch (Exception ex) { lbText.Text = "文件上传失败!"; } } else { lbText.Text = "注意:只能上传*.cs文件,并以“学号.cs”命名!"; } //将上传地址写入数据库 DateTime createTime = DateTime.Now; string fileName = FUDesignHigh.FileName; int n = TestHighManager.AddDesignUpload(stuId, learningLevel, createTime, path, fileName); } //将分数写入ClassUnit表中 TestHighManager.UpdateStudyingScore(stuId, learningLevel, TestHighManager.radioScore(r1, r2, r3, r4, r5, rdolistS1, rdolistS2, rdolistS3, rdolistS4, rdolistS5) + TestHighManager.judgeScore(j1, j2, j3, j4, rdolistJ1, rdolistJ2, rdolistJ3, rdolistJ4) + TestHighManager.blankScore(b1, b2, b3, txtB11, txtB21, txtB31) + TestHighManager.designScore(d1, rdolistD1S1, rdolistD1S2)); string str = null; str = TestHighManager.ShowScoreString(TestHighManager.radioScore(r1, r2, r3, r4, r5, rdolistS1, rdolistS2, rdolistS3, rdolistS4, rdolistS5), TestHighManager.judgeScore(j1, j2, j3, j4, rdolistJ1, rdolistJ2, rdolistJ3, rdolistJ4), TestHighManager.blankScore(b1, b2, b3, txtB11, txtB21, txtB31), TestHighManager.designScore(d1, rdolistD1S1, rdolistD1S2), scoreJudge); //Response.Write(string.Format("<script type = 'text/javascript'> alert('{0}'); </script>", str)); RegisterClientScriptBlock("", string.Format("<script type = 'text/javascript'> alert('{0}'); </script>", str)); }