欢迎光临
我们一直在努力

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

建站超值云服务器,限时71元/月

主要功能为:在聊天室中,每隔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>

处理答题部分略!!!

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 用ASP实现聊天室中的在线答题游戏
分享到: 更多 (0)

相关推荐

  • 暂无文章