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

教育系统应用

开发平台:

WORD

  1. <%@ page contentType="text/html; charset=gb2312" language="java" %>
  2. <%@ page import="java.sql.*" %>
  3. <%@ page import="jinghua.*"%>
  4. <%@ page import="java.text.*" %>
  5. <jsp:useBean id="DBCon" class="jinghua.JinghuaConn" scope="session">
  6. </jsp:useBean>
  7. <%! boolean debug=false;
  8. String studentID;
  9. %>
  10. <%
  11. try{
  12.     studentID=(String)session.getAttribute("studentID");
  13.     //Tools.showalert(studentID,out);
  14.     if(studentID==null){
  15.         throw new Exception();
  16.     }
  17. }catch(Exception e){
  18.     Tools.showalert("您还没有登录,或连接超时,请重新登录!",out);
  19.     Tools.showJS("window.open('../login.jsp','_self')",out);
  20. }
  21. //testtype: 1浏览的错题;2浏览列表中选中的错题;3错题本中的所有错题
  22. //testorder:2随机顺序;2从难到易;3从易到难
  23. int testtype=Integer.parseInt(request.getParameter("testtype"));
  24. int testorder=Integer.parseInt(request.getParameter("testorder"));
  25. int testnumber=Integer.parseInt(request.getParameter("testnumber"));
  26. int selectnum=0;
  27. String errorpad_selectID=(String)session.getAttribute("errorpad_selectID");
  28. String errorpad_sqlcon=(String)session.getAttribute("errorpad_sqlcon");
  29. if(debug){
  30.     out.print("<br>testtype="+testtype+
  31.             "<br>testorder="+testorder+
  32.             "<br>errorpad_sqlcon="+errorpad_sqlcon+
  33.             "<br>errorpad_selectid="+errorpad_selectID);
  34. }
  35. ResultSet rs=null;
  36. String sql="";
  37. String sqlcon="";
  38. String sqlorder="";
  39. int testnum=0;
  40. int testmark=0;
  41. PreparedStatement pstmt=null;
  42. Statement stmt=null;
  43. StringBuffer dbmsg=new StringBuffer();
  44. StringBuffer testIDs=new StringBuffer();
  45. StringBuffer errorIDs=new StringBuffer();
  46. //StringBuffer Answer=new StringBuffer();
  47. //StringBuffer Mark=new StringBuffer();
  48. int testNumber=0;
  49. //构造查询条件
  50. //testtype: 1浏览的错题;2浏览列表中选中的错题;3错题本中的所有错题
  51. //testorder:2随机顺序;2从难到易;3从易到难
  52. switch(testtype){
  53.     case 1:
  54.         sqlcon=errorpad_sqlcon;
  55.         break;
  56.     case 2:
  57.         //计算提交的所选择的错题的数量
  58.         if(errorpad_selectID==null|| errorpad_selectID.trim().equals("")){
  59.             Tools.showalert("还没有从错题本中选择错题!",out);
  60.             Tools.goback(out);
  61.         }else{
  62.        // String [] strarr=errorpad_selectID.split(",");
  63.        // if(debug)   out.print("<br>select num="+strarr.length);
  64.        // if(strarr.length<testnumber){
  65.        //     Tools.showalert("您从错题本中选择的题目数量不足!!",out);
  66.        //     Tools.goback(out);
  67.        // }else{
  68.             sqlcon=errorpad_sqlcon+ " AND (errorpad.id IN ("+errorpad_selectID+")) ";
  69.        // }
  70.         }
  71.         break;
  72.     case 3:
  73.         sqlcon="(`errorpad`.`stu_id` = '"+studentID+"')";
  74.         break;
  75.     default:
  76.         break;
  77. }
  78. switch(testorder){
  79.     case 1:
  80.         sqlorder=" ORDER BY RAND()";
  81.         break;
  82.     case 2:
  83.         sqlorder=" ORDER BY errorpad.errorcount DESC,errorpad.add_date DESC";
  84.         break;
  85.     case 3:
  86.         sqlorder=" ORDER BY errorpad.errorcount ASC,errorpad.add_date DESC";
  87.         break;
  88.     default:
  89.         break;
  90. }
  91. sql="SELECT  errorpad.`id` as errorID,  `question`.`ID`,`question`.`PreHard` , `question`.`QuestText`,  "+
  92.     " `question`.`Mark`,  `question`.`Answer`"+
  93.     " FROM  `errorpad`"+
  94.     " LEFT OUTER JOIN `question` ON (`errorpad`.`question_id` = `question`.`ID`) "+
  95.     " WHERE "+sqlcon+sqlorder+" LIMIT "+testnumber;
  96. try{
  97.     Connection con=DBCon.getConnection();
  98.     pstmt=con.prepareStatement(sql);
  99.     rs=pstmt.executeQuery();
  100.     testmark=0;
  101.     testnum=0;
  102.     while(rs.next()){
  103.         testmark+=rs.getInt("Mark");
  104.         testnum++;
  105.         //试题ID@答案@分数@难易度;     一道试题的格式,以#号结束
  106.         testIDs.append(rs.getString("ID")+"@"+rs.getString("Answer")+"@"+rs.getString("Mark")+
  107.             "@"+ rs.getString("PreHard")+"#");
  108.         errorIDs.append(rs.getString("errorID")+",");
  109.     }
  110.     rs.beforeFirst();
  111.     if(debug){
  112.         out.print("<br>query question sql="+sql);
  113.         out.print("<br>testIDs="+testIDs.toString());
  114.     }
  115. %>
  116. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  117. <!-- saved from url=(0041)http://jsptestonline.cosoft.org.cn/senior/none_xt.jsp -->
  118. <HTML><HEAD><TITLE>共创学堂-错题本在线测验</TITLE>
  119. <META http-equiv=Content-Type content="text/html; charset=gb2312">
  120. <LINK
  121. href="../student/style/style.css" type=text/css rel=stylesheet>
  122. <SCRIPT src="../student/js/html.js"></SCRIPT>
  123. <SCRIPT src="../student/js/gnb_menus_layer.js"></SCRIPT>
  124. <SCRIPT src="../student/js/menu.js"></SCRIPT>
  125. <SCRIPT src="../student/js/jumpmenu.js"></SCRIPT>
  126. <SCRIPT src="../student/js/Valid.js"></SCRIPT>
  127. <META content="MSHTML 6.00.2722.900" name=GENERATOR></HEAD>
  128. <BODY text=#000000 bgColor=#ffffff>
  129. <CENTER>
  130.   <form  ACTION="err_test_rs.jsp"  method="post" name="viewdatabase" target="_blank">
  131.     <table width="650" border="0" cellspacing="0" cellpadding="0">
  132.     <tr>
  133.       <td><img src="../student/images/test_pop_01.gif" width="102" height="27"></td>
  134.       <td align="right"><img src="../student/images/test_pop_02.gif" width="134" height="27"></td>
  135.     </tr>
  136.   </table>
  137.   <!--begin test -->
  138.   <table width="650" border="0" cellspacing="0" cellpadding="0">
  139.     <tr>
  140.       <td class="title1" align="center"><font color="#74a8d1" size="+2">
  141.                             <strong><B>
  142.                                 共创学堂-错题本在线测验
  143.                                     </B>
  144.                             </strong>
  145.                         </font></td>
  146.     </tr>
  147.   </table>
  148.   <br>
  149.   <table id=AutoNumber1 style="BORDER-COLLAPSE: collapse"
  150. height=82 cellspacing=1 width="650" border=0 cellpadding="2" bgcolor="#c1c1c1">
  151.     <tbody>
  152.       <tr class=trh>
  153.         <td align=center width=80 bgcolor=#eaeaea><b>序号</b></td>
  154.         <td align=middle bgcolor=#eaeaea> <p align=center><b>共<%=testnum%>题,<%=testmark%>分</b></p></td>
  155.       </tr>
  156.   <%while(rs.next()){%>
  157.       <tr class=trh1 bgcolor="#FFFFFF">
  158.         <td align=middle width=80> 
  159.           <table width="100%" border=0>
  160.             <tbody>
  161.               <tr>
  162.                 <td> <center>
  163.                    <%=(++testNumber)%> </center></td>
  164.               </tr>
  165.               <tr>
  166.                 <td> <center>
  167.                       <%DecimalFormat df=new DecimalFormat("###");
  168.                   String numNF=df.format(rs.getFloat("mark"));
  169.               out.print("("+numNF+"分)");%>
  170.                     </center></td>
  171.               </tr>
  172.             </tbody>
  173.           </table></td>
  174.         <td align=left>
  175. <br>
  176.          <%=jinghua.TransformString.DeleteBR(rs.getString("questtext"))%>
  177.  <br>
  178.  </td>
  179.       </tr>
  180.   <%}
  181.     rs.close();
  182.     pstmt.close();
  183.     %>
  184.     </tbody>
  185.   </table>
  186.   <table cellspacing=0 cellpadding=8 width=650 border=0>
  187.     <tbody>
  188.     <tr>
  189.       <td align=center>
  190.             <!--begin botton-->
  191.             <input class=s02 type=submit value=提交 name=submit1>
  192.         &nbsp;&nbsp;
  193.         <input class=s02 type=reset value=重置 name=submit2>
  194.           <input name="studentid" type="hidden" id="studentid2" value="<%=studentID %>">
  195.           <input name="testresult" type="hidden" id="studentid2" value="<%=testIDs.toString()%>">
  196.           <input name="errorids" type="hidden" id="studentid2" value="<%=errorIDs.toString()%>">
  197.         <!--end button-->
  198.       </td>
  199.     </tr>
  200.     </tbody>
  201.   </table>
  202.   <!--end test -->
  203.   <!--begin bottom -->
  204.   <TABLE
  205. style="BORDER-TOP: #dbdbdb 1px solid; MARGIN-TOP: 10px; MARGIN-BOTTOM: 10px; BACKGROUND-COLOR: #f6f6f6"
  206. cellSpacing=0 cellPadding=0 width="100%" border=0>
  207.   <TBODY>
  208.   <TR>
  209.     <TD align=middle colSpan=2 height=30>
  210.       <TABLE cellSpacing=0 cellPadding=0 width=750 border=0>
  211.         <TBODY>
  212.         <TR>
  213.           <TD><A href="http://jsptestonline.cosoft.org.cn/index.html"
  214.             target=_blank>关于我们</A> | <A
  215.             href="http://jsptestonline.cosoft.org.cn/contact/3_ywhz.html"
  216.             target=_blank>联系方式</A> | 网站地图 | <A
  217.             href="http://jsptestonline.cosoft.org.cn/about/service.html"
  218.             target=_blank>服务条款</A> | <A
  219.             href="http://jsptestonline.cosoft.org.cn/about/privacy.html"
  220.             target=_blank>隐私权保护</A> | <A
  221.             href="http://jsptestonline.cosoft.org.cn/about/copyright.html"
  222.             target=_blank>版权声明</A></TD>
  223.           <TD align=middle width=220>版权所有:<A href="http://jsptestonline.cosoft.org.cn/"
  224.             target=_blank>共创教育机构</A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><!--end bottom --></form></CENTER></BODY></HTML>
  225. <%
  226. }catch(SQLException e){
  227.     out.print("<br>SQL Error:sql="+sql+"<br>"+e.toString());
  228. }catch(Exception e){
  229.     out.print(e.toString() );
  230. }
  231. finally{
  232.     DBCon.dropConnection();
  233. }
  234. %>