用ASP制作在线测试

 1   
 2  
 3CurQ = Request.Form("CurQ")   
 4Answ = Request.Form("Answ")   
 5correct=Request.Form("Correct")   
 6wrong=Request.Form("Wrong")   
 7  
 8'Poor Man's IsNull Code goes here   
 9  
10If PoorMansIsNull(CurQ) Then   
11CurQ = 1   
12correct = 0   
13wrong = 0   
14End If   
15  
16If PoorMansIsNUll(Answ) Then   
17CurQ = CurQ + 1   
18If CurQ > (Your maximum number of questions) Then   
1<p>Congratulations. You have completed this test. You missed ```
2=wrong

questions,
but got ``` =correct

=(correct/(max#ofQs)

1Thank you for doing the test.   

End If

1  

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

 1  
 2<h2>Question Number ```
 3=rsTemp("QuestionID")
 4``` </h2>
 5<form action="myASP.ASP" method="POST">
 6<input =curq="" ```="" name="CurQ" type="hidden" value="```"/>   
 7Your question is ```
 8=rsTemp("Question")
 9```<br/>   
10Answer:   
11<select name="AnsW">
12<option value="1">```
13=rsTemp("AnswerA")&lt;/option&gt;
14&lt;option value="2"&gt;&amp;lt;%=rsTemp("AnswerB")&lt;/option&gt;
15&lt;option value="3"&gt;&amp;lt;%=rsTemp("AnswerC")&lt;/option&gt;
16&lt;option value="4"&gt;&amp;lt;%=rsTemp("AnswerD")&lt;/option&gt;
17&lt;/select&gt;
18&lt;input type="hidden" value="&amp;lt;%=correct
19```"/><input type="hidden" value="```
20=wrong
21```"/>
22<input type="reset" value="Clear the Form"/><input type="submit" value="OK!"/>
23</form>   
24  

Else

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

1  
2<p>Congratulations. You got it right. Whee</p>   

correct = correct + 1

1  

Else

1  
2<p>I'm sorry, you missed the question. You can review by   
3reading: </p>
4<p>```
5=rsTemp("reference")&lt;/p&gt;   
6&amp;lt;% wrong = wrong + 1 
1 End If 
1 End If 
2```</p>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus