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

教育系统应用

开发平台:

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. <jsp:useBean id="DBCon" class="jinghua.JinghuaConn" scope="session">
  6. </jsp:useBean>
  7. <%!Connection con;
  8. class Test{
  9.     String id;
  10.     String name;
  11.     String grade;
  12.     String time;
  13.     String totalMark;
  14.     String testclass;
  15.     public String toString(){
  16.         String temp="";
  17.         temp="<br> id="+id+"<br> name="+name;
  18.         return temp;
  19.    }
  20. };
  21. boolean debug=false;
  22. Statement stmt=null;
  23. ResultSet rs=null;
  24. String sql="";
  25. String mnName=null;
  26. int mntotalmark=0;
  27. %>
  28. <%
  29. ArrayList testSet=new ArrayList();
  30. String testIDs=null;
  31. try{
  32.     con=DBCon.getConnection();
  33. String mn_testID=request.getParameter("mnID");
  34. if(mn_testID==null)
  35. throw new Exception("页面缺少调用参数!");
  36. sql="SELECT   `mn_test`.`test_paper`,`mn_test`.`mntotalmark`,`mn_test`.`name` FROM  `mn_test`"+
  37. " WHERE   `mn_test`.`id`="+mn_testID;
  38. stmt=con.createStatement();
  39. rs=stmt.executeQuery(sql);
  40. if(rs.next()){
  41. testIDs=rs.getString("test_paper");
  42. mnName=rs.getString("name");
  43. mntotalmark=rs.getInt("mntotalmark");
  44. }
  45. else
  46. throw new Exception("没有查询到有关该模拟考试的试题数!");
  47. if(testIDs==null)
  48. throw new Exception("没有查询到有关该模拟考试的试题数!");
  49. rs.close();
  50. stmt.close();
  51. sql="SELECT   `test`.`id`,  `grade`.`Name` AS `gradename`,"+
  52.     "  `test`.`title` AS `testname`,  `test`.`mark`,  `test`.`date` AS `testdate`"+
  53.     "  FROM  `test`  LEFT OUTER JOIN `grade` ON (`test`.`gradenote` = `grade`.`note`)"+
  54. "  WHERE `test`.`id` IN("+testIDs+")";
  55.     if(debug) out.println("<br>test sql="+sql);
  56.     stmt=con.createStatement();
  57.     rs=stmt.executeQuery(sql);
  58.     while(rs.next()){
  59.      Test t=new Test();
  60.         t.id=rs.getString("id");
  61.         t.name=rs.getString("testname");
  62.         t.grade=rs.getString("gradename");
  63.         t.totalMark=rs.getString("mark");
  64. t.testclass="模拟考试";
  65.         t.time=rs.getString("testdate");
  66.         testSet.add(t);
  67.     }
  68.     rs.close();
  69.     stmt.close();
  70. %>
  71. <script language="JavaScript">
  72. function CheckForm(f)
  73. {
  74. if( f.mntotalmark.value.length<1)
  75. {
  76.     alert("您还没有输入分数!");
  77. return false;
  78. }
  79. if(!isNumberString(f.mntotalmark.value,"1234567890."))
  80. {
  81.     alert("嘿!您在分数下限里填了东西,但怎么不是数字呢?n");
  82.     return false;
  83. }
  84.    
  85. return true;
  86. }
  87. function isNumberString (InString,RefString)
  88. {
  89. if(InString.length==0) return (false);
  90. for (Count=0; Count < InString.length; Count++)  {
  91. TempChar= InString.substring (Count, Count+1);
  92. if (RefString.indexOf (TempChar, 0)==-1)
  93. return (false);
  94. }
  95. return (true);
  96. }
  97. function gotestpaper(){
  98. document.myform.method = "POST";
  99.     document.myform.action = "modify_test.jsp";
  100.     document.myform.target="_self";
  101.     document.myform.submit();
  102. }
  103. </script>
  104. <HTML>
  105. <HEAD>
  106. <META http-equiv=Content-Type content="text/html; charset=gb2312">
  107. <TITLE>共创学堂-模拟考试成绩查询</TITLE>
  108. <SCRIPT language=JavaScript>
  109. <!--
  110. function SymError()
  111. {
  112.   return true;
  113. }
  114. window.onerror = SymError;
  115. //-->
  116. </SCRIPT>
  117. <!-- saved from url=(0041)http://jsptestonline.cosoft.org.cn/senior/none_xt.jsp -->
  118. <META http-equiv=Content-Type content="text/html; charset=gb2312"><LINK
  119. href="../errorpad/style/style.css" type=text/css rel=stylesheet>
  120. <SCRIPT src=""></SCRIPT>
  121. <SCRIPT src=""></SCRIPT>
  122. <SCRIPT src=""></SCRIPT>
  123. <SCRIPT src=""></SCRIPT>
  124. <SCRIPT src=""></SCRIPT>
  125. <META content="MSHTML 6.00.2462.0" name=GENERATOR>
  126. <link rel="stylesheet" type="text/css" href="../css.css">
  127. </HEAD>
  128. <BODY bgColor=#ffffff text=#000000 onLoad="InitMyform()">
  129. <CENTER>
  130. <TABLE cellSpacing=0 cellPadding=0 width=650 border=0>
  131.   <TBODY>
  132.   <TR>
  133.           <TD><IMG height=27 src="../errorpad/images/test_pop_01.gif" width=102></TD>
  134.           <TD align=right><IMG height=27 src="../errorpad/images/test_pop_02.gif"
  135.       width=134></TD>
  136.         </TR></TBODY></TABLE>
  137.   <strong><font color="#3366FF" size="+2" face="黑体">模拟考试试卷修改</font></strong>
  138.   <!--begin test -->
  139.   <FORM action=modify_mn_test_totalmark.jsp method=post name=myform target="_self" id="myform" onSubmit="return CheckForm(this)">
  140.     <TABLE width=100% height="60" border=0 cellPadding=0 cellSpacing=0>
  141.       <TBODY>
  142.       </TBODY>
  143.     </TABLE>
  144.   <div align="center"><strong><%=mnName%></strong>
  145.     <%if (testSet.size()>0){
  146.  %>
  147.   </div>
  148.     <TABLE width=600 border=1 align=center cellSpacing=1 bordercolor="#799AE1" style="border-collapse: collapse">
  149.       <TBODY>
  150.         <TR>
  151.           <td width="587" height=22 bgColor=#E3E3E3 class=l> <table width="100%" border="0" cellspacing="0" cellpadding="0">
  152.               <tr>
  153.                 <td width="42" height="20" nowrap><div align="center"></div></td>
  154.                 <td width="239" nowrap> <div align="left"><strong>试卷名称</strong></div></td>
  155.                 <td width="149" nowrap><div align="center"><strong>考试发布时间</strong></div></td>
  156.                 <td width="78" nowrap><div align="center"><strong>考试类型</strong></div></td>
  157.                 <td width="84" nowrap><div align="center"><strong>总分</strong></div></td>
  158.               </tr>
  159.             </table></td>
  160.         </TR>
  161. <%          Iterator iter = testSet.listIterator();
  162.             while (iter.hasNext()) {
  163.                 Test t = (Test) iter.next();
  164. %>
  165.             <TR>
  166.           <td width="587" height=22 class=l> <table width="100%" border="0" cellspacing="0" cellpadding="0">
  167.               <tr>
  168.                 <td width="41" height="20" nowrap><div align="center"> </div></td>
  169.                 <td width="238" nowrap> <div align="left">
  170. <a href="modify_test_mn_paper.jsp?testID=<%=t.id%>&mnID=<%=mn_testID%>" target="_self"><%=t.name%></a></div></td>
  171.                 <td width="153" nowrap><div align="center"><%=t.time%></div></td>
  172.                 <td width="77" nowrap><div align="center"><%=t.testclass%></div></td>
  173.                 <td width="83" nowrap> <div align="center"><%=t.totalMark%></div></td>
  174.               </tr>
  175.             </table></td>
  176.         </TR>
  177. <%
  178.             }
  179. %>
  180.       </TBODY>
  181.     </TABLE>
  182.     <p>&nbsp;</p>
  183.     <table width=600 border=1 align=center cellspacing=1 bordercolor="#799AE1" style="border-collapse: collapse">
  184.       
  185.       <tbody>
  186.         <tr>
  187.           <td width="587" height=75 bgcolor=#E3E3E3 class=l>
  188.             <table width="100%" border="0">
  189.               <tr>
  190.                 <td><table width="100%" border="0">
  191.                     <tr>
  192.                       <td width="4%">&nbsp;</td>
  193.                       <td width="26%" nowrap><strong>模拟考试的总分合计为:</strong></td>
  194.                       <td width="70%" nowrap><strong><%=mntotalmark%></strong></td>
  195.                     </tr>
  196.                   </table></td>
  197.               </tr>
  198.               <tr>
  199.                 <td><table width="100%" border="0">
  200.                     <tr>
  201.                       <td width="4%" nowrap>&nbsp;</td>
  202.                       <td width="50%" nowrap><strong>如果模拟考试的总分合计不对,重新将其设置为:</strong></td>
  203.                       <td width="18%"><input name="mntotalmark" type="text" id="mntotalmark3" size="10" maxlength="10"></td>
  204.                       <td width="28%"><input name="Submit" type="submit" class="s03" value="重设总分"></td>
  205.                     </tr>
  206.                   </table></td>
  207.               </tr>
  208.             </table></td>
  209.         </tr>
  210.       </tbody>
  211.     </table>
  212.     <br>
  213.     <input name="Submit2" type="button" class="s03" onClick="gotestpaper()" value="返回">
  214.     <input name="mn_testID" type="hidden" id="mn_testID" value="<%=mn_testID%>">
  215.   </FORM>
  216. <%}
  217. else{
  218.    %>
  219.   <%
  220. }
  221. %>
  222.   <!--end test -->
  223.   <!--begin bottom -->
  224.   <!--end bottom -->
  225. </CENTER>
  226. </BODY>
  227. </HTML>
  228. <%}
  229. catch(SQLException se){
  230.     out.println("<br>sql="+sql);
  231.     out.println("<br>"+se.toString());
  232. }
  233. catch(Exception e){
  234.     out.print(e.toString());
  235. }
  236. finally{
  237.     DBCon.dropConnection();
  238. }
  239. %>