Result.asp
這一頁的主要目的是顯示結(jié)果,同時(shí)將這些結(jié)果插入數(shù)據(jù)庫以備將來參考。
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
變量result中存儲(chǔ)了結(jié)果。
百分?jǐn)?shù)是從result中算出來的,如下所示:
percent = round(( 100 * result )/count)
要將這個(gè)結(jié)果存儲(chǔ)在數(shù)據(jù)庫中,執(zhí)行以下查詢:
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
觀看模塊檢查會(huì)員是否以前曾經(jīng)進(jìn)行過在線考試。如果是的話,將用戶引導(dǎo)到viewrecord.asp。如果沒有的話,顯示相應(yīng)的信息。
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
Viewrecord.asp頁使會(huì)員能夠觀看一些他們的細(xì)節(jié)信息。查詢?nèi)缦拢?BR>sql_details = "Select *subject, score from details where ref_id = '" & id &"'"
Set RS_details = Application("Conn").Execute(sql_details)
結(jié)果是用一個(gè)簡單的表格格式來顯示的。
請注意,我并沒有將會(huì)員可以進(jìn)行一個(gè)主題的考試次數(shù)限制為一次。同一個(gè)主題考試可以進(jìn)行任意次。