论坛风格切换切换到宽版
  • 4339阅读
  • 0回复

请高手帮忙随机调用题库题目重复的解决办法 [复制链接]

上一主题 下一主题
离线wa123
 

发帖
116
金钱
19871
威望
0
贡献值
0
只看楼主 倒序阅读 使用道具 0 发表于: 2011-06-20
<!--#include file="../student/check.asp"--><!--#include file="conn.asp"-->

<%
flagpd=0
flagxz=0
flagtk=0
randomize
set rss=conn.execute("select top 1 * from report where 学生id="&session("studyid") &" and (是否补考=False or 补考成绩<>0) order by id desc ")

if rss.eof then
qi=1
else
qi=rss("id")+1
end if
set rss=conn.execute("select top 1 * from report where 学生id="&session("studyid")&" and (是否补考=True and  补考成绩=0) order by id desc ")
if not rss.eof then
qi=rss("id")
end if


set rss=conn.execute("select top 1 * from test order by id desc")
if rss.eof then
%>
<script language=javascript>
alert("请先出题!再进行考试!");
history.back();
</script>
<%
else
pd=rss("判断题数")
pds=rss("判断题每题分数")
xz=rss("选择题数")
xzs=rss("选择题每题分数")
tk=rss("填空题数")
tks=rss("填空题每题分数")
session("ttime")=rss("考试时间")
session("timen")=rss("考试时间")
zf=pd*pds+xz*xzs+tk*tks
testid=rss("id")

set rs=conn.execute("select top 1 * from type1 order by id desc")
maxtype1=rs("id")
set rs=conn.execute("select top 1 * from type2 order by id desc")
maxtype2=rs("id")
set rs=conn.execute("select top 1 * from type3 order by id desc")
maxtype3=rs("id")

sqlfind="select * from report where 试卷id="&testid&" and 学生id="&session("studyid")&" and (是否补考=False or 补考成绩<>0)"
set rsfind=conn.execute (sqlfind)
if not rsfind.eof then

%>

<script language=javascript>
alert("你已经参加过这次考试了,请等待下一次考试!");
window.navigate("index.asp");
</script>
<%else
set rsfinds=conn.execute("select * from report where 试卷id="&testid&" and 学生id="&session("studyid")&" and (是否补考=True and  补考成绩=0)")
if not rsfinds.eof then
else
sqlin="insert into report (id,试卷id,学生id,分数) values("&qi&","&testid&","&session("studyid")&",0)"
'response.write sqlin
'response.end
set rsin=conn.execute(sqlin)
end if
end if
%>
<!--#include file="ChangeTime.asp" -->
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网上考试系统</title>
<link rel="stylesheet" type="text/css" href="css.css">
</head>

<body topmargin="0" leftmargin="0" onload="ChangeTime()">


        <TABLE height=227 cellSpacing=0 cellPadding=0 width=100 align=left border=0>
          <TBODY>
            <TR>
              
              <TD vAlign=top width=763 bgColor=#ffffff height=197><table border="1" cellpadding="4" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="760" height="264">
                  <tr>
                    <td height="187" align="center"><div align="center">
  <center>
  <form name=form1 action="test_over.asp">
<table border="1" cellpadding="4" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="760" height="100">
  <tr>
    <td align="center"><font class=test1>第 <%=qi%> 期考试</font>
    <input type="hidden" name=qi value=<%=qi%>>  
    <input type=hidden name=testid value=<%=testid%>>  
     <br>(本期考试 <%=pd%> 道判断题,<%=xz%>  道选择题,<%=tk%> 道填空题,总分 <%=zf%> 分)<br><br>  
     <input type=hidden name=pd value=<%=pd%>>  
     <input type=hidden name=xz value=<%=xz%>>  
<input type=hidden name=tk value=<%=tk%>>  
<input type=hidden name=zf value=<%=zf%>>  
<input type=hidden name=pds value=<%=pds%>>  
<input type=hidden name=xzs value=<%=xzs%>>  
<input type=hidden name=tks value=<%=tks%>>  
  
  
<div align="center" class="Xhsmall">
  <%
  TimeLogin=time()
  TimeSubmit=DateAdd("n", TimeGet, TimeLogin)
  response.Write("登录时间:"&TimeLogin&"  交卷时间:"&TimeSubmit)  
  %>
  </div><br><font color="#000080">
    <%
studyid=session("studyid")
set rs= Server.CreateObject("adodb.recordset")
sqlstr="select * from student where studyid='"&studyid&"'"
rs.open sqlstr,conn,1,3
%>考生姓名:<%=rs("yourname")%>    学号:<%=rs("studyid")%>    班级:<%=rs("yourclass")%></font><br>  
   <%rs.close
   set rs=nothing%> <br>  
    <div align="center">  
      <center>  
      <table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="750">  
        <tr>  
          <td bgcolor="#CBEFDC">一、判断题(共 <%=pd%> 道,每题 <%=pds%> 分)</td>  
        </tr>  
        <%  
        if pd=0 then  
        response.write "<input type=hidden name=messagepd value='本次考无判断题'>"  
        flagpd=0  
        %><tr>  
          <td align=center>本次考无判断题  
          </td>  
        </tr>  
    <%  
  
    else  
    for i=1 to pd  
    if maxtype1=0 then  
        response.write "<input type=hidden name=messagepd value='题库里暂无判断题'>"  
        flagpd=0  
    %><tr>  
          <td align=center>题库里暂无判断题  
          </td>  
        </tr>  
    <%  
  
    else  
      
    randomize  
    sid=int((maxtype1+1)*rnd+1)  
    set rst=conn.execute("select * from type1 where id="&sid)  
      
    while rst.eof  
    randomize  
  
    sid=int((maxtype1+1)*rnd+1)  
    set rst=conn.execute("select * from type1 where id="&sid)  
    wend  
      
      
    %>  
        <tr>  
          <td>    <%=i%>、<%=rst("题干")%>  
          <input type=hidden name="tgpd<%=i%>" value="<%=rst("题干")%>">  
          <select name="cate<%=i%>" size="1" style="background-color: rgb(224,252,255)">  
            <option selected value=True>对</option>  
            <option value=False>错</option></select>  
            <input type=hidden name="pdda<%=i%>" value="<%=rst("正确答案")%>">  
  
          </td>  
        </tr>  
        <%  
        end if  
        next  
        end if %>                              
      </table>  
      </center>  
    </div>  
