主题:  某日偶得一随机抽取数据库的文件,但不知其用法!

yzhongyan

职务:普通成员
等级:1
金币:0.0
发贴:49
#12003/8/8 10:51:57
请各位高手帮忙解释一下其意?最好是把每一句的意思都讲一下,我是初学者请各位帮忙了,知道多少就写多少吧!谢了

<%@ Language=VBScript %>
<% option explicit %>



考试界面


<%=session("selectsubjectname")%>考试


<%
'if request.form("submit1")="开始考试" then
'保存开始时间
dim starttime
    session("starttime")=hour(now())*60+minute(now())
    starttime=session("starttime")
    
%>





一、单项选择题(每题<%=session("singleper")%>分,共<%=session("singlenumber")%>题)

<%

dim i,sql,rs,count,temp,strid1,strid2
strid1=""
strid2=""
randomize
for i=1 to session("singlenumber")
set rs=server.createobject("adodb.recordset")
sql="select * from question where subjectname='"&session("selectsubjectname") & "'and type='单选题' and haveselect=0"
rs.open sql,conn,3,2
count=rs.recordcount
temp=fix(count*rnd(10))
rs.move temp
rs("haveselect")=1

strid1=strid1 & rs("ID") & ","

%>




<%
if rs("A")<>"" then
%>



<%
end if
%> <%
if rs("B")<>"" then
%>



<%
end if
%> <%
if rs("C")<>"" then
%>



<%
end if
%> <%
if rs("D")<>"" then
%>



<%
end if
%>
  <%=i%>、<%=rs("question")%>
    " value="A">A、<%=rs("A")%>
    " value="B">B、<%=rs("B")%>
    " value="C">C、<%=rs("C")%>
    " value="D">D、<%=rs("D")%>

<%
rs.update
next
rs.close
set rs=nothing
%>




二、多项选择题(每题<%=session("multiper")%>分,共<%=session("multinumber")%>题。每题至少有1项正确的答案,少选、多选、错选均不得分)

<%
randomize
for i=1 to session("multinumber")
set rs=server.createobject("adodb.recordset")
sql="select * from question where subjectname='"&session("selectsubjectname") & "'and type='多选题' and haveselect=0 "
rs.open sql,conn,3,2
count=rs.recordcount
temp=fix(count*rnd(10))
rs.move temp
rs("haveselect")=1

strid2=strid2 & rs("ID") & ","

%>




<%
if rs("A")<>"" then
%>



<%
end if
%> <%
if rs("B")<>"" then
%>



<%
end if
%> <%
if rs("C")<>"" then
%>



<%
end if
%> <%
if rs("D")<>"" then
%>



<%
end if
%>
  <%=i%>、<%=rs("question")%>
    " value="A">A、<%=rs("A")%>
    " value="B">B、<%=rs("B")%>
    " value="C">C、<%=rs("C")%>
    " value="D">D、<%=rs("D")%>

<%
rs.update
next
rs.close

response.write("")
response.write("")

set rs=nothing
set rs=server.createobject("adodb.recordset")
sql="select * from question where haveselect=1 "
rs.open sql,conn,3,2
rs.movefirst
do while not rs.eof
rs("haveselect")=0
rs.update
rs.movenext
loop
rs.close
set rs=nothing
call endConnection()
'response.write(strid1)
'response.write(strid2)
%>



<%
dim lefttime
lefttime=1
'do while lefttime>0
'lefttime=session("testtime")-(hour(now())*60+minute(now())-session("starttime"))
'loop
'if lefttime=0 or lefttime<0 then
%>

<%
'end if
%>
<%
' else
%>
<%
'response.write "
请选择开始考试!
"
' end if
%>