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

教育系统应用

开发平台:

WORD

  1. <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" %>
  2. <%@ page errorPage="QuestGen_error.jsp" %>
  3. <%@ page import="java.io.*"%>
  4. <%@ page import="jinghua.Tools"%>
  5. <jsp:useBean id="DBCon" class="jinghua.JinghuaConn" scope="session">
  6. </jsp:useBean>
  7. <%!Connection con=null;
  8. String teachID="";
  9. String sql=null;
  10. Statement stmt=null;
  11. ResultSet rs=null;
  12. String testname=null;
  13. %>
  14. <%
  15. try{
  16. String testID=request.getParameter("testID");
  17. if(testID==null)
  18. throw new Exception("调用参数不足!");
  19. con=DBCon.getConnection();
  20. sql="SELECT  `test`.`paper`,`test`.`testnum`,  `test`.`title`,  `test`.`date`,  `test`.`mark`"+
  21. "  FROM  `test` WHERE  (`test`.`id` = "+testID+")";
  22.     stmt=con.createStatement();
  23.     rs=stmt.executeQuery(sql);
  24. if(rs.next()){
  25. testname=rs.getString("title");
  26. rs.close();
  27. stmt.close();
  28. }else{
  29. rs.close();
  30. stmt.close();
  31. throw new Exception("查询试卷题目错误!");
  32. }
  33. %>
  34. <script language="javascript">
  35. function CheckForm(f)
  36. {
  37. //获取HTML文本
  38. if (editor.EditMode.checked==true)
  39.   document.myform.Content.value=editor.Composition.document.body.innerText;
  40.    else
  41.   document.myform.Content.value=editor.Composition.document.body.innerHTML;
  42. //var v=document.myform.Content.value=editor.Composition.document.body.innerHTML;
  43. //alert(v);
  44. if (f.Answer.value.length < 1) // 没有输入答案
  45. {
  46.     alert("您还没有输入答案!");
  47. return false;
  48. }
  49. if( f.Mark.value.length<1)
  50. {
  51.     alert("您还有输入该试题的分数!");
  52. return false;
  53. }
  54. if(!isNumberString(f.Mark.value,"1234567890."))
  55. {
  56.     alert("嘿!您在分数里填了东西,但怎么不是数字呢?n");
  57.     return false;
  58. }
  59.     if( f.Grade.selectedIndex == 0) {
  60.         alert("请选择年级信息!")
  61.         return false;
  62.     }
  63.     if(f.Subject.selectedIndex==0){
  64.         alert("请选择科目信息!")
  65.         return false;
  66.     }
  67.     if((f.KnowPoint1.selectedIndex==0)&&(f.KnowPoint2.selectedIndex==0)&&(f.KnowPoint3.selectedIndex==0)){
  68.         alert("请选知识点信息!")
  69.         return false;
  70.     }
  71. return true;
  72. }
  73. function isNumberString (InString,RefString)
  74. {
  75. if(InString.length==0) return (false);
  76. for (Count=0; Count < InString.length; Count++)  {
  77. TempChar= InString.substring (Count, Count+1);
  78. if (RefString.indexOf (TempChar, 0)==-1)
  79. return (false);
  80. }
  81. return (true);
  82. }
  83. function gotestpaper(){
  84. document.myform.method = "POST";
  85.     document.myform.action = "modify_test_unit.jsp";
  86.     document.myform.target="_self";
  87.     document.myform.submit();
  88. }
  89. </script>
  90. <!--年级,科目,知识点三个下拉列表框联动-->
  91. <%
  92. String temp=Tools.sub_know(DBCon.getConnection());
  93. out.print(temp);
  94. temp=Tools.grade_sub(DBCon.getConnection());
  95. out.print(temp);
  96. %>
  97. <script language="JavaScript">
  98. function changegs(locationid){
  99.     document.myform.Subject.length =1;
  100.         document.myform.KnowPoint1.length =1;
  101.         document.myform.KnowPoint2.length =1;
  102.         document.myform.KnowPoint3.length =1;
  103.         var locationid=locationid;
  104.         var i;
  105.         for (i=0;i < gscount; i++){
  106.             if (grade_sub[i][0] == locationid) {
  107.             document.myform.Subject.options[document.myform.Subject.length] = new Option(grade_sub[i][2], grade_sub[i][1]);
  108.             }
  109. }
  110. }
  111. </script>
  112. <script language="JavaScript">
  113. function changesk(locationid){
  114. document.myform.KnowPoint1.length =1;
  115.     document.myform.KnowPoint2.length =1;
  116.     document.myform.KnowPoint3.length =1;
  117. var locationid=locationid;
  118. var i;
  119. for (i=0;i < gskcount; i++){
  120. if (grade_sub_know[i][1] == locationid){
  121. document.myform.KnowPoint1.options[document.myform.KnowPoint1.length] = new Option(grade_sub_know[i][3], grade_sub_know[i][2]);
  122.             document.myform.KnowPoint2.options[document.myform.KnowPoint2.length] = new Option(grade_sub_know[i][3], grade_sub_know[i][2]);
  123.             document.myform.KnowPoint3.options[document.myform.KnowPoint3.length] = new Option(grade_sub_know[i][3], grade_sub_know[i][2]);
  124. }
  125. }
  126. }
  127. </script>
  128. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  129. <html>
  130. <head>
  131. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  132. <link rel="stylesheet" type="text/css" href="../css.css">
  133. <title>试题提交</title>
  134. </head>
  135. <body>
  136. <FORM action="unit_test_quest_add_rs.jsp" method=post name=myform target="_self" onSubmit="return CheckForm(this)">
  137.   <TABLE width="100%" border=0 align=center cellPadding=0 cellSpacing=0>
  138.     <TBODY>
  139.       <TR>
  140.         <TD width="21%" rowSpan=2> <div align="left"><img height=45 src="images/logo.gif"
  141.   width=160></div></TD>
  142.         <TD width="63%" height=45>
  143.           <div align="center"><strong><font color="#3366FF" size="+2" face="黑体">试题录入<strong><font color="#3366FF" size="+2" face="黑体">:<%=testname%></font></strong></font></strong></div></TD>
  144.         <TD width="16%"><div align="right"></div></TD>
  145.       </TR>
  146.     </TBODY>
  147.   </TABLE>
  148.    
  149.   <table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
  150.     <!--DWLayoutTable-->
  151.     <tr>
  152.     <td width="100%" height="535" valign="top">
  153. <table width="100%" height="354" border="1" bordercolor="#d3add1" background="images/lvbgcolor.gif">
  154.           <tr>
  155.             <td width="34%" height="40" align="left" valign="middle"> 题目类型:
  156.               <select id=QuestType name=QuestType>
  157.                 <%Tools.showOption("select * from questtype",con,out);%>
  158.               </select>
  159.             </td>
  160.             <td width="66%" align="left" valign="middle"><table width="100%" border="0">
  161.                 <tr>
  162.                   <td width="21%" height="39" align="left" nowrap>答案: <input name="Answer" type="text" id="Answer3" size="5" maxlength="5">
  163.                   </td>
  164.                   <td width="20%" align="left" nowrap>分数: <input name="Mark" type="text" id="Mark2" size="5"></td>
  165.                   <td width="26%" align="left" nowrap> <div align="left">难易度:
  166.                       <select name=Difficulty id="select6">
  167.                         <option value="A" selected>A</option>
  168.                         <option value="B">B</option>
  169.                         <option value="C">C</option>
  170.                         <option value="D">D</option>
  171.                         <option value="E">E</option>
  172.                       </select>
  173.                     </div></td>
  174.                   <td width="11%" align="left" valign="middle"> <input name="Submit" type="submit" class="s03" value="提交">
  175.                   </td>
  176.                   <td width="11%" align="left" valign="middle">
  177.   <input name="Reset_Quest" type="reset" class="s03" id="Reset_Quest2" value="重置">
  178.                   </td>
  179.                   <td width="11%" align="left" valign="middle">
  180.   <input name="Submit2" type="button" class="s03" onClick="gotestpaper()" value="返回"></td>
  181.                 </tr>
  182.               </table></td>
  183.           </tr>
  184.           <tr>
  185.             <td height="40" align="left" valign="middle"> 年 级:
  186.               <select id=select10 name=Grade onClick="changegs(document.myform.Grade.options[document.myform.Grade.selectedIndex].value)" size="1">
  187.                 <option value="temp">未选择</option>
  188.                 <%Tools.showGradeOption(con,out);%>
  189.               </select> </td>
  190.             <td rowspan="3" align="center"> <iframe src="../editor/edit.jsp" id='editor' frameborder=0 scrolling=auto width=544 height=321>
  191.               </iframe>
  192.               <textarea name="Content" style="display:none"></textarea>
  193.               &nbsp; <input name="group" type="hidden" id="group" value="single">
  194.               <input name="testID" type="hidden" id="testID" value="<%=testID%>">
  195.               <input name="teacherID" type="hidden" value="1"></td>
  196.           </tr>
  197.           <tr>
  198.             <td height="40" align="left" valign="middle"> 科 目:
  199.               <select id=select8 name=Subject onClick="changesk(document.myform.Subject.options[document.myform.Subject.selectedIndex].value)"
  200. size="1">
  201.                 <option value="temp">未选择</option>
  202.                 <%--Tools.showOption("select * from subject order by id",con,out);--%>
  203.               </select>
  204.             </td>
  205.           </tr>
  206.           <tr>
  207.             <td height="215" align="left" valign="top">
  208.               <table width="100%" height="175" border="0" align="center">
  209.                 <tr>
  210.                   <td width="68%" height="21">知识点1: </td>
  211.                 </tr>
  212.                 <tr>
  213.                   <td height="35">
  214. <select name=KnowPoint1 id="select7">
  215.                       <option value=-1>----未选择----</option>
  216.                       <%-- Tools.showOption("select * from knowpoint order by id",con,out);--%>
  217.                     </select></td>
  218.                 </tr>
  219.                 <tr>
  220.                   <td height="25">知识点2:</td>
  221.                 </tr>
  222.                 <tr>
  223.                   <td height="36">
  224.                     <select name=KnowPoint2 id="select12">
  225.                       <option value=-1>----未选择----</option>
  226.                       <%-- Tools.showOption("select * from knowpoint order by id",con,out);--%>
  227.                     </select></td>
  228.                 </tr>
  229.                 <tr>
  230.                   <td height="21">知识点3:</td>
  231.                 </tr>
  232.                 <tr>
  233.                   <td height="23">
  234. <select name=KnowPoint3 id="select16">
  235.                       <option value=-1>----未选择----</option>
  236.                       <%-- Tools.showOption("select * from knowpoint order by id",con,out);--%>
  237.                     </select></td>
  238.                 </tr>
  239.               </table>
  240.             </td>
  241.           </tr>
  242.         </table></td>
  243.   </tr>
  244. </table>
  245. </form>
  246. </body>
  247. </html>
  248. <%}
  249. catch(Exception e){
  250.     System.out.print(e.toString());
  251. }
  252. finally{
  253.     DBCon.dropConnection();
  254. }
  255. %>