用ASP实现聊天室中的在线答题游戏

2016-01-29 19:43 2 1 收藏

用ASP实现聊天室中的在线答题游戏,用ASP实现聊天室中的在线答题游戏

【 tulaoshi.com - ASP 】

       主要功能为:在聊天室中,每隔5分钟,向显示对话页面,发送一道题,所有用户都可答题。
  答对者加相应的分值。
  具体实现:在聊天室框架中加入一隐含帧,
  此帧每5分钟刷新一次。
  隐含帧内的ASP页内容如下:
  <%@ LANGUAGE=VBs cript%>
  <%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>
  <s cript Language="Javas cript">
  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>");
  </s cript>
  </head>
  <body bgcolor='#FFFFFF'>
  </Body>
  </html>
  处理答题部分略!!! 答案处理部分,放在处理发送对话信息的程序中即可。下面是答案处理的代码部分: if mid(FStr,i,1)="#" then 'FStr是保存对话信息的字符串变量
  TFstr=mid(FStr,i+1,1)
  if CInt(DateDiff("n",application("questionTime"),Now()))<=1 then '判断时间1分钟内答题有效
  if LCase(TFstr)=LCase(application("answerTrue")) then '判断答题是否

来源:https://www.tulaoshi.com/n/20160129/1509964.html

延伸阅读
标签: ASP
  ################main.asp###################### <%Response.Buffer=true Response.Expires=0 userName=Request.Form("username") if username="" then Response.Redirect "index.asp" session("u_name")=username if Request.Form("sx")="1" then session("u_...
标签: ASP
  ################reload.asp############## <%'Response.ContentType="text/xml" Response.Write "<?xml version=""1.0"" encoding=""GB2312""?" Response.Write "<Msg" dim c_info,c_Lid,c_Ip,u_Lid,NewLid,u_name,i c_info=Application("c_inf...
标签: ASP
  这是最重要的一个了。也很大。我的习惯不太好。没有加详细的注释,认真看吧。 #########send.asp############## <html <head <META content="text/html; charset=gb2312" http-equiv=Content-Type <meta http-equiv='pragma' content='no-cache' <link REL="SHORTCUTICON" url="images/Blueno...
标签: ASP
  #############续send.asp################# var oRDom=new ActiveXObject("Microsoft.XMLDOM"); oRDom.async=false; var Path="reload.asp"; var tCok; function Clock() {cRld++; if (cRld10){cRld=1;GetXmlData();} clearTimeout(tCok); tCok=setTimeout("Clock()",1000); } function GetXmlData() /...
标签: ASP
  ########say.asp############## <% Option Explicit dim F,T,sC,cL,E,W,sJ Response.ContentType="text/xml" F=Request.Form ("F") T=Request.Form ("T") sC=Request.Form ("sC") cL=Request.Form ("cL") E=Request.Form("E") 'W=Request.Form("W") W=&quo...

经验教程

562

收藏

16
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部