<br>  
    <div align="center">  
      <center>  
      <table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="750">  
        <tr>  
          <td bgcolor="#CBEFDC">一、选择题(共 <%=xz%> 道,每题 <%=xzs%> 分)</td>  
        </tr>  
          <%if xz=0 then  
                  response.write "<input type=hidden name=messagepd value='本次考无选择题'>"  
        flagxz=0  
        %><tr>  
          <td align=center>本次考无选择题  
          </td>  
        </tr>  
    <%else  
    for i=1 to xz  
    if maxtype2=0 then  
                      response.write "<input type=hidden name=messagepd value='题库里暂无选择题'>"  
    flagxz=0  
    %><tr>  
          <td align=center>题库里暂无选择题  
          </td>  
        </tr>  
    <%else  
    randomize  
    sid=int((maxtype2+1)*rnd+1)  
    set rst=conn.execute("select * from type2 where id="&sid)  
    while rst.eof  
    randomize  
  
    sid=int((maxtype2+1)*rnd+1)  
    set rst=conn.execute("select * from type2 where id="&sid)  
      
    wend  
    %>  
  
        <tr>  
          <td>    <%=i%>、<%=rst("题干")%>  
          <input type=hidden name="tgxz<%=i%>" value="<%=rst("题干")%>"></td>  
        </tr>  
        
        <tr>  
          <td>  
                   
            <input  type="radio" value="A" name="sele<%=i%>"> A.<%=rst("选项1")%>    
<input type=hidden name="xzxx1<%=i%>" value="<%=rst("选项1")%>" >  
  
            <input  type="radio" value="B" name="sele<%=i%>"> B.<%=rst("选项2")%>   
<input type=hidden name="xzxx2<%=i%>" value="<%=rst("选项2")%>" >  
              
            <input  type="radio" value="C" name="sele<%=i%>"> C.<%=rst("选项3")%>    
            <input type=hidden name="xzxx3<%=i%>" value="<%=rst("选项3")%>" >  
  
            <input  type="radio" value="D" name="sele<%=i%>"> D.<%=rst("选项4")%>  
            <input type=hidden name="xzxx4<%=i%>" value="<%=rst("选项4")%>" >  
  
<input type=hidden name="xzda<%=i%>" value="<%=rst("正确答案")%>" >  
          </td>  
        </tr>  
          <%  
        end if  
        next  
        end if %>  
        </table>  
      </center>  
    </div>  
<br>  
    <div align="center">  
      <center>  
      <table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="750">  
        <tr>  
          <td bgcolor="#CBEFDC">一、填空题(共 <%=tk%> 道,每题 <%=tks%> 分)</td>  
        </tr>  
         <%if tk=0 then  
                      response.write "<input type=hidden name=messagepd value='本次考无填空题'>"  
        flagtk=0  
        %><tr>  
          <td align=center>本次考无填空题  
            
          </td>  
        </tr>  
    <%else  
    for i=1 to tk
    if maxtype3=0 then  
                      response.write "<input type=hidden name=messagepd value='题库里暂无填空题'>"  
    flagtk=0  
    %><tr>  
          <td align=center>题库里暂无填空题  
          </td>  
        </tr>  
    <%else  
    randomize  
    sid=int((maxtype3+1)*rnd+1)  
    set rst=conn.execute("select * from type3 where id="&sid)  
    while rst.eof  
    randomize  
  
    sid=int((maxtype3+1)*rnd+1)  
    set rst=conn.execute("select * from type3 where id="&sid)  
      
      
    wend  
      
    %>  
  
        <tr>  
          <td>    <%=i%>、<%=rst("题干")%>  
          <input type=hidden name="tgtk<%=i%>" value="<%=rst("题干")%>">  
            您的答案:<input type="text" name="T<%=i%>" size="20" class="line"></td>  
<input type="hidden" name="tkda<%=i%>" value="<%=rst("正确答案")%>">  
        </tr>  
         <%  
        end if  
        next  
        end if %>  
          
        </table>  
  
      </center>  
    </div>  
    <br>  
      <input type="submit" value="提交" name="B1"> <input type="reset" value="重置" name="B2">  
    </form>  <p>  
    <div align="center">
      <center></td>
                  </tr>
              </table></TD>
              
            </TR>
            <TR>
              <TD colSpan=3 height=30><IMG height=1 width=825></TD>
            </TR>
          </TBODY>
        </TABLE>
      </center>
    </div>
    <p><br>
  
      </td>  
      </tr>  
      </table>  
  
  </center>  
</div>  

</body>  
  
</html>  
<%end if %>
评价一下你浏览此帖子的感受

精彩

感动

搞笑

开心

愤怒

无聊

灌水
快速回复
限100 字节
 
上一个 下一个