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

教育系统应用

开发平台:

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