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

ASP
把HTML表单提交的数据转化成XML文件
全球IP地址查询完整版
一个把WORD转换成HTML的程序
天气预报的小偷,可以偷到全国24小时城市天气预报.
显示页面show.asp--基于web的QQ程序1
接收信息页面inform.asp--基于web的QQ程序2
发送信息页面send.asp--基于web的QQ程序3
关于客户端用ASP参生报表
关于客户端用ASP参生报表(高级篇)
利用ASP在线维护数据库
使用JScript.NET创建asp.net页面(一)
使用JScript.NET创建asp.net页面(二)
使用JScript.NET创建asp.net页面(三)
使用JScript.NET创建asp.net页面(四)
使用JScript.NET创建asp.net页面(五)
使用JScript.NET创建asp.net页面(六)
使用JScript.NET创建asp.net页面(七)
创建一个Web投票系统
W3 Jmail中文使用说明
bbs的数据结构和存储过程(一)

用ASP制作在线测试


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 32 ::
收藏到网摘: 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 %>