paperview.jsp
上传用户:hjt198082
上传日期:2015-04-16
资源大小:95k
文件大小:4k
源码类别:

MySQL数据库

开发平台:

Java

  1. <%@ page contentType="text/html;charset=GBK" %>
  2. <%@ page language="java" import="java.sql.*"%>
  3. <%@ page import="java.lang.Math.*" %>
  4. <%@ page import="java.util.*" %>
  5. <jsp:useBean id="conn" scope="page" class="test.ConnOracle"/>
  6. <%@ include file="/public/checkvalidadmin.jsp"%>
  7. <%@ include file="/public/checkvalidadmin8.jsp"%>
  8. <%!
  9. ResultSet rs = null;
  10. ResultSet rsTmp = null;
  11. String sql = "";
  12. int PageSize = 13;
  13. int Page = 1;
  14. int totalPage = 1;
  15. String str = "";
  16. String curr_classid   = "";
  17. String curr_paperid   = "";
  18. String oper_flag = "";
  19. %>
  20. <%
  21. curr_classid = request.getParameter("classid");
  22. curr_paperid = request.getParameter("paperid"); 
  23. oper_flag    = request.getParameter("operflag");
  24. %>
  25. <html>
  26. <head>
  27. <title>察看试卷</title>
  28.     <link rel="stylesheet" href="../public/style.css">
  29. <Script language="JavaScript">
  30. //打开新窗口函数openwin
  31. function openwin(id)
  32. {
  33.    window.open('questiondetails.jsp?id='+id,'infoWin', 'height=400,width=600,scrollbars=yes,resizable=yes');
  34. }
  35. function mysubmit(flag) {
  36.    document.myform.operflag.value=flag;
  37.    document.myform.submit();
  38. }
  39. </Script>
  40. </head>
  41. <body  class="ss">
  42. <center>
  43. <form name="myform" action="paperview.jsp" method="post">
  44. <%
  45.    sql = "select * from test_classinfo";
  46.    try {
  47.    rs = conn.executeQuery( sql );
  48.    }catch(Exception e) {
  49.    out.println("访问课程信息数据出错!");
  50.    return;
  51.    }
  52. %>
  53.    请选择对应的班级:
  54.    <select name=classid onchange="mysubmit(1)">
  55. <%
  56.    while(rs.next()){
  57.    
  58.    String tmpclassid = rs.getString("classid");
  59.    
  60.    // 在起始状态时,设置一个curr_classid的初试值
  61.    if(curr_classid==null || curr_classid.equals("")) 
  62.    curr_classid = tmpclassid;
  63.    if(curr_classid!=null && curr_classid.equals(tmpclassid)) {
  64.               out.println("<option value=" + tmpclassid + " selected>" + rs.getString("classname") + "</option>");
  65.    }else
  66.               out.println("<option value=" + tmpclassid + ">" + rs.getString("classname") + "</option>");
  67.    }
  68. %>
  69.    </select>
  70. <%
  71.        sql = "select distinct paper_id from test_paper_info where classid='" + curr_classid + "'";
  72.    rs  = conn.executeQuery( sql );
  73.    if(!rs.next()) {
  74.        out.println("还没有班级代号为 " +  curr_classid + " 的试题,请首先生成该班级的试题!");
  75.    return;
  76.    }
  77. %>
  78.    请选择要察看的试卷
  79.    <select name="paperid" name=classid onchange="mysubmit(2)">
  80. <%
  81.    String tmp_paperid = "";
  82.    do{
  83.    tmp_paperid = rs.getInt("paper_id") + "";
  84.    if(oper_flag==null || oper_flag.equals("1")) {
  85.    curr_paperid = tmp_paperid;
  86.    oper_flag = "2";           // 避免每次循环都要重新设置curr_paperid的值
  87.            }
  88.    if(tmp_paperid.equals(curr_paperid)) {
  89.         out.println("<option value=" + tmp_paperid + " selected>第" + tmp_paperid + "套</option>");
  90.            }
  91.    else
  92.                out.println("<option value=" + tmp_paperid + ">第" + tmp_paperid + "套</option>");
  93.    }while(rs.next());
  94. %>    
  95.    </select>
  96.    <!--下面这个隐藏表单域主要是为了用来区别用户到底是更改了班级设定,还是更改了试卷设定进行的提交-->
  97.    <input type="hidden" name="operflag" value="1">
  98. </form>
  99. <hr>
  100. <table class=dbt2 width=640 cellSpacing=1 cellPadding=3 border=0>
  101. <tr class=dbt3 align=middle>
  102. <TH>题目编号</TH>
  103. <TH>在试题库中编号</TH>
  104. <TH>题型</TH>
  105. <TH width=200>题目简介</TH>
  106. <TH>题目详细信息</TH>
  107. </TR>
  108. <%
  109.     sql = "select * from test_paper_info where classid='" + curr_classid + "'";
  110. sql+= " and paper_id=" + curr_paperid;
  111. System.out.println(sql);
  112. rs  = conn.executeQuery( sql );
  113. %>
  114. <%
  115. int k=1;
  116. int tmpquestionid=0;
  117. while(rs.next()) {
  118. %>
  119. <TR class=dbt4 align=center>
  120. <TD><%=k%></TD>
  121.     <TD>
  122. <%
  123. tmpquestionid = rs.getInt("questionid");
  124.     out.println(tmpquestionid);
  125. %>
  126. </TD>
  127.     <TD>
  128. <%
  129.     if(rs.getInt("selectid")==1) out.println("单选");
  130.         else out.println("<font color=blue>多选</font>");
  131. %>
  132. </TD>
  133.     <TD>
  134. <%      int endindex = 16;
  135. String tmp = rs.getString("qname");
  136. if(tmp.length() < endindex) 
  137. endindex = tmp.length();
  138.     out.println(tmp.substring(0,endindex));
  139. %>
  140. </TD>
  141. <TD><%="<a href=javascript:openwin('"+tmpquestionid+"')>察看</a>"%></TD>
  142. </TR>
  143. <%
  144. k++;
  145. }
  146. %>
  147. <TR class=dbt4 align=center>
  148.     <TD colspan=5><a href=paperdel.jsp?paperid=<%=curr_paperid%>&classid=<%=curr_classid%>>删除本套试卷</a></TD>
  149. </TR>
  150. </table>
  151. </center>
  152. <hr>
  153. </body>
  154. </html>