当前位置: 首页 > 图文教程 > 网络编程 > ASP > 用ASP制作在线测试

ASP
ASP限制只能中文输入的方法
获得jpg文件的实际尺寸
关于页面缓存清除的方法小结
如何更好更快的debug
ASP中缓冲的启用及执行速度的影响
处理二进制数据
如何读出空格
排序方式解决“上下主题”问题(一)
排序方式解决“上下主题”问题(二)
排序方式解决“上下主题”问题(三)
关于ACCESS 2K与ASP的几点想法
提高IIS的安全性
ASP3.0中的流控制能力(1)
ASP3.0中的流控制能力(2)
ASP3.0中的流控制能力(3)
关于JMAIL如何在收件人处指定多个收件人
个人经验:使用asp尽量减少服务器端的工作量
分行模块,自动识别英文和型号数
用IIS+ASP建网站的安全性分析
迁移到 ASP .NET:需考虑的重要问题(1)

用ASP制作在线测试


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 96 ::
收藏到网摘: n/a

  <%

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 %>