Using ASP to make online test

Source: Internet
Author: User
Tags dsn mysql
Online <%

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 are have completed this test. You missed <%=wrong%>
Questions
But got <%=correct%> questions right. That's equivilent to a
<%= (correct/(MAX#OFQS)%>%.
Thank 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)
%>


<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 are got it right. Whee</p>
<% correct = correct + 1%>

<% Else%>

<p>i ' m sorry, you missed the question. 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%>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.