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

教育系统应用

开发平台:

WORD

  1. <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" %>
  2. <%@ page import="java.sql.*"%>
  3. <%@ page import="jinghua.*"%>
  4. <%@ page import="java.util.*"%>
  5. <%@ page import = "java.io.PrintWriter" %>
  6. <%@ page import = "jinghua.chart.servlet.WebHitChart" %>
  7. <%@ page import = "jinghua.chart.servlet.WebHitDataSet" %>
  8. <jsp:useBean id="DBCon" class="jinghua.JinghuaConn" scope="session">
  9. </jsp:useBean>
  10. <%!Connection con;
  11. boolean debug=true;
  12. class Test{
  13.     String id;
  14.     String name;
  15.     String grade;
  16.     String time;
  17.     String totalMark;
  18.     String testclass;
  19. int testnum;
  20.     public String toString(){
  21.         String temp="";
  22.         temp="<br> id="+id+"<br> name="+name;
  23.         return temp;
  24.    }
  25. };
  26. Statement stmt=null;
  27. ResultSet rs=null;
  28. String sql="";
  29. %>
  30. <%
  31. String [] question=null;
  32. ArrayList testSet=new ArrayList();
  33. String testname=null;
  34. String paper=null;
  35. String testIDs=null;
  36. Test test=new Test();
  37. StringBuffer sb=null;
  38. try{
  39.     con=DBCon.getConnection();
  40. test.id=request.getParameter("testID");
  41. if(test.id==null)
  42. throw new Exception("页面缺少调用参数!");
  43. sql="SELECT  `test`.`paper`,`test`.`testnum`,  `test`.`title`,  `test`.`date`,  `test`.`mark`"+
  44. "  FROM  `test` WHERE  (`test`.`id` = "+test.id+")";
  45.     stmt=con.createStatement();
  46.     rs=stmt.executeQuery(sql);
  47.     if(rs.next()){
  48.         test.name=rs.getString("title");
  49. test.time=rs.getString("date");
  50. test.totalMark=String.valueOf(rs.getFloat("mark"));
  51.         paper=rs.getString("paper");
  52. test.testclass="单元测试";
  53. test.testnum=rs.getInt("testnum");
  54.     }
  55.     rs.close();
  56.     stmt.close();
  57. if(paper==null)
  58.      throw new Exception("没有查询到试卷内容!");
  59. if(paper.equals(""))
  60.      throw new Exception("没有查询到试卷内容!");
  61.  question=paper.split("#");
  62.      sb=new StringBuffer();
  63.      //585@A@5@A#586@B@6@B#587@C@7@C#588@D@8@E#
  64.     for(int j=0;j<question.length;j++){
  65.         sb.append(question[j].substring(0,question[j].indexOf("@"))+",");
  66.     }
  67.     paper=sb.toString().substring(0,sb.toString().length()-1);
  68. sql="select ID,QuestText,Tip,Mark,Answer from question "+
  69. " where id in ("+paper+") order by id";
  70.     if(debug) out.println("<br>test paper="+paper+
  71. "<br>test sql="+sql);
  72. //试题记录集
  73.     stmt=con.createStatement();
  74.     rs=stmt.executeQuery(sql);
  75. %>
  76. <script language="JavaScript">
  77. function gotestpaper(){
  78. document.myform.method = "POST";
  79.     document.myform.action = "modify_test.jsp";
  80.     document.myform.target="_self";
  81.     document.myform.submit();
  82. }
  83. function del_check()
  84. {
  85. var count = myform.elements.length;
  86. var noSelect = true;
  87.   for(var i=0;i<count;i++)
  88.   {
  89.      if(myform.elements[i].checked)
  90.      {
  91.              noSelect = false;
  92.       break;
  93. }
  94.    }
  95. if(noSelect == true)
  96. {
  97.     alert("您还没有选择要删除的试题");
  98.     return(false);
  99.  }
  100.    else
  101.    {
  102.          if(confirm("将删除所有选择的试题吗?"))
  103.          {
  104.                 document.myform.method = "POST";
  105.                 document.myform.action = "unit_test_quest_del.jsp";
  106.                 document.myform.target="_self";
  107.                 document.myform.submit();
  108.          }
  109.          else
  110.          {
  111.                 document.myform.method = "GET";
  112.                 document.myform.action = "";
  113. }
  114.      }
  115.      return false;
  116. }
  117. function add_check()
  118. {
  119. document.myform.method = "POST";
  120.     document.myform.action = "unit_test_quest_add.jsp";
  121.     document.myform.target="_self";
  122.     document.myform.submit();
  123.         
  124.     return false;
  125. }
  126. function deactive_check()
  127. {
  128. var count = myform.elements.length;
  129. var noSelect = true;
  130.   for(var i=0;i<count;i++)
  131.   {
  132.      if(myform.elements[i].checked)
  133.      {
  134.              noSelect = false;
  135.       break;
  136. }
  137.    }
  138. if(noSelect == true)
  139. {
  140.     alert("您还没有选择要注销的试卷!");
  141.     return(false);
  142.  }
  143.    else
  144.    {
  145.          if(confirm("注销所有选择的试卷吗?"))
  146.          {
  147.                 document.myform.method = "POST";
  148.                 document.myform.action = "test_deactivde.jsp";
  149.                 document.myform.target="_self";
  150.                 document.myform.submit();
  151.          }
  152.          else
  153.          {
  154.                 document.myform.method = "GET";
  155.                 document.myform.action = "";
  156. }
  157.          }
  158.          return false;
  159. }
  160. function subform(stract)
  161. {
  162. switch (stract){
  163. case "del":
  164.             del_check();
  165. break;
  166. case "add":
  167.             add_check();
  168. break;
  169. case "deactive":
  170. deactive_check();
  171. break;
  172. }
  173. }
  174. </script>
  175. <HTML>
  176. <HEAD>
  177. <META http-equiv=Content-Type content="text/html; charset=gb2312">
  178. <TITLE>共创学堂-模拟考试成绩查询</TITLE>
  179. <SCRIPT language=JavaScript>
  180. <!--
  181. function SymError()
  182. {
  183.   return true;
  184. }
  185. window.onerror = SymError;
  186. //-->
  187. </SCRIPT>
  188. <!-- saved from url=(0041)http://jsptestonline.cosoft.org.cn/senior/none_xt.jsp -->
  189. <META http-equiv=Content-Type content="text/html; charset=gb2312"><LINK
  190. href="../errorpad/style/style.css" type=text/css rel=stylesheet>
  191. <META content="MSHTML 6.00.2462.0" name=GENERATOR>
  192. <link rel="stylesheet" type="text/css" href="../css.css">
  193. </HEAD>
  194. <BODY bgColor=#ffffff text=#000000 onLoad="InitMyform()">
  195. <CENTER>
  196. <TABLE cellSpacing=0 cellPadding=0 width=650 border=0>
  197.   <TBODY>
  198.   <TR>
  199.           <TD><IMG height=27 src="../errorpad/images/test_pop_01.gif" width=102></TD>
  200.           <TD align=right><IMG height=27 src="../errorpad/images/test_pop_02.gif"
  201.       width=134></TD>
  202.         </TR></TBODY></TABLE>
  203.   <strong><font color="#3366FF" size="+2" face="黑体">单元测试试卷修改</font></strong>
  204.   <!--begin test -->
  205.   <FORM action=Query_unit_test_mark.jsp method=post name=myform target="_self" id="myform" onSubmit="return CheckForm(this)">
  206.     <TABLE width=100% height="60" border=0 cellPadding=0 cellSpacing=0>
  207.       <TBODY>
  208.         <TR>
  209.           <TD height="75"  align=middle> <table width="600" height="62" border="1" align="center" cellspacing="1" bordercolor="#799AE1" id="AutoNumber3" style="border-collapse: collapse">
  210.               <tr> 
  211.                 <td height="58" nowrap background="../images/admin_bg_1.gif" bgcolor="#FFFDE8"><b><font color="#FFFFFF"> 
  212.                   </font></b> 
  213.                   <div align="center">
  214. <table width="100%" border="0">
  215.                       <tr> 
  216.                         <td width="35%">&nbsp;</td>
  217.                         <td width="16%"><input name="errDel" type="button" class="s03" id="errDel" value="删 除" border="0" onClick=subform("del")></td>
  218.                         <td width="15%"><input name="errAscRate" type="button" class="s03" id="errAscRate2" value="添 加" border="0" onClick=subform("add")></td>
  219.                         <td width="24%"> <input name="goback" type="button" class="s03" id="goback"  onClick="gotestpaper()" value="返回"></td>
  220.                         <td width="10%">&nbsp;</td>
  221.                       </tr>
  222.                     </table>
  223.                     
  224.                   </div>
  225.                   </td>
  226.               </tr>
  227.             </table></TD>
  228.         </TR>
  229.       </TBODY>
  230.     </TABLE>
  231.     <TABLE width=600 border=1 align=center cellSpacing=1 bordercolor="#799AE1" style="border-collapse: collapse">
  232.       <TBODY>
  233.         <TR>
  234.           <td width="587" height=30 bgColor=#E3E3E3 class=l> 
  235.             <table width="100%" border="0" cellspacing="0" bgcolor="#FFFDE8">
  236.               <tr bgcolor="#FFFDE8"> 
  237.                 <td width="47" height="20" nowrap background="../images/admin_bg_1.gif"> 
  238.                   <div align="center"></div></td>
  239.                 <td width="197" height="30" nowrap background="../images/admin_bg_1.gif" bgcolor="#FFFDE8"> 
  240.                   <div align="left"><strong>试卷名称</strong></div></td>
  241.                 <td width="138" nowrap background="../images/admin_bg_1.gif"> 
  242.                   <div align="center"><strong>考试发布时间</strong></div></td>
  243.                 <td width="117" nowrap background="../images/admin_bg_1.gif"> 
  244.                   <div align="center"><strong>考试类型</strong></div></td>
  245.                 <td width="93" nowrap background="../images/admin_bg_1.gif"> 
  246.                   <div align="left"><strong>总分</strong></div></td>
  247.               </tr>
  248.             </table></td>
  249.         </TR>
  250.             <TR>
  251.           <td width="587" height=22 class=l> <table width="100%" border="0" cellspacing="0" cellpadding="0">
  252.               <tr>
  253.                 <td width="43" height="20" nowrap><div align="center"> </div></td>
  254.                 <td width="201" nowrap> <div align="left"><%=test.name%></div></td>
  255.                 <td width="136" nowrap><div align="center"><%=test.time%></div></td>
  256.                 <td width="118" nowrap><div align="center"><%=test.testclass%></div></td>
  257.                 <td width="94" nowrap> <div align="left"><%=test.totalMark%></div></td>
  258.               </tr>
  259.             </table></td>
  260.         </TR>
  261.       </TBODY>
  262.     </TABLE>
  263.     <br>
  264.     <table  width="600" height="82" border="1" cellspacing="1" bordercolor="#799AE1" id="AutoNumber1" style="border-collapse: collapse">
  265.       <tr class="trh">
  266.         <td width="52" height="30" align="center" nowrap background="../images/admin_bg_1.gif"> 
  267.           <font color="#FFFFFF"><b>序号</b></font></td>
  268.         <td width="535" height="30" align="center" nowrap background="../images/admin_bg_1.gif"> 
  269.           <p align="center"><font color="#FFFFFF"> <b>单项选择题(共<%=test.testnum%>&nbsp;题,<%=test.totalMark%>分)</b></font></td>
  270.       </tr>
  271.       <% int testNumber=0;
  272. while(rs.next()){%>
  273.       <tr class="trh1">
  274.         <td width="52"   height="35" align="center" nowrap bgcolor="#FFFFFF">  
  275.           <center>
  276.             <table width="100%" border="0" cellspacing="0" cellpadding="0">
  277.               <tr>
  278.                 <td bgcolor="#FFFFFF"> 
  279.                   <div align="center">
  280.                     <input name="id" type="checkbox" id="id" value="<%=rs.getInt("ID")%>">
  281.                     <%out.print(testNumber+1);%>
  282.                     . </div></td>
  283.               </tr>
  284.               <tr>
  285.                 <td bgcolor="#FFFFFF">
  286. <div align="center">(<%=rs.getInt("Mark")%>分)</div></td>
  287.               </tr>
  288.             </table>
  289.           </center>
  290.           &nbsp;</td>
  291.         <td width="535" height="35" align="left" bgcolor="#FFFFFF"><br>
  292.           <%
  293. out.print("题目:<br>"+rs.getString("QuestText"));
  294. out.print("答案:&nbsp;&nbsp;"+rs.getString("Answer"));
  295. out.print("<br>提示:<br>"+""+rs.getString("Tip"));
  296. testNumber++;
  297. %>
  298.         </td>
  299.       </tr>
  300.       <%}
  301.     rs.close();
  302.     stmt.close();
  303.     %>
  304.     </table>
  305.     <p>
  306.     <input name="testID" type="hidden" id="testID" value="<%=test.id%>">
  307. </FORM>
  308.   <!--end test -->
  309.   <!--begin bottom -->
  310.   <!--end bottom -->
  311. </CENTER>
  312. </BODY>
  313. </HTML>
  314. <%}
  315. catch(SQLException se){
  316.     out.println("<br>sql="+sql);
  317.     out.println("<br>"+se.toString());
  318. }
  319. catch(Exception e){
  320.     out.print(e.toString());
  321. }
  322. finally{
  323.     DBCon.dropConnection();
  324. }
  325. %>