err_test_rs.jsp
上传用户:nbluoke
上传日期:2013-08-09
资源大小:4851k
文件大小:12k
源码类别:

教育系统应用

开发平台:

WORD

  1. <%@ page contentType="text/html; charset=gb2312" language="java" %>
  2. <%@ page import="java.sql.*" %>
  3. <%@ page import="jinghua.*"%>
  4. <%@ page import="java.util.*"%>
  5. <%@ page import="java.text.*"%>
  6. <%! boolean debug=true;%>
  7. <jsp:useBean id="DBCon" class="jinghua.JinghuaConn" scope="session">
  8. </jsp:useBean>
  9. <%
  10. //String testID=request.getParameter("testid");
  11. String studentID=request.getParameter("studentid");
  12. String paper=request.getParameter("testresult");
  13. String errorids=request.getParameter("errorids");
  14. if(debug)
  15.     out.print("<br>studentID="+studentID+
  16.         "<br>errorids="+errorids);
  17. //String mn_testID=request.getParameter("mn_testID");
  18. //int valid=Integer.parseInt(request.getParameter("valid"));
  19. //int old=Integer.parseInt(request.getParameter("old"));
  20. //String testID="62";
  21. //String studentID="1";
  22. if(studentID==null){
  23.     Tools.showalert("您还没有登录,或连接超时,请重新登录!",out);
  24.     Tools.showJS("window.open('../login.jsp','_self')",out);
  25. }
  26. if(paper==null|| errorids==null){
  27.     Tools.showalert("没有取得试卷信息,请重试!!",out);
  28.     Tools.goback(out);
  29. }
  30. else{
  31. String [] arrErrorID=errorids.split(",");
  32. ResultSet rs=null;
  33. String sql="";
  34. String title="";
  35. int testnum=0;
  36. StringBuffer sb=new StringBuffer();
  37. Statement stmt=null;
  38. String name="";//考生姓名
  39. int correct=0;
  40. int error=0;
  41. String correctAns="";
  42. String youAns="";
  43. StringBuffer dbmsg=new StringBuffer();
  44. StringBuffer testIDs=new StringBuffer();
  45. StringBuffer Answer=new StringBuffer();
  46. StringBuffer Mark=new StringBuffer();
  47. StringBuffer SubAns=new StringBuffer();
  48. StringBuffer SubMark=new StringBuffer();
  49. StringBuffer TF=new StringBuffer();
  50. StringBuffer Dif=new StringBuffer();
  51. int sub_num=0;
  52. Vector explain=new Vector();
  53. String [] arrMark=null;
  54. String [] arrAnswer=null;
  55. String [] arrSubAns=null;
  56. String [] arrTestID=null;
  57. String [] arrTF=null;
  58. String temp="";
  59. String subid="";//科目ID
  60. String markPercent="";//百分制的分数
  61. float testmark=0.0f;
  62. float totalmark=0.0f;
  63. int testNumber=0;
  64. try{
  65.     Connection con=DBCon.getConnection();
  66.     if(paper!=null){
  67.         //分析试题:试题ID@答案@分数@难易度;     一道试题的格式,以#号结束
  68.         if(debug) out.print("<br>begin:");
  69.         String [] tests=paper.split("#");
  70.         testnum=tests.length;
  71.         if(debug) out.print("<br>paper="+paper+"<br>testnum="+testnum);
  72.         for(int i=0;i<testnum;i++){
  73.             //取回试题号
  74.             String [] test=tests[i].split("@");
  75.             if(debug) {
  76.                 out.print("<BR>tests["+i+"]="+tests[i]);
  77.             }
  78.             testIDs.append(test[0]+",");//题号
  79.             Answer.append(test[1]+",");//答案
  80. Mark.append(test[2]+",");
  81.             Dif.append(test[3]+",");
  82.             testmark+=Float.parseFloat(test[2]);//总分数
  83.         }
  84.         arrMark=Mark.toString().split(",");
  85.         arrAnswer=Answer.toString().split(",");
  86.         arrTestID=testIDs.toString().split(",");
  87.         //根据arrTestID提取考生提交的答案信息,不填写的为"空";
  88.         if(debug){
  89.             out.print("<br>Mark="+Mark.toString());
  90.             out.print("<br>Answer="+Answer.toString());
  91.             out.print("<br>TestID="+testIDs.toString());
  92.             out.print("<br>Mark="+Mark.toString() );
  93.             out.print("<br>Dif="+Dif.toString());
  94.         }
  95.         //取回用户提交的答案
  96.         for(int i=0;i<testnum;i++){
  97.            temp=request.getParameter("radio"+arrTestID[i]);
  98.            if (temp==null){
  99.                SubAns.append("空"+",") ;
  100.                //arrSubAns[i]=new String("@");
  101.            }else{
  102.                SubAns.append(temp+",");
  103.                //arrSubAns[i]=new String(temp);
  104.            }
  105.         }
  106.         if(debug){
  107.             out.print("<br>Mark="+Mark.toString());
  108.             out.print("<br>Answer="+Answer.toString());
  109.             out.print("<br>TestID="+testIDs.toString());
  110.             out.print("<br>SubAns="+SubAns.toString());
  111.         }
  112.         arrSubAns=SubAns.toString().split(",");
  113.         //评分
  114.         correct=0;
  115.         error=0;
  116.         testmark=0;
  117.         totalmark=0.0f;
  118.         for(int i=0;i<testnum;i++)
  119.         {
  120.             jinghua.T_Question.addUsedCount(con,Integer.parseInt(arrTestID[i]));
  121.             totalmark+=Float.parseFloat(arrMark[i]);
  122.             if(arrSubAns[i].equals(arrAnswer[i])){
  123.                 jinghua.T_errorpad.decErrorCount(con,arrErrorID[i]);
  124.                 jinghua.T_Question.addCorrectCount(con,Integer.parseInt(arrTestID[i]));
  125.                 TF.append("T,");
  126.                 SubMark.append(arrMark[i]+",");
  127.                 correct++;
  128.                 if(debug){
  129.                     Tools.debugmsg("<br>arrMark["+i+"]="+arrMark[i],out);
  130.                 }
  131.                 testmark+=Float.parseFloat(arrMark[i]);
  132.             }else {
  133.                 jinghua.T_errorpad.addErrorCount(con,arrErrorID[i]);
  134.                 error++;
  135.                 SubMark.append("0,");
  136.                 if(arrSubAns[i].equals(" "))
  137.                     TF.append("@,");
  138.                 else
  139.                     TF.append("F,");
  140.             }
  141.         }
  142.         if(debug){
  143.             out.print("<br>TF="+TF.toString() );
  144.             out.print("<br>SubMark="+SubMark.toString() );
  145.         }
  146.         arrTF=TF.toString().split(",");
  147.         //考生信息
  148.         sql="select vcUserNo,vcName from UserInfo where vcUserNo="+"'"+studentID+"'";
  149.         stmt=con.createStatement();
  150.         rs=stmt.executeQuery(sql);
  151.         if(rs.next()){
  152.             name=""+rs.getString("vcName");
  153.         }
  154.         rs.close();
  155.         stmt.close();
  156.     //试题记录集
  157.     //sql="select id,questtext,tip,mark from question where id in ("+sql+") order by id";
  158.      }
  159. %>
  160. <html>
  161. <head>
  162. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  163. <title>成绩查询 | 考试成绩 |  | 单项选择题</title>
  164. <link rel="stylesheet" type="text/css" href="../css.css">
  165. </head>
  166. <body>
  167. <center>
  168.   <table border="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2" height="25">
  169.     <tr>
  170.       <td width="100%" height="29" style="border-left-style: solid; border-left-width: 0; border-right-style: solid; border-right-width: 0; border-top-style: solid; border-top-width: 0; border-bottom: 1px solid #000000">
  171.         <img border="0" src="../images/cxcj.gif"></td>
  172.     </tr>
  173.     <tr>
  174.       <p>&nbsp;</p>
  175.     </tr>
  176.   </table>
  177.   <p>&nbsp;</p>
  178. </center>
  179. <div align="center">
  180.   <center>
  181.   <table cellspacing="1" style="border-collapse: collapse" bordercolor="#799AE1" width="469" id="AutoNumber2" border="1">
  182.       <form method="POST" action=""><tr>
  183.       <td width="100%" height="25" bgcolor="#6699CC" background="../student/images/admin_bg_1.gif" bordercolor="#799AE1">
  184.       <p align="center"><b>&nbsp;<font color="#FFFFFF">成绩单</font></b></td>
  185.     </tr>
  186.     <tr>
  187.       <td width="100%" height="160" bgcolor="#FFFDE8" bordercolor="#799AE1">
  188.         <p align="center"> </p>
  189.             <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="202">
  190.               <tr>
  191.                 <td width="8%" height="28"> <p align="right">考生编号:</td>
  192.                 <td height="28" colspan="4"> <%=studentID%></td>
  193.               </tr>
  194.               <tr>
  195.                 <td width="8%" height="29"> <p align="right">姓&nbsp;&nbsp;&nbsp;
  196.                     名:</td>
  197.                 <td height="29" colspan="4"><%=name%>&nbsp;</td>
  198.               </tr>
  199.               <tr>
  200.                 <td width="8%" height="29"> <p align="right">得&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;分:</td>
  201.                 <td width="13%" height="29">卷面分:</td>
  202.                 <td width="23%"><%=testmark%>&nbsp;</td>
  203.                 <td width="15%">百分制:</td>
  204.                 <td width="41%">
  205.                 <% DecimalFormat df=new DecimalFormat("###");
  206.                     String r=df.format(testmark/totalmark*100);
  207.                     out.print(r);
  208.                 %>
  209.             &nbsp;&nbsp;</td>
  210.               </tr>
  211.               <tr>
  212.                 <td width="8%" height="29"> <p align="right">答&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;错:</td>
  213.                 <td height="29" colspan="4"><%=error%>&nbsp;</td>
  214.               </tr>
  215.               <tr>
  216.                 <td width="8%" height="29"> <p align="right">答&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;对:</td>
  217.                 <td height="29" colspan="4"><%=correct%>&nbsp;</td>
  218.               </tr>
  219.               <tr>
  220.                 <td height="29"> <p align="right">正确答案:</p></td>
  221.                 <td height="29" colspan="4"><%=Answer.toString() %>&nbsp;</td>
  222.               </tr>
  223.               <tr>
  224.                 <td height="29"><p align="right">您的答案:</p></td>
  225.                 <td height="29" colspan="4"><%=SubAns.toString()%>&nbsp;</td>
  226.               </tr>
  227.             </table>
  228.         <p align="center"> </p>
  229.       </td>
  230.     </tr>
  231.     <tr>
  232.           <td width="100%" height="25" bgcolor="#FFFFFF" bordercolor="#799AE1"> <p align="center">
  233.               <INPUT class="s02" onclick="window.close()" type=button value=返回 name=close2>
  234.               <span lang="en-us"> </span></td>
  235.  </tr></form>
  236.   </table>
  237.   </center>
  238. </div>
  239. <center><form name="viewdatabase"  ACTION=""  method="post">
  240.   <table border="1" cellspacing="1" style="border-collapse: collapse" bordercolor="#799AE1" width="100%" id="AutoNumber1" height="82">
  241.     <tr class="trh">
  242.       <td width="44" align="center" bgcolor="#799AE1" height="24">
  243.       <font color="#FFFFFF"><b>序号</b></font></td>
  244.         <td align="center" bgcolor="#799AE1" width="592" height="24"> <p align="center"><font color="#FFFFFF">
  245. <b>单项选择题(共<%=testnum%>&nbsp;题,<%=totalmark%>分)</b></font></td>
  246.     </tr>
  247. <% testNumber=0;
  248. while(testNumber<testnum){%>
  249.     <tr class="trh1">
  250.         <td align="center"   height="35" width="44"> 
  251. <center>
  252.             <table width="100%" border="0" cellspacing="0" cellpadding="0">
  253.               <tr>
  254.                 <td> <div align="center">
  255.                     <%out.print(testNumber+1);%>.
  256.                   </div></td>
  257.               </tr>
  258.               <tr>
  259.                 <td><div align="center">(<%=Math.round(Float.parseFloat(arrMark[testNumber]))%>分)</div></td>
  260.               </tr>
  261.             </table>
  262.           </center>&nbsp;</td>
  263.         <td align="left" width="592" height="35"><br>
  264. <%
  265. out.print("正确答案是"+arrAnswer[testNumber]+",&nbsp;&nbsp;");
  266.                         if(arrTF[testNumber].equals("T")){
  267.                             out.print("您的答案是"+arrSubAns[testNumber] +"<br>");
  268.                         }else{
  269.                             out.print("<font color=Red>您的答案是"+arrSubAns[testNumber] +"</font><br>");
  270.                         }
  271.              sql="select id,questtext,tip,mark from question where id="+arrTestID[testNumber];
  272.             stmt=con.createStatement();
  273.             rs=stmt.executeQuery(sql);
  274.             if(rs.next()){
  275.      out.print("原题目:<br>"+rs.getString("questtext"));
  276.      out.print("<br>提示:<br>"+""+rs.getString("tip"));
  277.             }
  278.             rs.close();
  279.             stmt.close();
  280. testNumber++;
  281. %>
  282. </td>
  283.     </tr>
  284. <%}
  285.     %>
  286.     <tr>
  287.       <td align="center" bgcolor="#FFFFFF" height="16" width="640" colspan="2" bordercolor="#FFFFFF">
  288.       <p align="center">
  289.       <INPUT class="s02" onclick="window.close()" type=button value=返回 name=close>
  290.       </p>
  291.       </td>
  292.       </tr>
  293.   </table>
  294. </form>
  295.  </center>
  296.  <center> <form ACTION="" METHOD="GET">
  297.     <table style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0">
  298.       <tr>
  299.         <td width="576">
  300.         <p ALIGN="center">&nbsp;</p>
  301.         <p> </td>
  302.       </tr>
  303.     </table>
  304.   </form>
  305.  </center>
  306. </body>
  307. </html>
  308. <%}
  309. catch (Exception e){
  310.     if(debug){
  311.        Tools.debugmsg("<BR>Exception:"+e.toString() ,out);
  312.     }
  313. }
  314. finally{
  315.     DBCon.dropConnection();
  316. }
  317. }
  318. %>