⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mgquestion.asp

📁 在线考试系统
💻 ASP
字号:
<%@ Language=VBScript %>
<% option explicit %>
<!--#include file="conn.asp"-->
<!--#include file="Checkadmin.asp"-->
<% 
  dim isedit  '是否在修改状态
  dim sql,rs
  dim subjectname
  dim number  '每页显示的文章数目
  dim curpage, i,page  
  subjectname=trim(request("subjectname"))
  function invert(str) 
    invert=replace(replace(replace(replace(str,"&lt;","<"),"&gt;",">"),"<br>",chr(13)),"&nbsp;"," ")
  end function
  number=15  '显示试题数默认值
  isedit=false
  if request("action")="edit" then
   ''''''''''''''''''''''''''修复答案类型'''''' 
  
      sql="UPDATE QUESTION SET type='MULTI'  WHERE LEN(rtrim(lTRIM(answer)))>1" 
  	     conn.execute sql
	     sql="UPDATE QUESTION SET type='SINGLE'  WHERE LEN(rtrim(lTRIM(answer)))=1" 
	 conn.execute sql
	      sql="UPDATE QUESTION SET answer=upper(answer) "
		  conn.execute sql



	    '''''''''cstr'''''''''''''''''''''''
      isedit=true
  end if
  if request("action")="del" then  '删除
     sql="delete from question where id=" &request("id")
	 conn.execute sql
     %>
     <script language=vbscript>
	     msgbox "操作成功!!该试题已删除!" 
     </script>
<%
end if
%>
<html>
<head>
<title>管理试题</title>
<link href="STYLE.CSS" rel="stylesheet" type="text/css">
</head>
<body background=images/backimage.gif > 
<center>
  <p align="left"><a href="primarypage.asp"><font color=red size=+0 face=宋体>返回管理界面</font></a></p>
  <h1><font color=blue  ><b><a href="primarypage.asp" style="font-family: &quot;华文行楷&quot;; font-size: larger;">学科试题管理</a></b></font></h1>
  <hr>
  <p align="left" style="font-family: &quot;黑体&quot;; font-size: medium;">
    <%  if isedit then
	   set rs=server.createobject("adodb.recordset")
	   rs.open "select * from question where id=" & cstr(request("id")),conn,1,1
	   response.write "编 辑 试 题"
   else
	   response.write "添 加 试 题"
   end if %>
(<font color=red>带*各项均必须完全填写</font>)  </p>
  <form action="addquestion.asp"  method="post">
    <input type="Hidden" name="action" value='<% If isedit then%>modify<% Else %>add<% End If %>'>
    <input type="Hidden" name="id" value='<%=request("id")%>'>
    <input type="Hidden" name="page" value='<%=request("page")%>'>
    <p align="left"><font color=red>*</font>问题:
        <input type="text" name="question" class=input maxlength=100 size="50" value='<% if isedit then
     response.write trim(rs("question")) 
     end if %>'>
    </p>
    <p align="left"><font color=red>*</font>科目:
        <input type="text" name="subjectname" class=input maxlength=30 size="10" value='<%=subjectname%>'>
    </p>
    <p align="left"> 选项A:
        <input type="text" name="A" class=input maxlength=100 size="50" value='<% if isedit then
     response.write trim(rs("A")) 
     end if %>'>
        <br>
    选项B:
    <input type="text" name="B" class=input maxlength=100 size="50" value='<% if isedit then
     response.write trim(rs("B")) 
     end if %>'>
    <br>
    选项C:
    <input type="text" name="C" class=input maxlength=100 size="50" value='<% if isedit then
     response.write trim(rs("C")) 
     end if %>'>
    <br>
    选项D:
    <input type="text" name="D" class=input maxlength=100 size="50" value='<% if isedit then
     response.write trim(rs("D")) 
     end if %>'>
    </p>
    <p align="left"><font color=red>*</font>答案(大写半角英文字母,多选答案用逗号空格分隔,如A, B, C):
        <input style="ime-mode: disabled " type="text"name="answer" class=input maxlength=15 size="10" value='<% if isedit then
     response.write trim(rs("answer")) 
     end if %>'>
</p>
    <p align="left"><font color=red>*</font>类型(单选题还是多选题):
        <input type="radio" name="leixing" value="SINGLE" checked
     <% if isedit then
	   if  rs("type")="single" OR rs("type")="SINGLE" then
	       response.write "checked"
	   end if
	end if  %>>
        单选题&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
        <input type="radio" name="leixing" value="MULTI" 
	<% if isedit then
	      if rs("type")="multi" OR rs("type")="MULTI"then
	         response.write "checked"
	    end if
	  end if
         %>>
        多选题</p>
    <p align="left"><font color=red></font>图片:
        <input type="text" name="image" class=input maxlength=100 size="50" value='<% if isedit then
     response.write trim(rs("image")) 
          end if %>'>
    </p>
    <p align="left"><font color=red></font>声音:
        <input type="text" name="voice" class=input maxlength=100 size="50" value='<% if isedit then
     response.write trim(rs("voice")) 
          end if %>'>
    </p>
    <p align="center">
      <input name="submit" type=submit class=button value="  确  认  ">
    </p>
  </form>
  <hr>
