首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 网站建设 > ASP > 用ASP制作在线测试
【标  题】:用ASP制作在线测试
【关键字】:ASP,在线,ASP
【来  源】:网络

用ASP制作在线测试

<%

CurQ = Request.Form("CurQ")
Answ = Request.Form("Answ")
correct=Request.Form("Correct")
wrong=Request.Form("Wrong")

'Poor Man's IsNull Code goes here

If PoorMansIsNull(CurQ) Then           
        CurQ = 1                            
        correct = 0
        wrong = 0
End If

If PoorMansIsNUll(Answ) Then
        CurQ = CurQ + 1
        If CurQ > (Your maximum number of questions) Then
%>
        <p>Congratulations. You have completed this test. You missed <%=wrong%>
questions,
        but got <%=correct%> questions right. That is equivilent to a
<%=(correct/(max#ofQs)%>%.
        Thank you for doing the test.
<% End If %>

<%  set conntemp = server.createobject("adoDB.Connection")
    set myDSN = '(your DSN info goes here)
    conntemp.Open myDSN
    set mySQL = "SELECT * FROM QUESTIONS WHERE QuestionID=" & CurQ
    set rsTemp= conntemp.Execute(mySQL)
%>

<h2>Question Number <%=rsTemp("QuestionID")%> </h2>

<form method=POST action="myASP.ASP">
    <input type=hidden name=CurQ value=<%=CurQ%>>
Your question is <%=rsTemp("Question")%><br>
Answer:
        <select name="AnsW">
                <option value=1><%=rsTemp("AnswerA")</option>
                <option value=2><%=rsTemp("AnswerB")</option>
                <option value=3><%=rsTemp("AnswerC")</option>
                <option value=4><%=rsTemp("AnswerD")</option>
         </select>    
<input type=hidden value="<%=correct%>"><input type=hidden value="<%=wrong%>">
<input type=reset value="Clear the Form"><input type=submit value="OK!">
</form>

<% Else %>
<%   set conntemp = server.createobject("adoDB.Connection")
     set myDSN = '(your DSN info goes here)
     conntemp.Open myDSN
     set mySQL = "SELECT * FROM QUESTIONS WHERE QuestionID=" & CurQ
     set rsTemp= conntemp.Execute(mySQL)
             If AnsW = rsTemp("CorrectAns") Then
%>

                <p>Congratulations. You got it right. Whee</p>
                <% correct = correct + 1 %>

             <% Else %>

                <p>I'm sorry, you missed the question. You can review by
reading: </p>
                <p><%=rsTemp("reference")</p>
                <% wrong = wrong + 1 %>

             <% End If %>

      <form method=POST action="myASP.ASP">
              <input type="hidden" name=curQ value="<%=curQ%>">
              <input type="hidden" name=correct value="<%=correct%>">
              <input type="hidden" name=wrong value="<%=wrong%>">
              <input type="submit" value="Next Question"%>
      </form>

<% End If %>
ASP讲座之六:ASP与数据库(一):【上一篇】
怎样使用ASP实现Ping:【下一篇】
【相关文章】
没有相关文章
【随机文章】
  • 巧用VBA自动处理Word表格
  • 将一个集合转换为一个DataTable
  • const个人小解
  • OSPF路由协议验证
  • 结合PHP使用HTML表单访问单个和多个表单值
  • 架设流媒体服务器之RealProducer
  • Microsoft Vista Speech Recognition Tested
  • BMP文件格式及创建简单位图
  • 局域网arp欺诈与防御
  • Java 访问数据库的速度瓶颈问题的分析及解决(2)
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.