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