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

📄 exam_paper.asp

📁 在线考试系统
💻 ASP
字号:
<%@ Language=VBScript %>
<% if Session("userid")="" then
        Response.Redirect("exam_login.htm")
   end if     
   examname = session("examname")
   if Session("examover")="1" or cint(Request.Cookies(examname & "totaltime"))< 0 then
        Response.Redirect("exam_result.asp")
   end if     
   totalq = cint(session("totalquestions") )
%>        
<HTML>
<HEAD>
   
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<script language="JavaScript">
var timer,timecounter=0
function readCookie(name)
{
   var result=null;
   var myCookie=document.cookie+";";
   var searchName=name+"=";
   var start=myCookie.indexOf(searchName);
   var end;
   if(start!=-1)
    {
      start+=searchName.length;
      end=myCookie.indexOf(";",start);
      result=myCookie.substring(start,end);
    }
  return result;      
}
function writeCookie(name)
{
  var expDate=new Date();
  var day=1*24*60*60;
  expDate.setTime(expDate.getTime()+day);
  document.cookie=name+"="+timecounter;
}
function starttimer(counter,ans)
{
var cook 
    timecounter=parseInt(readCookie(<%=chr(34) & examname&"totaltime"& chr(34)%> ))
   var index=-1
   if(ans=="A")
        index=0
   else if(ans=="B")
        index=1      
   else if(ans=="C")
        index=2      
   else if(ans=="D")
        index=3
                 
   if(document.examform.qno.value-1<=counter&&index!=-1)
        document.examform.elements[index].checked=true
      timer=setInterval("change()",1000)
      
}
function stoptimer()
{
    writeCookie("<%=examname&"totaltime"%>");  
    clearInterval(timer)
}
function change()
{
    var hrs,mins,secs;
    hrs=parseInt(timecounter/3600);
    mins=parseInt(timecounter/60);
    secs=timecounter%60;
	window.status="剩余时间 : "+hrs+":"+mins+":"+secs;
	rem_time.innerText="剩余时间 :"+hrs+":"+mins+":"+secs;
	timecounter--
	if(timecounter==-1)
	  {
	    store_ans()
	    stoptimer()
	    document.examform.submit()    
	    
	  }  	      
}
function store_ans()
{
     var elems=document.examform.elements 
     var ans=""
    for(var i=0;i<elems.length;i++)
     if((elems[i].type=="radio"||elems[i].type=="checkbox")&&elems[i].checked)
         ans=ans+elems[i].value    
    document.examform.answer.value=ans
    if(ans=="")
      document.examform.answer.value="Not Attempted"    
    stoptimer()
}       
</script>
</HEAD>
<%
  anss=Session("Answers")
  qq=CInt(Request.Form("qno"))
%>
<BODY onload='starttimer(<%=Session("Counter")%>,"<%=anss(qq)%>")' onunload="stoptimer()">
<!-- #INCLUDE FILE = "connect_ama.asp" -->
<%      
   num=Session("Questions")
   current_userid=Session("userid")
   
   if qq <> 1 then
      anss(qq-1)=Request.Form("answer")
      Session("Answers")=anss
  end if
   set rs=myconn.Execute("select * from q_bank where q_id=" & num(qq))
%>


<table>
<tr><td style="WIDTH: 500px" width=500 bgColor=gold ><P align=right><FONT size=4><STRONG>
	<%'=Request.Cookies(examname & "totaltime")%>用户名: <% =current_userid %></STRONG></FONT> </P>
</td></TD></tr></table><br>

<table  border=1  bordercolor=LightGoldenrodYellow><tr><td>
剩余问题数 :<%=totalq-qq%>
<div id=rem_time style="font-color:blue;"></div>
</td></tr>
</table><br>
<%if qq = totalq then %>
     <form name=examform action="exam_result.asp" method="post" onsubmit="store_ans()">
<%else%>     
     <form name=examform action="exam_paper.asp" method="post" onsubmit="store_ans()">     
<%end if%>     
<table width=500>
  <tr><td><b>问题: <%=qq%> . <%=rs("question")%></b></td></tr>

        <tr><td bgcolor=LightGoldenrodYellow><input type=radio name=answers value="A"><%=rs("optA")%></td></tr>
        <tr><td><input type=radio name=answers value="B"><%=rs("optB")%></td></tr>
        <tr><td bgcolor=LightGoldenrodYellow><input type=radio name=answers value="C"><%=rs("optC")%></td></tr>
<tr><td align=center>
<%if qq<>1 then %>
    <input type=button value="&lt;&lt; 前一题  " onclick="history.back()">
<% end if %>    

<%if qq = totalq then %>
    <input type=submit value="完成 &gt;&gt;"><br><br>
<% else %>    
    <input type=submit value="  后一题 &gt;&gt;"><br><br>
<% end if %>    
</td></tr>
</table>        
<%if rs("image") <>"" then%>
      <img src="../aero_images/<%=rs("image")%>">
<% end if
       tempcount=CInt(Session("Counter"))

       if tempcount=qq then
        Session("Counter")=tempcount+1
       end if
      
%>              
<input type=hidden name=qno value="<%=qq+1%>">
<input type=hidden name=answer>
</form>
<P> </P>
<%
    'x=Session("answers") 
    'for i=1 to Session("Counter") 
      'Response.Write i&","&x(i)&"<br>"
    'next  
%>
<table>
<tr><td style="WIDTH: 500px" width=500 bgColor=gold 
      ><P align=right><strong><font size="4">在线考试系统</font></strong> </P>
</td></TD>     
</tr>
</table>
</BODY>
</HTML>
<%
'''''''''''''''''''''''''''''''''
'closing order important'''''''''
 myconn.Close

set myconn=nothing
set myrs=nothing
'''''''''''''''''''''''''''''''''
%>

⌨️ 快捷键说明

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