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

教育系统应用

开发平台:

WORD

  1. <%@ page contentType="text/html; charset=gb2312" language="java" %>
  2. <%@ page import="java.sql.*" %>
  3. <%@ page import="java.io.*"%>
  4. <%@ page import="jinghua.*"%>
  5. <jsp:useBean id="DBCon" class="jinghua.JinghuaConn" scope="session">
  6. </jsp:useBean>
  7. <%!
  8. String studentID;
  9. boolean debug=false;
  10. StringBuffer dbmsg=new StringBuffer();
  11. %>
  12. <%
  13. //StudentID
  14. try{
  15.     studentID=(String)session.getAttribute("studentID");
  16.     //Tools.showalert(studentID,out);
  17.     if(studentID==null){
  18.         throw new Exception();
  19.     }
  20. }catch(Exception e){
  21.     Tools.showalert("您还没有登录,或连接超时,请重新登录!",out);
  22.     Tools.showJS("window.open('../login.jsp','_self')",out);
  23. }
  24. //studentID=1;
  25. String gradeID=""+request.getParameter("Grade");
  26. String subjectID=""+request.getParameter("Subject");
  27. String knowpointID=""+request.getParameter("KnowPoint");
  28. gradeID=gradeID.trim();
  29. subjectID=subjectID.trim();
  30. knowpointID=knowpointID.trim();
  31. String sql="";
  32. String title="";
  33. String strClass="";
  34. ResultSet rs=null;
  35. try{
  36.     Connection con=DBCon.getConnection();
  37.     sql="select grade.name as gn,subject.name as sn, knowpoint.name as kn "+
  38.         "from grade,subject,knowpoint where grade.note="+"'"+gradeID+"'"+" and subject.id="+
  39.         subjectID+" and knowpoint.id="+knowpointID;
  40.     PreparedStatement pstmt=con.prepareStatement(sql);
  41.     rs=pstmt.executeQuery();
  42.     if(rs.next()){
  43.         strClass="年级:"+rs.getString("gn")+"   科目:"+rs.getString("sn")+"   知识点:"
  44.             +rs.getString("kn");
  45.     }
  46.     if(debug){
  47.         out.print(strClass);
  48.     }
  49.     pstmt.close();
  50.     rs.close();
  51.     sql="select id,paper,title from test where status=2 and gradenote="+"'"+gradeID+"'"+" and subid="+subjectID+
  52.         " and ((knowpointid1="+knowpointID+") or (knowpointid2="+knowpointID+
  53.         ") or (knowpointid3="+knowpointID+")) order by id";
  54.     pstmt=con.prepareStatement(sql);
  55.     rs=pstmt.executeQuery();
  56. if(debug) {
  57.     dbmsg.append("<br>sql="+sql);
  58.     out.print(dbmsg.toString());
  59. }
  60. if (rs.next()){//符合条件的记录   //试题ID@答案@分数@难易度;   一道试题的格式,以分号结束
  61.     rs.beforeFirst();
  62.  %>
  63. <html>
  64. <head>
  65. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  66. <title>单元测试-选择试题</title>
  67. </head>
  68. <body text=black bgColor=white leftMargin=0 topMargin=10 marginheight="0"
  69. marginwidth="0">
  70. <DIV align=center>
  71. <FORM name="form1" action="UnitTestPaper.jsp" method="post">
  72. <TABLE cellSpacing=0 cellPadding=0 width=760 align=center border=0>
  73.   <TBODY>
  74.   <TR>
  75.           <TD vAlign=top bgColor=#fbffee> <P>  &nbsp;</P></TD>
  76.     <TD vAlign=top width=480>
  77.       <TABLE cellSpacing=0 cellPadding=0 width=480 border=0>
  78.             <TBODY>
  79.               <TR align=middle>
  80.                 <TD class=p2 height=30>
  81.                     <font color="#74a8d1">
  82.                             <strong><B>
  83.                                 <%=strClass%>
  84.                                     </B>
  85.                             </strong>
  86.                         </font></TD>
  87.               </TR>
  88.              <%while(rs.next()){%>
  89.               <TR bgColor=#cccc99>
  90.                   <TD class=p2 height=30> <P><B><FONT color=#333300>
  91.   <a href="UnitTestPaper.jsp?testID=<%=rs.getInt("ID")%>&stuID=<%=studentID%>"
  92.                         title="<%=rs.getString("title")%>"
  93.    target="_blank">★ <%=rs.getString("title")%>
  94.   </a></FONT></B></P></TD>
  95.               </TR>
  96.                     <TR>
  97.                         <TD class=p2><P>&nbsp;</P></TD>
  98.                     </TR>
  99.             <%
  100.             }
  101.             rs.close();
  102.             pstmt.close();
  103.             %>
  104.             </TBODY>
  105.           </TABLE></TD>
  106.           <TD vAlign=top width=140 bgColor=#fbffee>&nbsp;</TD>
  107.       </TR></TBODY></TABLE>
  108.   </FORM>
  109. </DIV>
  110. </body>
  111. </html>
  112. <%
  113. }else{
  114.     Tools.showalert("没有从数据库找到符合条件的试卷,请重新设定查询条件",out);
  115.     //Tools.goback(out);
  116. }
  117. }catch(SQLException e){
  118.     out.print("<br>SQL Error:sql="+sql+"<br>"+e.toString());
  119. }catch(Exception e){
  120.     out.print(e.toString() );
  121. }
  122. finally{
  123.     DBCon.dropConnection();
  124. }
  125. %>