</center><br>
<script language=javascript>
function SureDel(id,subjectname)
{
    if ( confirm("你是否真的要删除该试题?"))   
        {
            window.location.href = "mgquestion.asp?action=del&id=" +id +"&subjectname=" +subjectname
        }
}
</script>
 <%
  set rs=server.createobject("adodb.recordset")
  rs.open "select * from question where subjectname='" & cstr(trim(request("subjectname"))) & "' order by id  ",conn,1,1
  if err.number <> 0 then
	           response.write "数据库出错"
           else
	           if rs.bof and rs.eof then
		           rs.close
		           response.write "该科目没有试题"
	           else
			        %>
                   
<table width="100%" border="1" cellspacing="0" cellpadding="0" align="center" height="44" bordercolor=purble>
  <tr> 
    <td width="2%">
      <div align="center">编号</div>
    </td>
    <td width="15%">
      <div align="center">问题</div>
    </td>
    <td width="8%">
      <div align="center">图片</div>
    </td>
    <td width="8%">
      <div align="center">声音</div>
    </td>
    <td width="8%"> 
      <div align="center">选项A</div>
    </td>
    <td width="8%"> 
      <div align="center">选项B</div>
    </td>
    <td width="8%"> 
      <div align="center">选项C</div>
    </td>
    <td width="8%"> 
      <div align="center">选项D</div>
    </td>
    <td width="8%"> 
      <div align="center">答案</div>
    </td>
    <td width="8%"> 
      <div align="center">题型</div>
    </td>
    <td width="8%"> 
      <div align="center">科目</div>
    </td>
    <td width="15%"> 
      <div align="center">操作</div>
    </td>
  </tr>
  <%
               if request("page")="" then
  	               curpage = 1
               else
	               curpage = cint(request("page"))
               end if

               rs.pagesize=cint(number)
               rs.absolutepage = curpage
               for i = 1 to rs.pagesize
                   %>
  <tr> 
    <td width="1%" height="1" > 
      <div align="center"><font size="3"><%=rs("id")%></font></div>
    </td>
    <td  height="1" > 
      <div align="center"><font size="3"><a href='mgquestion.asp?type=<%=trim(rs("type"))%>&subjectname=<%=trim(rs("subjectname"))%>&action=edit&id=<%= trim(rs("id"))%>&page=<%=request("page")%>'><%=rs("question")%></a></font></div>
    </td>
    <td  height="1" > 
      <div align="center"><font size="3"><%=rs("image")%></font></div>
    </td>
    <td  height="1" > 
      <div align="center"><font size="3"><%=rs("voice")%></font></div>
    </td>
    <td  height="1" > 
      <div align="center"><font size="3"><%=rs("A")%></font></div>
    </td>
    <td  height="1" > 
      <div align="center"><font size="3"><%=rs("B")%></font></div>
    </td>
    <td  height="1" > 
      <div align="center"><font size="3"><%=rs("C")%></font></div>
    </td>
    <td  height="1" > 
      <div align="center"><font size="3"><%=rs("D")%></font></div>
    </td>
    <td  height="1" > 
      <div align="center"><font size="3"><%=rs("answer")%></font></div>
    </td>
    <td  height="1" > 
      <div align="center"><font size="3">
	  <%IF rs("type")="SINGLE" or rs("type")="single"THEN
	   Response.Write("单选题")
	   ELSE
	   Response.Write("多选题")
	   END IF
	  %>	  </font></div>
    </td>
    <td  height="1" > 
      <div align="center"><font size="3"><%=rs("subjectname")%></font></div>
    </td>
    <td  height="1" > 
      <div align="center"><font size="3"> <a href='mgquestion.asp?type=<%=trim(rs("type"))%>&subjectname=<%=trim(rs("subjectname"))%>&action=edit&id=<%= trim(rs("id"))%>&page=<%=request("page")%>'>编辑</a>&nbsp<a href='javascript:SureDel(<%=rs("id") %>,subjectname="<%=rs("subjectname")%>")'>删除</a></font></div>
    </td>
  </tr>
  <% rs.movenext
      if rs.eof then
	      i = i + 1
	      exit for
     end if
               next %>
</table>
 
	      <% response.write "<hr size=0 width='100%'><div align=center>"
		response.write "第<font color=red>" + cstr(curpage) + "</font>页/共<font color=red>" + cstr(rs.pagecount) + "</font>页 "
		response.write "本页<font color=red>" + cstr(i-1) + "</font>条/共<font color=red>" + cstr(rs.recordcount) + "</font>条 "
		if curpage = 1 then 
			
		else
			response.write "<a href='mgquestion.asp?subjectname=" & cstr(request("subjectname")) & "&page=1'>首页</a> <a href='mgquestion.asp?type=" & cstr(request("type"))  & "&subjectname=" & cstr(request("subjectname"))& "&page=" & cstr(curpage-1) & "'>前页</a> "
		end if
		if  curpage = rs.pagecount then
			
		else
			response.write "<a href='mgquestion.asp?subjectname=" & cstr(request("subjectname")) & "&page=" + cstr(curpage+1) + "'>后页</a> <a href='mgquestion.asp?subjectname=" & cstr(request("subjectname")) + "&page=" + cstr(rs.pagecount) + "'>末页</a>"
		end if
	end If
end if

 'rs.close
set rs=nothing
 %>
<hr size=0 width=100%>
 <p align=center><a href="primarypage.asp"><font color=red size=+0 face=宋体>返回管理界面</font></a></p>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -