欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

用ASP制作在线测试

程序员文章站 2022-08-14 23:32:34
<%curq = request.form("curq")answ = request.form("answ")correct=request.form("correct")...
<%

curq = request.form("curq")
answ = request.form("answ")
correct=request.form("correct")
wrong=request.form("wrong")

poor mans 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(和php搭配之最佳组合) = "select * from questions where questionid=" & curq
    set rstemp= conntemp.execute(mysql(和php搭配之最佳组合))
%>

<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(和php搭配之最佳组合) = "select * from questions where questionid=" & curq