Developing an online exam program with ASP (vii)

Source: Internet
Author: User
Tags count insert query
program | Online result.asp
The main purpose of this page is to display the results and insert the results into the database for future reference.
For each item in Request.Form
Sql_check = "Select Count (*) from" &subject& "where answer = '" & Request.Form (item) & ""
Set Rs_check = Application ("Conn"). Execute (Sql_check)
If Rs_check (0) > 0 Then
result = result + 1
End If
Next
The results are stored in the variable result.
Percentages are calculated from result, as follows:
Percent = Round ((* result)/count)
To store this result in a database, execute the following query:
sql_id = "SELECT id from Loginuser where username= '" & Session ("username") & "'"
Set rs_id = Application ("Conn"). Execute (sql_id)
Id= rs_id (0)
Sql_insert = "INSERT into details (Ref_id,subject,score) VALUES ('" & ID & "', '" _
& Subject & "', '" & Percent & ""
Set Rs_insert = Application ("Conn"). Execute (Sql_insert)
View.asp
Watch the module to check if the member has conducted an online exam before. If so, the user is directed to viewrecord.asp. If not, display the appropriate information.
sql_id= "SELECT ID from Loginuser where username= '" & Session ("username") & ""
Set rs_id = Application ("Conn"). Execute (sql_id)
Id= rs_id (0)
Sql_count = "SELECT count (*) from details where ref_id = '" & ID & "'"
Set Rs_count = Application ("Conn"). Execute (Sql_count)
If rs_count (0) < > 0 Then
Response.Redirect "Viewrecord.asp"
End If
If rs_count (0) = 0 Then
Session ("Noview") = "NO ONLINE examinations HAVE BEEN GIVEN"
Response.Redirect "Default.asp"
End If
Viewrecord.asp
The Viewrecord.asp page allows members to view some of their detail information. The query is as follows:
sql_details = "Select *subject, score from details where ref_id = '" & ID & "'"
Set rs_details = Application ("Conn"). Execute (Sql_details)
The result is displayed in a simple tabular format.

Please note that I do not limit the number of times a member can conduct a subject to a test. The same subject examination can be carried out at any time.



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.