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

教育系统应用

开发平台:

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