用ASP實現聊天室中的線上答題遊戲

來源:互聯網
上載者:User
聊天室|線上 主要功能為:在聊天室中,每隔5分鐘,向顯示對話頁面,發送一道題,所有使用者都可答題。
答對者加相應的分值。
具體實現:在聊天室架構中加入一隱含幀,
此幀每5分鐘重新整理一次。
隱含幀內的ASP頁內容如下:
<%@ LANGUAGE=VBScript%>
<%Response.Expires=0%>
<%
Dim Conn,Rs
Application.Lock
application("CanswerName")=application("answerName") '儲存答對題使用者的名字
application("answerName")=""
application("TanswerName")="" '清除答錯題使用者的名子
set Conn=server.createobject("ADODB.Connection")
accessdb="db1.mdb" '題庫的串連
myDSN="DRIVER={Microsoft Access Driver (*.mdb)};"
myDSN=myDSN & "DBQ=" &server.mappath(accessdb)
Conn.Open myDSN
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.CursorLocation=3
Rs.open "select * from QUESTION ",Conn
Randomize '隨機取得一道題的ID
r=Rs.RecordCount
ID=int((r-1)*Rnd)+1
Rs.Close
set Rs=Nothing
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.open "select * from QUESTION where questionID="&ID,Conn
application("questionName")=Rs("questionName") '題目
application("questionID")=Rs("questionID") '題的ID
application("questionCent")=Rs("questionCent") '題的分數
application("questionClass")=Rs("questionNotes")'題的說明
Rs.close
Set Rs = Nothing
Set Ra = Server.CreateObject("ADODB.Recordset")
Ra.open "select * from ANSWER where questionID="&ID,Conn
application("answerA")=Ra("answerA") '題的選項
application("answerB")=Ra("answerB")
application("answerC")=Ra("answerC")
application("answerD")=Ra("answerD")
application("answerTrue")=Ra("answerTrue") '題的正確答案
Ra.close
set Ra=Nothing
Conn.Close
set Conn=Nothing
application("questionTime")=Now()
Application.UnLock
%>
<HTML>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
<Link Rel='stylesheet' Href='../Style.Css' Type='text/css'>
<meta http-equiv="refresh" content="300;url=question.asp">
<title><%=Application("V")%></title>
<script Language="JavaScript">
parent.ShowSays.document.write("******系統訊息:******<br>"); //向聊天室顯示交談視窗寫入問題
parent.ShowSays.document.write("**上題答對者為:<%=application"CanswerName")%><br>");
parent.ShowSays.document.write("問題::<%=application("questionName")%>");
parent.ShowSays.document.write(" <%=application("questionCent")%>分(1分鐘之內,回答輸入‘#答案’)<%=Time()%><br>");
parent.ShowSays.document.write("A::<%=application("answerA")%><br>");
parent.ShowSays.document.write("B::<%=application("answerB")%><br>");
parent.ShowSays.document.write("C::<%=application("answerC")%><br>");
parent.ShowSays.document.write("D::<%=application("answerD")%><br>");
</script>
</head>
<body bgcolor='#FFFFFF'>
</Body>
</html>
處理答題部分略!!!



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.