用ASP開發一個線上考試程式(七)

來源:互聯網
上載者:User
程式|線上 Result.asp
  這一頁的主要目的是顯示結果,同時將這些結果插入資料庫以備將來參考。
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中儲存了結果。
  百分數是從result中算出來的,如下所示:
percent = round(( 100 * result )/count)
  要將這個結果儲存在資料庫中,執行以下查詢:
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
  觀看模組檢查會員是否以前曾經進行過線上考試。如果是的話,將使用者引導到viewrecord.asp。如果沒有的話,顯示相應的資訊。
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頁使會員能夠觀看一些他們的細節資訊。查詢如下:
sql_details = "Select *subject, score from details where ref_id = '" & id &"'"
Set RS_details = Application("Conn").Execute(sql_details)
結果是用一個簡單的表格格式來顯示的。

  請注意,我並沒有將會員可以進行一個主題的考試次數限制為一次。同一個主題考試可以進行任意次。



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.