protected void btnOk_Click(object sender, EventArgs e) { TestMidManager.JudgingRadio(rdolistS1, r1, lblS1A, btnS1E); TestMidManager.JudgingRadio(rdolistS2, r2, lblS2A, btnS2E); TestMidManager.JudgingRadio(rdolistS3, r3, lblS3A, btnS3E); TestMidManager.JudgingRadio(rdolistS4, r4, lblS4A, btnS4E); TestMidManager.JudgingRadio(rdolistS5, r5, lblS5A, btnS5E); TestMidManager.JudgingJudge(rdolistJ1, j1, lblJ1A, btnJ1E); TestMidManager.JudgingJudge(rdolistJ2, j2, lblJ2A, btnJ2E); TestMidManager.JudgingJudge(rdolistJ3, j3, lblJ3A, btnJ3E); TestMidManager.JudgingJudge(rdolistJ4, j4, lblJ4A, btnJ4E); TestMidManager.JudgingBlank(b1, txtB11, lblB11A, btnB11E); TestMidManager.JudgingBlank(b2, txtB21, lblB21A, btnB21E); TestMidManager.JudgingBlank(b3, txtB21, lblB31A, btnB31E); TestMidManager.JudgingDesign(d1, btnanswer); btnOk.Enabled = false; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["stuId"] != null) { //随机出题 long tick = DateTime.Now.Ticks; Random ran = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32)); int iDown = 1; int iUp = TestMidManager.CountRadio(); int[] n = new int[5]; while (true) { int i = 0; n[0] = ran.Next(iDown, iUp); n[1] = ran.Next(iDown, iUp); n[2] = ran.Next(iDown, iUp); n[3] = ran.Next(iDown, iUp); n[4] = ran.Next(iDown, iUp); if (n[0] != n[1] && n[0] != n[2] && n[0] != n[3] && n[0] != n[4] && n[1] != n[2] && n[1] != n[3] && n[1] != n[4] && n[2] != n[3] && n[2] != n[4] && n[3] != n[4]) { i = 4; } if (i == 4) { break; } } r1 = TestMidManager.GetRadio(n[0]); TestMidManager.ShowQuestionRadio(r1, rdolistS1, lblS1); r2 = TestMidManager.GetRadio(n[1]); TestMidManager.ShowQuestionRadio(r2, rdolistS2, lblS2); r3 = TestMidManager.GetRadio(n[2]); TestMidManager.ShowQuestionRadio(r3, rdolistS3, lblS3); r4 = TestMidManager.GetRadio(n[3]); TestMidManager.ShowQuestionRadio(r4, rdolistS4, lblS4); r5 = TestMidManager.GetRadio(n[4]); TestMidManager.ShowQuestionRadio(r5, rdolistS5, lblS5); //随机出题 int iUp1 = TestMidManager.CountJudge(); int[] j = new int[4]; while (true) { int i = 0; j[0] = ran.Next(iDown, iUp1); j[1] = ran.Next(iDown, iUp1); j[2] = ran.Next(iDown, iUp1); j[3] = ran.Next(iDown, iUp1); if (j[0] != j[1] && j[0] != j[2] && j[0] != j[3] && j[1] != j[2] && j[1] != j[3] && j[2] != j[3]) { i = 3; } if (i == 3) { break; } } j1 = TestMidManager.GetJudge(j[0]); TestMidManager.ShowQuestionJudge(j1, rdolistJ1, lblJ1); j2 = TestMidManager.GetJudge(j[1]); TestMidManager.ShowQuestionJudge(j2, rdolistJ2, lblJ2); j3 = TestMidManager.GetJudge(j[2]); TestMidManager.ShowQuestionJudge(j3, rdolistJ3, lblJ3); j4 = TestMidManager.GetJudge(j[3]); TestMidManager.ShowQuestionJudge(j4, rdolistJ4, lblJ4); //随机出题 int iUp2 = TestMidManager.CountBlank(); int[] k = new int[3]; while (true) { int i = 0; k[0] = ran.Next(iDown, iUp2); k[1] = ran.Next(iDown, iUp2); k[2] = ran.Next(iDown, iUp2); if (k[0] != k[1] && k[0] != k[2] && k[1] != k[2]) { i = 2; } if (i == 2) { break; } } b1 = TestMidManager.GetBlank(k[0]); TestMidManager.ShowQuestionBlank(b1, lblB1, lblB12); b2 = TestMidManager.GetBlank(k[1]); TestMidManager.ShowQuestionBlank(b2, lblB2, lblB22); b3 = TestMidManager.GetBlank(k[2]); TestMidManager.ShowQuestionBlank(b3, lblB3, lblB32); //随机出题 int iUp3 = TestMidManager.CountDesign(); int[] m = new int[2]; m[0] = ran.Next(iDown, iUp3); d1 = TestMidManager.GetDesign(m[0]); TestMidManager.ShowQuestionDesign2(d1, lblD1); } else { Response.Redirect("Login.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) //防止点保存后,页面再一次刷新,和验证码一样 { if (Session["stuId"] != null) { int score1 = 0; int score2 = 0; int score3 = 0; string stuId = Session["stuId"].ToString(); stuNews1 = ClassUnitManager.GetStudyingInform(stuId); score1 = stuNews1.pretest; score2 = stuNews1.low; score3 = stuNews1.mid; if (int.Parse(Request.QueryString["caid"].ToString().Trim()) == 1) //不是第一次做题,读取断点 { BreakingPointRadio bpr = new BreakingPointRadio(); bpr = BreakingPointManager.LoadBreakingPointRadio(Session["stuId"].ToString()); r1 = TestMidManager.GetRadio(bpr.r1); TestMidManager.ShowQuestionRadio(r1, rdolistS1, lblS1); r2 = TestMidManager.GetRadio(bpr.r2); TestMidManager.ShowQuestionRadio(r2, rdolistS2, lblS2); r3 = TestMidManager.GetRadio(bpr.r3); TestMidManager.ShowQuestionRadio(r3, rdolistS3, lblS3); r4 = TestMidManager.GetRadio(bpr.r4); TestMidManager.ShowQuestionRadio(r4, rdolistS4, lblS4); r5 = TestMidManager.GetRadio(bpr.r5); TestMidManager.ShowQuestionRadio(r5, rdolistS5, lblS5); BreakingPointJudge bpj = new BreakingPointJudge(); bpj = BreakingPointManager.LoadBreakingPointJudge(Session["stuId"].ToString()); j1 = TestMidManager.GetJudge(bpj.j1); TestMidManager.ShowQuestionJudge(j1, rdolistJ1, lblJ1); j2 = TestMidManager.GetJudge(bpj.j2); TestMidManager.ShowQuestionJudge(j2, rdolistJ2, lblJ2); j3 = TestMidManager.GetJudge(bpj.j3); TestMidManager.ShowQuestionJudge(j3, rdolistJ3, lblJ3); j4 = TestMidManager.GetJudge(bpj.j4); TestMidManager.ShowQuestionJudge(j4, rdolistJ4, lblJ4); BreakingPointBlank bpb = new BreakingPointBlank(); bpb = BreakingPointManager.LoadBreakingPointBlank(Session["stuId"].ToString()); b1 = TestMidManager.GetBlank(bpb.b1); TestMidManager.ShowQuestionBlank(b1, lblB1, lblB12); b2 = TestMidManager.GetBlank(bpb.b2); TestMidManager.ShowQuestionBlank(b2, lblB2, lblB22); b3 = TestMidManager.GetBlank(bpb.b3); TestMidManager.ShowQuestionBlank(b3, lblB3, lblB32); BreakingPointDesign bpd = new BreakingPointDesign(); bpd = BreakingPointManager.LoadBreakingPointDesign(Session["stuId"].ToString()); d1 = TestMidManager.GetDesign(bpd.d1); TestMidManager.ShowQuestionDesign(d1, lblD1, lblD1S1, lblD1S2, rdolistD1S1, rdolistD1S2); TestMidManager.ShowRadioBreakingpoint(bpr, rdolistS1, rdolistS2, rdolistS3, rdolistS4, rdolistS5); TestMidManager.ShowJudgeBreakingpoint(bpj, rdolistJ1, rdolistJ2, rdolistJ3, rdolistJ4); TestMidManager.ShowBlankBreakingpoint(bpb, txtB11, txtB21, txtB31); } else if (int.Parse(Request.QueryString["caid"].ToString().Trim()) == 0) { if (score1 >= 75 || score2 >= 60) { //随机出题(加入错题的权重,原先的题号不变,多余的错题作为普通题目放到最后进行随机) long tick = DateTime.Now.Ticks; Random ran = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32)); int iDown = 1; int iUp = TestMidManager.CountRadio(); int[] rr = new int[iUp + 1]; for (int mn = 1; mn <= TestMidManager.CountRadio(); mn++) { rr[mn] = WrongRadioManager.WrongRadionum(Session["stuId"].ToString(), mn, "Mid", "WrongRadio"); iUp = iUp + rr[mn]; } int[] n = new int[5]; while (true) { int i; n[0] = ran.Next(iDown, iUp); n[1] = ran.Next(iDown, iUp); n[2] = ran.Next(iDown, iUp); n[3] = ran.Next(iDown, iUp); n[4] = ran.Next(iDown, iUp); //对随机选出的5个数重映射题号 for (i = 0; i <= 4; i++) { if (n[i] > TestMidManager.CountRadio()) { int temp; temp = n[i] - TestMidManager.CountRadio(); int p; for (p = 1; p <= TestMidManager.CountRadio(); p++) { temp = temp - rr[p]; if (temp <= 0) { break; } } n[i] = p; } } if (n[0] != n[1] && n[0] != n[2] && n[0] != n[3] && n[0] != n[4] && n[1] != n[2] && n[1] != n[3] && n[1] != n[4] && n[2] != n[3] && n[2] != n[4] && n[3] != n[4]) { i = 4; } if (i == 4) { break; } } r1 = TestMidManager.GetRadio(n[0]); TestMidManager.ShowQuestionRadio(r1, rdolistS1, lblS1); r2 = TestMidManager.GetRadio(n[1]); TestMidManager.ShowQuestionRadio(r2, rdolistS2, lblS2); r3 = TestMidManager.GetRadio(n[2]); TestMidManager.ShowQuestionRadio(r3, rdolistS3, lblS3); r4 = TestMidManager.GetRadio(n[3]); TestMidManager.ShowQuestionRadio(r4, rdolistS4, lblS4); r5 = TestMidManager.GetRadio(n[4]); TestMidManager.ShowQuestionRadio(r5, rdolistS5, lblS5); //随机出题 int iUp1 = TestMidManager.CountJudge(); int[] jj = new int[iUp1 + 1]; for (int mn = 1; mn <= TestHighManager.CountJudge(); mn++) { jj[mn] = WrongRadioManager.WrongRadionum(Session["stuId"].ToString(), mn, "Mid", "WrongJudge"); iUp1 = iUp1 + jj[mn]; } int[] j = new int[4]; while (true) { int i; j[0] = ran.Next(iDown, iUp1); j[1] = ran.Next(iDown, iUp1); j[2] = ran.Next(iDown, iUp1); j[3] = ran.Next(iDown, iUp1); //对随机选出的4个数重映射题号 for (i = 0; i <= 3; i++) { if (j[i] > TestMidManager.CountJudge()) { int temp; temp = j[i] - TestMidManager.CountJudge(); int p; for (p = 1; p <= TestMidManager.CountJudge(); p++) { temp = temp - jj[p]; if (temp <= 0) { break; } } j[i] = p; } } if (j[0] != j[1] && j[0] != j[2] && j[0] != j[3] && j[1] != j[2] && j[1] != j[3] && j[2] != j[3]) { i = 3; } if (i == 3) { break; } } j1 = TestMidManager.GetJudge(j[0]); TestMidManager.ShowQuestionJudge(j1, rdolistJ1, lblJ1); j2 = TestMidManager.GetJudge(j[1]); TestMidManager.ShowQuestionJudge(j2, rdolistJ2, lblJ2); j3 = TestMidManager.GetJudge(j[2]); TestMidManager.ShowQuestionJudge(j3, rdolistJ3, lblJ3); j4 = TestMidManager.GetJudge(j[3]); TestMidManager.ShowQuestionJudge(j4, rdolistJ4, lblJ4); //随机出题 int iUp2 = TestMidManager.CountBlank(); int[] kk = new int[iUp2 + 1]; for (int mn = 1; mn <= TestMidManager.CountBlank(); mn++) { kk[mn] = WrongRadioManager.WrongRadionum(Session["stuId"].ToString(), mn, "Mid", "WrongBlank"); iUp2 = iUp2 + kk[mn]; } int[] k = new int[3]; while (true) { int i; k[0] = ran.Next(iDown, iUp2); k[1] = ran.Next(iDown, iUp2); k[2] = ran.Next(iDown, iUp2); //对随机选出的3个数重映射题号 for (i = 0; i <= 2; i++) { if (k[i] > TestMidManager.CountBlank()) { int temp; temp = k[i] - TestMidManager.CountBlank(); int p; for (p = 1; p <= TestMidManager.CountBlank(); p++) { temp = temp - kk[p]; if (temp <= 0) { break; } } k[i] = p; } } if (k[0] != k[1] && k[0] != k[2] && k[1] != k[2]) { i = 2; } if (i == 2) { break; } } b1 = TestMidManager.GetBlank(k[0]); TestMidManager.ShowQuestionBlank(b1, lblB1, lblB12); b2 = TestMidManager.GetBlank(k[1]); TestMidManager.ShowQuestionBlank(b2, lblB2, lblB22); b3 = TestMidManager.GetBlank(k[2]); TestMidManager.ShowQuestionBlank(b3, lblB3, lblB32); //随机出题 int iUp3 = TestMidManager.CountDesign(); int[] m = new int[2]; m[0] = ran.Next(iDown, iUp3); d1 = TestMidManager.GetDesign(m[0]); TestMidManager.ShowQuestionDesign(d1, lblD1, lblD1S1, lblD1S2, rdolistD1S1, rdolistD1S2); } else { lblTitle.Visible = false; PanelAll.Visible = false; PanelDesign.Visible = false; btnSubmit.Visible = false; btnOk.Visible = false; btnSave.Visible = false; //Response.Write("<script type = 'text/javascript'> alert('你未通过低等级测试,不能进行该等级测试!'); </script>"); RegisterClientScriptBlock("", "<script>alert('你未通过前测或低等级测试,不能进行中级测试!')</script>"); } } } else { Response.Redirect("Login.aspx"); } } }
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; string stuId = Session["stuId"].ToString(); if (correct == false) { r[0] = r1.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), r1.Id, "Mid", "WrongRadio"); } correct = TestMidManager.JudgingRadio(rdolistS2, r2, lblS2A, btnS2E); if (correct == false) { r[1] = r2.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), r2.Id, "Mid", "WrongRadio"); } correct = TestMidManager.JudgingRadio(rdolistS3, r3, lblS3A, btnS3E); if (correct == false) { r[2] = r3.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), r3.Id, "Mid", "WrongRadio"); } correct = TestMidManager.JudgingRadio(rdolistS4, r4, lblS4A, btnS4E); if (correct == false) { r[3] = r4.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), r4.Id, "Mid", "WrongRadio"); } correct = TestMidManager.JudgingRadio(rdolistS5, r5, lblS5A, btnS5E); if (correct == false) { r[4] = r5.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), r5.Id, "Mid", "WrongRadio"); } correct = TestMidManager.JudgingJudge(rdolistJ1, j1, lblJ1A, btnJ1E); if (correct == false) { j[0] = j1.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), j1.Id, "Mid", "WrongJudge"); } correct = TestMidManager.JudgingJudge(rdolistJ2, j2, lblJ2A, btnJ2E); if (correct == false) { j[1] = j2.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), j2.Id, "Mid", "WrongJudge"); } correct = TestMidManager.JudgingJudge(rdolistJ3, j3, lblJ3A, btnJ3E); if (correct == false) { j[2] = j3.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), j3.Id, "Mid", "WrongJudge"); } correct = TestMidManager.JudgingJudge(rdolistJ4, j4, lblJ4A, btnJ4E); if (correct == false) { j[3] = j4.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), j4.Id, "Mid", "WrongJudge"); } correct = TestMidManager.JudgingBlank(b1, txtB11, lblB11A, btnB11E); if (correct == false) { b[0] = b1.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), b1.Id, "Mid", "WrongBlank"); } correct = TestMidManager.JudgingBlank(b2, txtB21, lblB21A, btnB21E); if (correct == false) { b[1] = b2.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), b2.Id, "Mid", "WrongBlank"); } correct = TestMidManager.JudgingBlank(b3, txtB21, lblB31A, btnB31E); if (correct == false) { b[2] = b3.suggestion; WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), b3.Id, "Mid", "WrongBlank"); } correct = TestMidManager.JudgingDesignRadio(rdolistD1S1, rdolistD1S2, d1, lblD1S1A, lblD1S2A); if (correct == false) { WrongRadioManager.addRadioToWrongTotal(Session["stuId"].ToString(), d1.Id, "Mid", "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,表明为错题,就把建议编号放到相应的jj数组中 } } //判断填空错题的学习建议是否重复 for (int i = 0; i <= 2; i++) { if (b[i] != 0) { rr[b[i]] = b[i]; //如果b[i]不为0,表明为错题,就把建议编号放到相应的bb数组中 } } for (int i = 0; i <= 5; i++) { if (rr[i] != 0) { //写入XML文件 xmlWriter.WriteStartElement("错题"); xmlWriter.WriteAttributeString("类型", rr[i].ToString()); xmlWriter.WriteEndElement(); } } //写文档结束,调用WriteEndDocument方法 xmlWriter.WriteEndDocument(); //关闭textWriter xmlWriter.Close(); bool scoreJudge = TestMidManager.Score(TestMidManager.radioScore(r1, r2, r3, r4, r5, rdolistS1, rdolistS2, rdolistS3, rdolistS4, rdolistS5), TestMidManager.judgeScore(j1, j2, j3, j4, rdolistJ1, rdolistJ2, rdolistJ3, rdolistJ4), TestMidManager.blankScore(b1, b2, b3, txtB11, txtB21, txtB31), TestMidManager.designScore(d1, rdolistD1S1, rdolistD1S2)); if (scoreJudge == true) { //实现设计题上传 Boolean fileOK = false; // 指定路径 String path = Server.MapPath("~/"); // 文件上传控件中如果已经包含文件 if (FUDesignMid.HasFile) { // 得到文件的后缀 String fileExtension = System.IO.Path.GetExtension(FUDesignMid.FileName).ToLower(); // 允许的文件后缀 String[] allowedExtensions = { ".cs" }; // 看包含的文件是否是被允许的文件后缀 for (int i = 0; i < allowedExtensions.Length; i++) { if (fileExtension == allowedExtensions[i]) { // 如果是,标志位置为真 fileOK = true; } } } if (fileOK) { try { // 文件另存在服务器指定目录下 FUDesignMid.PostedFile.SaveAs(Server.MapPath("./DesignWorks/mid/") + FUDesignMid.FileName); lbText.Text = "文件上传成功!"; path = "~/DesignWorks/mid/" + FUDesignMid.FileName; } catch (Exception ex) { lbText.Text = "文件上传失败!"; } } else { lbText.Text = "注意:只能上传*.cs文件!"; } //将上传地址写入数据库 DateTime createTime = DateTime.Now; string fileName = FUDesignMid.FileName; int n = TestMidManager.AddDesignUpload(stuId, learningLevel, createTime, path, fileName); } //将分数写入ClassUnit表中 TestMidManager.UpdateStudyingScore(stuId, learningLevel, TestMidManager.radioScore(r1, r2, r3, r4, r5, rdolistS1, rdolistS2, rdolistS3, rdolistS4, rdolistS5) + TestMidManager.judgeScore(j1, j2, j3, j4, rdolistJ1, rdolistJ2, rdolistJ3, rdolistJ4) + TestMidManager.blankScore(b1, b2, b3, txtB11, txtB21, txtB31) + TestMidManager.designScore(d1, rdolistD1S1, rdolistD1S2)); string str = null; str = TestMidManager.ShowScoreString(TestMidManager.radioScore(r1, r2, r3, r4, r5, rdolistS1, rdolistS2, rdolistS3, rdolistS4, rdolistS5), TestMidManager.judgeScore(j1, j2, j3, j4, rdolistJ1, rdolistJ2, rdolistJ3, rdolistJ4), TestMidManager.blankScore(b1, b2, b3, txtB11, txtB21, txtB31), TestMidManager.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)); }