目 录
前言
与传统教育相比,远程教育是一种全新的教育模式,它可以突破时间和空间的限制,帮助人们随时随地地学习,让更多的学习者共享优秀教育资源。远程教育既具有开放性、交互性、协作性和自主性等特点,又具有异步性、实时性、生动性、集成性和大容量等优势。因此,在远程教育系统的建设中,单纯地构建各种功能单一的系统并不能完全满足远程教育建设的需求,只有那些对数据和信息进行了有效组织、整合了多种业务、为用户提供个性化服务的系统才能充分发挥远程教育的作用。
使用在线教育系统可以为用户提供在线教案学习、在线提交作业和查询教师等服务。
第一章 编程环境基础知识
1.1 ASP技术简介
Microsoft Active Server Pages 即我们所称的ASP,其实是一套微软开发的服务器端脚本环境.Active Server Page 是创建动态网页的一个很好的工具,它起一种编程语言的作用,可以利用它编写动态产生HTML的程序代码.因此,只要用户浏览Web站点并请求一个ASP页,Web服务器就可以处理相应的ASP代码,生成HTML代码,然后将它传递到用户浏览器并显示出网页.
ASP程序的优点:
1,ASP使用VBScript脚本语言直接源于VB语言,秉承了VB简单易学的特点,掌管起来非常容易.
2,无须编译,容易编写,可在服务器端直接执行.
3,利用ADO组件轻松存取数据库.
4,与浏览器无关,客户端只要使用可执行HTML码的浏览器,即可浏览ASP所设计的网页内容.
5,ASP能与任何ActiveX scripting语言相容.除了可使用VBScript或JavaScript语言来设计外,还通过plug-in的方式,使用由第三方所提供的其他脚本语言.
6,ASP技术的处理速度相当快,并且其安全性也很高,ASP的源程序,不会被传到客户浏览器,因而可以避免所写的源程序被他人剽窃,也提高了程序的安全性.
7,ASP的对象和组件:ASP有7个固有对象这7个固有对象分别是Request,Response,Server,Application,Session,ASPError和ObjectContext.
1.2 ACCESS2003 技术简介
Access2003 就是关系数据库开发工具,数据库能汇集各种信息以供查询,存储和检索.那么什么叫数据库呢 数据库(Database)是由一些有意义和有关系的数据(data)所组合而成.一个数据库中,包含了许多条记录(Record),而每条记录是由多个字段(Field)所组成,不同的字段存放这不同的数据.所以数据库的严格定义是一组相关记录的集合,而字段则是最基本的数据项,也是数据库中最小的单位.在计算机中用来帮我们管理数据库的系统,我们称之为数据库管理管理系统(Database Management System DBMS).数据库管理系统是架构在一个或多个数据库之上,并针对数据库中的数据进行管理运用.
Access 的优点在于它能使用数据表示图或自定义窗体收集信息,数据表示图提供了一种类似于 Excel 的电子表格,可以使数据库一目了然.另外,Access 允许创建自定义报表用于打印或输出数据库中的信息.Access也提供了数据存储库,可以使用桌面数据库文件把数据库文件置于网络文件服务器,与其他网络用户共享数据库.如上所述,Access 作为关系数据库开发具备了许多优点,可以在一个数据包中同时拥有桌面数据库的便利和关系数据库的强大功能.
第二章 需求分析
一个典型的在线教育系统至少应包含资料显示、资料管理和教师管理3种功
能。本站的系统结构如图2—1所示。
2-1系统结构
2.1 目标设计
在线教育系统所要实现的功能如下。
● 资料显示模块
■ 显示资料
■ 显示教师介绍
■ 浏览查阅资料
■ 回复提交资料
● 资料管理模块
■ 资料栏目管理
■ 发布资料
■ 管理资料
● 教师管理模块
■ 添加教师信息
■ 编辑教师信息
■ 删除教师信息
2.2 系统功能分析与设计
在线教育系统共分为3个模块:资料显示模块、资料管理模块和教师管理模块,其功能模块划分如图所示。
2.3 性能需求
开发环境
- WindowsXP操作系统
- 80G的硬盘空间
- AMD2500+处理器
- 17 # 纯平监视器
- 512内存
适用环境
1.Windows98/Me/2000/XP操作系统
2.1G以上的硬盘空间
3.Inter 赛扬1.0G以上处理器
4.15 # 普通监视器以上
5.32M以上内存
第三章 系统设计
3.1 资料显示模块
资料显示模块包含以下子模块。
● 资料显示
● 资料搜索
资料显示子模块包含以下页面。
● index.asp
● detail.asp
● download.asp
● teacherinfo.asp
资料搜索子模块包含以下页面。
● search.asp
● list.asp
各页面间的关系如图3-1所示。
3-1各页面间的关系
3.1.1 资料信息显示页
1. index.asp页面示例
图3-2为显示资料信息所看到的页面。
图 3-2 显示资料信息
2. 页面中需要用户填写的HTML表单元素。
此页无需填写HTML表单元素。
3. 页面所涉及的数据库表信息。
此页面用来显示资料信息,使用了系统中的资料信息表main和教师信息表teacher。
4. 页面代码分析
‘引用创建数据库连接对象函数文件
<!--#include file="conn.asp"-->
‘引用网站设置文件
<!--#include file="fenlei.asp"-->
<%’取得网站设置信息
sql = "select * from config"
set rs = server.createobject("adodb.recordset")
rs.open sql,conn,1,3
schoolname = rs("schoolname")
gonggao = rs("gonggao")
todaytimes = rs("todaytimes")
times = rs("times")
‘今日访问统计
if rs("todaydate") <> date() then
rs("todaydate") = date()
rs.update
todaytimes = 0
end if
‘总访问统计
if request.cookies("counted") <> "yes" then
response.cookies("counted") = "yes"
‘设置cookies失效时间
response.cookies("counted").expires = now() + 1/72
‘统计数加1
times = times + 1
todaytimes = todaytimes + 1
rs("times") = times
rs("todaytimes") = todaytimes
rs.update
end if
‘关闭记录集对象
rs.close
dim num1
dim rndnum
Randomize
%>
‘Html页面显示部分
……
<%’取最近更新的10条资料记录
sql = "select * from main,teacher where main.idofteacher=teacher.teacherid order by main.times desc"
rs.open sql,conn,1,1
‘显示最近更新的10条资料记录
for i = 1 to 10
if rs.eof then
response.write "<tr><td> </td><td> </td><td> </td><td> </td></tr>"
else
if len(rs("title")) > 10 then
filetitle = left(rs("title"),10)&"..."
else
filetitle = rs("title")
end if
%>
<tr><td align=left> <img src=images/arrow.gif>
<a href=# title="<%=rs("title")%>" onclick=javascript:showdetail(<%=rs("mainid")%>);><%=filetitle%></a>
</td><td align=center><a href=teacherinfo.asp?id=<%=rs("teacherid")%> title="查看<%=rs("teacher")%>的个人专集"><%=rs("teacher")%></a></td>
<td align=center><%=rs("times")%></td>
<td align=left> <%=rs("fenlei2")%></td></tr>
<%‘取下一条资料记录
rs.movenext
end if
next
‘关闭记录集对象
rs.close
%>
3.1.2 资料详细信息页
1. etail.asp页面示例
图3-3为显示资料详细信息的页面。
图3-3 资料详细信息
2. 页面中需要用户填写的Html表单元素。
此页无需填写Html表单元素。
3. 面所涉及的数据库表信息。
此页使用了系统中的资料信息表main和教师信息表teacher。
4. 页面代码分析
‘引用创建数据库连接对象函数文件
<!--#include file="conn.asp"-->
‘引用网站设置文件
<!--#include file="fenlei.asp"-->
<%’取得要显示资料信息的id号
id = request("id")
if id = "" then
conn.close
set conn = nothing
response.write "<script>alert('没有找到您要查看的记录');window.close();</script>"
response.end
end if
‘打开记录集对象
set rs = server.createobject("adodb.recordset")
sql = "select * from main,teacher,type where main.idofteacher=teacher.teacherid and main.idoftype=type.typeid and main.mainid="&id
‘取得资料详细信息
rs.open sql,conn,1,1
‘如果资料详细信息不存在则提示错误
if rs.bof and rs.eof then
rs.close
set rs = nothing
conn.close
set conn = nothing
response.write "<script>alert('没有找到您要查看的记录');window.close();</script>"
response.end
else
%>
‘Html页面显示部分,显示资料的详细信息
……
<%’关闭记录集对象
rs.close
set rs = nothing
‘关闭数据库连接对象
conn.close
set conn = nothing
end if
3.1.3 资料信息下载页
1. download.asp页面示例
图3-4 为阅读资料信息所看到的页面。
图3-4 阅读资料信息
2. 页面中需要用户填写的Html表单元素
此页无需填写Html表单元素。
3. 页面所涉及的数据库表信息
此页使用了系统中的资料信息表main。
4. 页面代码分析
<%’取得要显示资料信息的id号
id = trim(request("id"))
if id = "" then
conn.close
set conn = nothing
response.write "<script>alert('没有找到您要阅读的资料');window.close();</script>"
response.end
end if
sql = "select * from main where mainid="&id
set rs = server.createobject("adodb.recordset")
‘取得资料详细信息
rs.open sql,conn,1,3
‘如果资料详细信息不存在则提示错误
if rs.bof and rs.eof then
rs.close
set rs = nothing
conn.close
set conn = nothing
response.write "<script>alert('没有找到您要阅读的资料');window.close();</script>"
response.end
‘如果资料详细信息存在
Else
‘该资料阅读数加1
rs("times") = rs("times") + 1
rs.update
‘页面下载或者打开资料信息
response.redirect rs("fileurl")
‘关闭记录集对象
rs.close
set rs = nothing
‘关闭数据库连接对象
conn.close
set conn = nothing
end if
%>
3.1.4 提交回复作业页
1. redetail.asp页面示例
图3-5为提交回复作业信息所看到的页面。
图3-5 提交回复作业信息
2. 页面中需要用户填写的Html表单元素
此页中有3个表单元素,如表1所示。
表1 redetail.asp页的表单元素
名称 |
表单元素类型 |
含义 |
最大长度 |
Name |
Text |
学生姓名 |
20 |
Title |
Text |
作业标题 |
20 |
Message |
Textarea |
作业答案 |
100 |
3. 页面所涉及的数据库表信息
此页面用来显示提交回复作业信息,并没有涉及到数据库表的操作。
4. 页面代码分析
‘Html页面表单提交到redetailok.asp提交作业答案
<form action="redetailok.asp" method="post" >
‘Html页面显示部分
……
</form>
3.1.5 提交回复作业成功页
1. 页面中需要用户填写的Html表单元素
此页无需填写Html表单元素。
2. 页面所涉及的数据库表信息
此页使用了系统中的回复作业信息记录表work。
3. 页面代码分析
‘引用创建数据库连接对象函数文件
<!--#include file="conn.asp"-->
<%’学生姓名必须要输入
name = trim(request("name"))
if name = "" then
response.write "<script>alert('请输入学生姓名');history.go(-1);</script>"
conn.close
set conn = nothing
response.end
end if
if len(name) > 5 then
response.write "<script>alert('学生姓名不得超过5个汉字');history.go(-1);</script>"
conn.close
set conn = nothing
response.end
end if
‘作业标题必须要输入
title = trim(request("title"))
if title = "" then
response.write "<script>alert('请输入作业标题');history.go(-1);</script>"
conn.close
set conn = nothing
response.end
end if
‘作业答案必须要输入
message = trim(request("message"))
if message = "" then
response.write "<script>alert('请输入作业答案');history.go(-1);</script>"
conn.close
set conn = nothing
response.end
end if
‘作业的id号必须存在
reid = trim(request("reid"))
if reid = "" then
response.write "<script>alert('非法操作');history.go(-1);</script>"
conn.close
set conn = nothing
response.end
end if
sql = "select * from work where name='"&name&"' and reid="&reid
set rs = server.createobject("adodb.recordset")
‘查找作业表中是否存在学生姓名和回复作业的id号相同的记录存在
rs.open sql,conn,1,3
‘如果存在则说明学生已经提交过作业不能再提交了
if not (rs.bof and rs.eof) then
rs.close
set rs = nothing
conn.close
set conn = nothing
response.write "<script>alert('你已经提交过作业了');history.go(-1);</script>"
response.end
else
‘如果不存在则添加作业答案记录
rs.addnew
rs("reid")=reid
rs("name")=name
rs("title")=title
rs("message")=message
‘添加作业答案记录成功
rs.update
‘关闭记录集对象
rs.close
set rs = nothing
‘关闭数据库连接对象
conn.close
set conn = nothing
end if
response.write "<script>alert('添加成功');window.location.href='index.asp';</script>"
%>
3.1.6 教师基本信息页
1. teacherinfo.asp页面示例
图3-6为显示教师基本信息所看到的页面。
图3-6 显示教师基本信息
2. 页面中需要用户填写的Html表单元素
此页无需填写Html表单元素。
3. 页面所涉及的数据库表信息
此页面用来显示教师基本信息,此页使用了系统中的资料信息表main和教师信息表teacher。
4. 页面代码分析
<%’取得要显示教师信息的id号
id = trim(request("id"))
if id = "" then
conn.close
set conn = nothing
response.write "<script>alert('请不要捣乱');top.window.location.href='index.asp';</script>"
response.end
end if
‘判断用户是否是管理员
if session("admin") = "admin" then
isadmin = true
else
isadmin = false
end if
‘判断用户是否是教师
if session("teacherid") <> "" then
isteacher = true
else
isteacher = false
end if
‘取得教师详细信息
sql = "select * from teacher where teacherid="&id
set rs = server.createobject("adodb.recordset")
rs.open sql,conn,1,1
%>
‘Html页面显示部分,显示教师信息
……
<%’关闭记录集对象
rs.close
end if
‘取得栏目信息
sql = "select * from type"
rs.open sql,conn,1,1
set rs1 = server.createobject("adodb.recordset")
‘所有栏目信息
do while not rs.eof
sql1 = "select count(mainid) from main where idofteacher="&id&" and idoftype="&rs("typeid")
‘取得教师在该栏目发表的资料总数
rs1.open sql1,conn,1,1
counter = rs1(0)
rs1.close
‘发表的资料总数如果是3的倍数
if counter mod 3 = 0 then
‘定义显示资料记录的框架的高度
iframeheight = 20*(int(counter/3)+1)
else
iframeheight = 20*(int(counter/3)+2)
end if
‘框架的高度最大值为220
if iframeheight > 220 then iframeheight = 220
%>
<tr><td align="center" class="header" colspan=3>已在本站发布的<%=rs("type")%>(共<%=counter%>件)</td></tr>
<tr><td align="center" colspan=3>
‘显示资料记录的框架页
<iframe name="titleof<%=rs("typeid")%>" frameborder=0 width=100% height=<%=iframeheight%> scrolling=no src=titlelist.asp?type=<%=rs("typeid")%>&id=<%=id%>></iframe>
</td></tr>
<%’取下一个栏目
rs.movenext
loop
‘关闭记录集对象
set rs1 = nothing
‘关闭记录集对象
rs.close
set rs = nothing
%>
</table>
<%’如果用户既不是管理员也不是教师
if not isadmin and not isteacher then
%>
<!--#include file="foot.asp"-->
<%
end if
%>
</body>
</html>
<%’关闭数据库连接对象
conn.close
set conn = nothing
%>
3.1.7 资料信息搜索页
1. search.asp页面示例
图3-7为搜索资料信息所看到的页面。
图3-7搜索资料信息
2. 页面中需要用户填写的Html表单元素
此页共有5个表单元素,如表2所示。
表2 search.asp页的表单元素
名称 |
表单元素类型 |
含义 |
最大长度 |
fenlei1 |
Text |
所属学院 |
20 |
feilei2 |
Text |
所属系 |
20 |
Teacher |
Text |
教师姓名 |
10 |
Course |
Text |
相关资料 |
20 |
Titli |
Text |
资料标题 |
20 |
3. 页面所涉及的数据库表信息
此页面用来显示搜索资料信息,此页使用了系统中的资料栏目信息表type。
4. 页面代码分析
‘Html页面表单提交到list.asp
<form action="list.asp" method="post">
‘Html页面显示部分,显示要填写的搜索条件
……
</form>
3.1.8 资料信息搜索结果页
1. list.asp页面示例
图3-8为显示资料信息列表所看到的页面。
3-8 显示资料信息列表
2. 页面中需要用户填写的Html表单元素
此页无需填写Html表单元素。
3. 页面所涉及的数据库表信息
此页面用来显示资料信息列表,使用了系统中的资料信息表main和教师信息表teacher。
3.2 资料管理模块
资料管理模块包含以下子模块。
● 管理员登陆
● 资料栏目管理
● 资料信息管理
管理员登陆子模块包含以下页面。
● adminlogin.asp
● asmincheck.asp
● adminmain.asp
资料栏目管理子模块包含以下页面。
● addtype.asp
● addtypeok.asp
● edittype.asp
● edittypeok.asp
● deltype.asp
● deltypeok.asp
资料信息管理子模块包含以下页面。
● put.asp
● pubok.asp
● list.asp
● edit.asp
● editok.asp
● admindelcourseware.asp
● admindelcoursewareok.asp
各页面间的关系如图3-9所示。
3-9 各页面间的关系