计算机文化基础自动测试系统

摘    要

自动测试系统是前台应用Dreamweaver8软件,后台结合ASP编程技术开发出来的。本论文主要阐述一个功能比较强大的网上考试系统的后台操作过程及一些关键技术。利用网络和数据库技术,基于B/S模式研究开发了自动测试系统这一ASP应用程序。它是专门用于试题录入、查询、修改、删除、组卷和参加自动测试的ASP应用程序。其最大的特点是开放性、方便性和灵活性。用户可以向题库添加、修改和查询试题(卷),还可以自动新增科目并建立相应的数据表。允许用户根据自己的需求,从现有的试题库中灵活地抽取各类试题,以组建适合于自身所需的试卷。而且,自动测试试卷的难易程度和形式以及各题型分数等都由用户根据需要确定。考生通过浏览器进行有效的身份验证登录后,并要求在规定的时间内进行答题,提交后系统自动给出成绩并记入数据库中以供审核和查阅。

关键词: ASP;数据库;题库管理;试卷生成 


ABSTRACT

automatic testing system is the stage application Dreamweaver8 software, the backstage combines the ASP plait distance technique development to come out. This thesis mainly elaborates stronger on-line examination system of a function of the backstage operation process and some key techniques. Utilize electric network and the data storehouse technique, we based on, and B/S's pattern was researched and developed online examination system this ASP's application. It is being used specially the test questions to write down, Inquiry, Alteration, Leave out, Series paper and ASP's application joining the online examination. Such the largest distinguishing feature is the opening property, convenient quality and elasticity. Consumer may increase to the subject storehouse, Mend and the inquiry test questions (Paper).Still may newly gain the subject voluntarily establishes the relevant data sheet. Permits consumer on the basis of self the demand, In agilely collect different type of test questions through the now available test questions storehouse. Be fit for the examination paper that is required in order to organize to oneself. But also, hard easy degree and shape that the self-test is coiled along with the different fraction number inscribed greatly await wholly to fix through consumer on the basis of the necessaries. The examinee by means of the browser carries on valid capacity and verifies entry queen. Moreover the demand is living the stipulation time inner place carries on the answer. Refer to the automatic marking of rear system in order to feed examination and examining in bearing in mind to be laid up.

Key Words:ASP ;database; management of test papers; test paper generation

目    录

1引言

1.1选题背景

1.2 系统开发目的

1.3 系统开发所用的技术

1.3.1 数据库系统

1.3.2  ADO

1.3.3  ASP技术

2需求分析

2.1 系统需求

2.2 功能需求

2.3 性能需求

3系统分析与总体设计

3.1可行性分析

3.1.1 经济可行性

3.1.2 技术上的可行性

3.1.3 操作可行性

3.2系统总体结构设计

3.2.1硬件设备及操作系统

3.2.2系统构架

3.2.3工作方式

3.2.4 数据库的分析与设计

4  系统详细设计与实现

4.1  系统模块

4.1.1 系统首页

4.1.2 用户登录

4.2 管理员模块(后台管理模块)

4.2.1 题库和科目的管理

4.2.2 试卷的生成

4.2.3信息的发布

4.2.4成绩查询

4.3 审核模块

5软件测试

5.1 软件测试的目的

5.2 软件测试的方法

5.3 测试内容设计

5.4 测试结果

6系统维护和改进

6.1 运行维护

6.2 系统的改进与提高

7结 论

8参考文献

附录:英文翻译

致 谢

1引言

1.1选题背景

随着科学技术的飞速发展,现在很多教育机构都已经开设了网络教学,通过计算机实现异地教育和培训。现在计算机硬件技术的发展已经达到了相当高的水平。但是,教学软件的开发目前还处于起步阶段,随着这项技术的不断深入发展,就要求有更好、更完善的软件系统应用到教学当中去,这就给软件设计人员提出了更高的设计要求。

教学软件的开发包括很多环节,例如教学系统、答疑系统和考试系统等等。其中很重要的一个环节就是自动测试系统。在我国,虽然教学已经蓬勃地发展起来,但是目前学校与社会上的各种考试大都采用传统的考试方式,在此方式下,组织一次考试至少要经过五个步骤,即人工出题、考生考试、人工阅卷、成绩评估和试卷分析。显然,随着考试类型的不断增加及考试要求的不断提高,教师的工作量将会越来越大,并且其工作将是一件十分烦琐和非常容易出错的事情,可以说传统的考试方式已经不能适应现代考试的需要。随着计算机应用的快速发展,应用不断扩大,人们迫切要求利用网络技术来进行自动测试,以减轻教师的工作负担及提高工作效率,与此同时也提高了考试的质量,从而使考试更趋于公证、客观,更加激发学生的学习兴趣。例如目前许多国际著名的计算机公司所举办的各种认证考试绝大部分采用这种方式。

自动测试系统是现阶段研究开发的一个热点。它是建立在国际互联网上的应用系统,客户端的配置可以极为简单,使考试不受地域的局限。一个完备的自动测试系统可以使用户在网上学习过后及时检验自己的学习效果,发现自己的不足,使得学习效率得到很大提高。自动测试系统中题目的生成、试卷的提交、成绩的批阅等都可以在上自动完成。相对于传统的考试方式,自动测试系统可以给考试者带来很大的方便:第一,管理员可以动态地管理各种考试信息,只要设计好考试试题,就可以自动生成考试试卷;第二,考试时间灵活,考生可以在规定的时间段内参加考试;第三,阅卷迅速,在考试完毕后,可以迅速给出考试成绩,给考生以最大的公平感。这样一来,教师所要做的只是精心设计题目、维护题库,而不是组织考试,从而大大减轻了教师的负担,这表明其经济性是相当可观的。为了适应新形势的发展,我进行了这一系统的初步设计工作,也可以说是做一个初步的探索,希望它能够在各类考试中发挥高效、便捷的作用,把老师从繁重的工作中解脱出来!

1.2 系统开发目的

现阶段,学校与社会上的各种考试大都采用传统的考试方式,在此方式下,组织一次考试至少要经过五个步骤,即人工出卷、考生考试、人工阅卷、成绩评估和试卷分析。显然,随着考试类型的不断增加及考试要求的不断提高,教师的工作量将会越来越大,并且其工作将是一件十分繁琐和非常容易出错的事情,可以说传统的考试方式已经不能适应现代考试的需要。随着计算机应用的迅猛发展,网络应用不断扩大,如远程教育和虚拟大学的出现等等,且这些应用正逐步深入到千家万户。人们迫切要求利用这些技术来进行自动考试,以减轻教师的工作负担及提高工作效率,与此同时也提高了考试的质量,从而使考试更趋于公证,客观!更加激发学生的学习兴趣。例如目前许多国际著名的计算机公司所举办的各种认证考试绝大部分采用这种方式。为了适应新形势的发展,在做这次毕业设计时,我选择了网上考试系统,使其尽快在各类考试中发挥高效、便捷的作用,把老师从繁重的工作中解脱出来!

1.3 系统开发所用的技术

1.3.1 数据库系统

后台数据库系统使用微软的Microsoft SQL Server 2000。SQL Server是微软公司在Windows系列平台上开发的数据库,是一个功能完备的数据库管理系统。它包括支持开发的引擎、标准的SQL语言、扩展的特性(如数据复制、OLAP分析)等功能,支持存储过程、触发器等特性。SQL Server采用客户端/服务器(Client/Server,C/S)体系结构,在使用SQL Server时,实际使用客户机程序和数据库服务器。

SQL Server 2000在性能、处理能力方面有了很大提高,更注重安全性、高可用性、集成的管理工具等,并具有下面几个新特性和重要改进之处:①支持XML;②用高级语言编写数据库对象;③自定义数据类型;④与ADO.NET2.0紧密结合;⑤增强的SQL;⑥数据库镜象;⑦全文索引增强;⑧管理、监控、开发工具的集成和增强;⑨存储引擎的改进。

1.3.2  ADO

对于用本机代码编写的应用程序,ADO为 OLE DB 数据提供程序提供基于 COM 的应用程序级别接口。ADO支持各种开发需要,包括使用与关系数据库和其他存储区中的数据的活连接来创建前端数据库客户端和中间层业务对象。而且,ADO 可构建客户端记录集、使用松耦合记录集、处理 OLE DB 的数据整形行集合。

数据访问连接 ADO 支持到数据库的显式连接。在 ADO 中,记录集可在用户通读数据库中的数据时使用打开的连接并保持锁定,或者使用客户端游标记录集,这样可在不保留数据库连接的情况下处理数据。

数据滚动 ADO 既可按顺序浏览数据,也可不按顺序浏览数据。ADO 记录集支持高速、只能向前、只读的服务器端游标。ADO 记录集唯一支持可滚动、可更新的服务器端游标,尽管这种游标使用服务器资源,并且大多数情况下可以更好地以存储过程中的逻辑的形式实现,或者以松耦合的客户端游标的形式实现。

ADO(ActiveX Data Objects)是一种操作Microsoft所支持的数据库的新技术。在ASP中,ADO可以看作是一个服务器组件(Server Component),更简单点说,是一系列的对象,应用这些功能强大的对象,即可轻松完成对数据库复杂的操作。本文中个性化页面的实现便大量地用到了ADO技术。具体的操作步骤可以归纳为以下几步:

1.创建数据库源名(DSN)

2.创建数据库链接(Connection)

3.创建数据对象

4.操作数据库

5.关闭数据对象和链接

1.3.3  ASP技术

ASP(Active Server Pages动态网页)是微软公司推出的一种用以取代CGI(Common Gateway Interface通用网关接口)的技术。目前,Internet上的许多基于Windows平台的Web站点已开始应用ASP来替换CGI。 简单地讲,ASP是一个位于服务器端的脚本运行环境,通过这种环境,用户可以创建和运行动态的交互式Web服务器应用程序,如交互式动态网页,包括使用HTML表单收集和处理信息,上传与下载等等。由于ASP是在服务器端解释、执行,开发者可以不必考虑浏览器是否支持ASP;同时由于它在服务器端执行,开发者也不必担心别人下载程序从而窃取编程逻辑。 ASP通过后缀名为.asp的ASP文件来实现,一个.asp文件相当于一个可执行文件,因此必须放在Web服务器上有可执行权限的目录下。当用户从浏览器输入了.asp文件的地址后,浏览器就将这个URL请求发给Web Server,如果Web Server上装了ASP,就调用ASP。ASP读出相应.asp文件,解释并执行命令,动态生成一个HTML页面回传Web Server,然后Web Server再把结果发送给浏览器。

2需求分析

2.1 系统需求 

近几年,随着计算机技术的发展和互联网时代的到来和飞速发展,我们已经进入了信息时代,也有人称为数字化时代,在这数字化的时代里,学校传统的管理方法和办学水平都受到了极大的挑战。Internet技术持续迅猛的发展,也给传统的考试方式提出了新的模式——利用网络的自动测试。相对于传统的考试方式,自动测试可以给考试者带来很大的方便:第一,管理员可以动态地管理各种考试信息,只要设计好考试试题,就可以自动生成考试试卷;第二,考试时间灵活,考生可以在规定的时间段内参加考试;第三,阅卷迅速,在考试完毕后,可以迅速给出考试成绩,给考生以最大的公平感。

自动测试系统开发时应该满足:

  1. 全面综合考虑多方面的因素,统筹兼顾。
  2. 最大限度的提高工作效率。
  3. 方便、易操作、快捷的原则。
  4. 对于不同的用户应该有不同的使用权限,方便管理。

2.2 功能需求 

自动测试系统的主要目的是要提高教师的工作效率,具有自动生成试卷功能,可以及时阅卷,也可对题库进行管理等功能。该系统可以基本满足教育机构的需求,实现低成本、高效率的办公宗旨。一个典型的自动测试系统需要具备以下基本功能:

1.系统登录验证功能。

2.用户注册功能。

3.用户修改密码功能。

4.系统题库管理功能。

5.试卷管理功能。

6.系统新闻管理功能。

7.考试信息发布功能。

2.3 性能需求 

系统的运行对运行环境的要求如下。

1.硬件要求

处理器:Inter Pentium43.06GX或更高;

内存:256MB以上;

硬件空间:20GB以上;

显卡:SVGA显示适配器。

2.软件环境

操作系统:Windows NT/2000/XP。

数据库:Microsoft SQL Server 2005。

操作系统对使用ASP.NET开发本系统的影响不是很大,但性能好些的操作系统可以使得系统运行地更流畅,减少系统崩溃的可能性。因此,本系统开发采用Windows XP Professional版。

3系统分析与总体设计

3.1可行性分析

也称为可行性研究,是在系统调查的基础上,针对新系统的开发是否具备必要性和可能性,对新系统的开发从技术、经济、社会的方面进行分析和研究,以避免投资失误,保证新系统的开发成功。可行性研究的目的就是用最小的代价在尽可能短的时间内确定问题是否能够解决。该系统的可行性分析包括以下几个方面的内容。

3.1.1 经济可行性

主要是对项目的经济效益进行评价,本系统作为一个毕业设计,无需开发经费,因此在经济上是可以接受的,并且本系统实施后可以显著提高考试效率,有助于学院完全实现网络化管理。所以本系统在经济上是可行的。

3.1.2 技术上的可行性

技术上的可行性分析主要分析技术条件能否顺利完成开发工作,硬、软件能否满足开发者的需要等。该管理系统采用了当前新兴的Client/Server模式进行开发。结合了Internet/Intranet技术。数据库服务器选用微软公司的SQL Server数据库,它能够处理大量数据,同时保持数据的完整性并提供许多高级管理功能。它的灵活性、安全性和易用性为数据库编程提供了良好的条件。因此,系统的软件开发平台已成熟可行。硬件方面,科技飞速发展的今天,硬件更新的速度越来越快,容量越来越大,可靠性越来越高,价格越来越低,其硬件平台完全能满足此系统的需要。

3.1.3 操作可行性

所开发的智能考试系统可适用于各企事业单位,其功能比较完善、界面美观简洁、便于操作。并且我们开发出此软件后可立即投入使用。所以,在操作方面是可行的。

综上所述,此系统开发目标已明确,在技术和经济等方面都可行,并且投入少、见效快。因此系统的开发是完全可行的。

3.2系统总体结构设计

软件系统总体结构设计的主要任务就是将整个系统合理的划分成各个功能模块,正确处理模块之间与模块内部的联系及它们之间的调用关系和数据联系,定义各模块的内部结构等,本系统的软件总体结构按分解-协调的原则,信息隐蔽抽象的原则,自顶向下的原则,一致性原则,面向用户的原则进行设计。

3.2.1硬件设备及操作系统

服务器:要装有数据库软件sql server2000并配置好IIS。

操作系统:Windows xp。

客户端:机型:奔腾四代1.6G以上,硬盘:40G以上(至少需要250M自由空间,以运行操作系统和本系统) 软驱:3.5′/1.44MB,内存:256M以上,Windows98以上操作系统,安装Web浏览器。

网络:服务器和客户端应有网络连通。配置TCP/IP协议。

数据库:Sql server2000

3.2.2系统构架

开发这个系统的目的就是帮助学校、企业或机关单位的主管考试部门提高工作效率,实现企业考试信息管理以及考试流程的系统化、规范化和自动化。系统最终实现的主要功能如下:

系统管理设置部分:科目的管理、题库的管理、试卷的生成、信息发布。

考场控制:系统控制考试时间、防刷新、考试成绩自动生成。

用户管理部分:由管理员浏览用户信息库里面的部分信息,用户可以查询自己所参加的所有考试成绩。

图3-1为本系统的大体功能模块图。

图3-1  考试系统功能模块图

3.2.3工作方式

如图3-2所示,自动考试系统建立在系统后台的数据库的基础上,用户(包括普通用户、系统管理员、审核人员)可以方便地通过Internet轻松设置参加考试。

图3-2 自动考试系统应用原理示意图

3.2.4 数据库的分析与设计

智能考试系统数据库采用Microsoft SQL SERVER,数据库中表及其作用如下:

(1)用户信息表(cadre_info):用于存储所有用户的信息(包括:考号、考生姓名、密码、职务信息、管理员权限)

(2)部门信息表(department):为了考试的分部门管理以及查询所建立的部门信息表(包括:部门名称)

(3)考试科目信息表(exam_subject):为存储考试的科目信息所建立的科目信息表(包括:科目编号、科目名称)

(4)新闻信息表(exam_news):考试信息发布需要存储新闻信息所建立的新闻信息表(包括:新闻编号、标题、正文内容、创建人、审核发布人、创建日期、审核通过的发布日期)

(5)题库信息表(exam_database):为了存储题库所建立的题库信息表(包括:题目编号、题干、选项、正确答案、考试时是否以被选过的标记)

(6)考试信息表(exam_test):存储管理员已经制定了的考试所建立的考试信息表(包括:考试编号、各科目数量、各科目分值、考试时间、创建者、审核者、开始日期、结束日期、设置日期)

(7)考生信息表(exam_testuser):为存储每次参加考试又那些考生所建立的考生信息表(包括:考生考号、考试编号、是否考过标记)

(8)等待通过的项目信息表(waitforpass):为存储等待通过的项目(包括考试和要发布的新闻)所建立的项目信息表(包括:等待通过的项目类别、编号、审核者、审核日期、是否通过)

(9)考试成绩信息表(exam_score):为存储每个考生的考试成绩信息所建立的成绩信息表(包括:考生的各种信息、考试信息、考试成绩)

(10)考试新闻系统登录信息表(exam_news_log):用来查看没有浏览新闻的考生所建立的日志表(包括:新闻编号、登录用户)

根据系统功能设计要求及功能模块的划分,数据库需要的存储的信息如下:E-R(Eneity-Relationship Approach)图是最常用的概念模型表示方法,也是数据库的核心和基础,它是按用户的观点来对数据和信息建模,依据概念模型设计应具的特点:真实性、易理解性、易修改性、易转换性,系统数据库的E-R图如图3-3所示。

图3-3  系统数据库E-R图

根据这些功能要求,我的同组同学吴婷婷在SQL server 2000里创建了相应的数据库。 

4  系统详细设计与实现

该考试系统设有两种不同权限类型的用户,第一种是只能参加考试的普通考生,第二种是可对试题、成绩、新闻、考生和教师信息等进行管理的系统管理员。该系统可实现考生在线答题,管理员在线录题及生成试卷,系统管理维护,共分为五大主要子系统:新闻模块,登陆,考试模块,领导审核,后台管理。在本次毕业设计中我主要负责前台设计和系统管理员模块的设计。

其各个模块的具体功能如下:

 (1)进入考试系统

输入管理员或普通用户的ID和密码,以普通用户的身份进入系统时选择要考试的科目,以管理员的身份进入系统,这时页面上方的导航条已经改变,增加了科目管理、试卷管理、生成试卷、新闻发布等选项。

(2)首页

系统的首页主要使用框架搭建,主要分为四个部分:顶部工具条、左侧用户信息栏、右侧中部系统时间信息栏、右下侧是用户所选的功能模块界面默认为的考试新闻信息栏。

(3)新闻页面

关于发布以及显示考试方面(如:考试科目,考试时间等)的相关信息,考场纪律及注意事项。

(4)登录

登录界面需要让用户输入用户名、密码,以及进入系统的身份(考生和系统管理员)。如果输入错误还要返回该页面,程序还要判断是否因为错误登录信息而造成的再次进入,如果是还要显示错误信息。

(5)考试模块

<1>考试模块:只有一个考试的列表,表格的每一列的内容分别是:序号、考试科目、考试时间、操作(进入考场的链接)。

<2>成绩查询:本页面可提供对考生以往考试成绩的多功能查询功能,这里可显示考生以往的考试成绩。页面的实现基本上同题库的实现页面相同。

(6)领导审核

项目的审核:进入此界面后,在新闻的下方有系统提示的审批请求,单击进入审批页面。审批内容包括考试计划和考试新闻的审批,如果考试信息审核通过则考试按照计划执行,如果新闻审核通过则新闻发布。如果提交的信息未通过则考试信息和新闻不发布。

 (7)后台管理

系统管理员界面的首页与普通用户的公共首页基本上一样,只是上方的工具栏发生变化,管理员工具条增加了对系统数据库维护的几个选项。

<1>科目管理:主要实现对考试科目的添加、删除等功能。本次设计只有计算机文化基础。

<2>题库管理:主要的功能是实现试题内容的添加、修改、删除、查询等操作以及对现有试题库的科目、题型的浏览。首先要实现的是页面中的操作有效性提示部分,其次题库的显示可以按照科目题型分类和按照关键字显示,这里采用一个提供选项的表单。最后是显示已有的题库。由于题库的容量庞大,所以采用分页显示。

<3>生成试卷:管理先向系统提交想要生成的试卷的各种信息,这个信息须通过领导审批才能作为一次正式的考试。本系统处理试卷的生成总共需要三部分:第一步,管理员需要向系统提交试卷的基本信息。在页面中添加一个表单,在表单内插入一个表格,表格内输入考试的题目、题型、数目、各题的分值、考试的有效期。第二步,管理员需要向系统提交参加考试的人员名单以及审核考试信息的领导姓名。只要在页面中添加一个两行的表格,第一行显示的内容分别为:编号、姓名、职务、部门、单位。名单的显示是通过调用系统用户表生成的,这样可以方便的组织某一部门的考试。审核领导的名单是通过对系统用户的职务级别判断产生的。第三步,管理员确认所有信息无误后将所有考试信息存入数据库,生成试卷成功。制卷逻辑流程如图4-1所示。

图4-

1 制卷逻

辑流程图

<4>信息发布:管理员添加考试新闻(如:科目的考试通知等)需要填写的内容有标题、正文、有效期、审核领导和姓名。审核领导姓名通过查询数据表自动形成。管理确认提交后,系统将信息加入数据库。当一条考试计划或者考试新闻成功添加以后,管理员在这个项目通过审批前有权取消计划。审核功能流程如图4-2所示。

图4-2 审核功能流程图

4.1  系统模块

4.1.1 系统首页

本系统的主页有两种类型,分别是考试主页和管理主页。

考试主页是用户进入系统页面,主要功能是为用户提供登录和注册界面,并显示考试系统的新闻状态。主页面功能是由default.asp文件实现的,此文件使用的是框架搭建的,主要分为四部分:顶部工具条、左侧用户信息栏、右侧中部系统时间信息栏、右下侧是用户所选的功能模块界面默认为的考试新闻信息栏。并分别由四个文件构成:righttopframe.asp、toolbar.asp、news.asp、leftframe.asp。

管理主页是指系统管理员的管理主页,其功能是显示用户信息和管理功能导航,并显示考试新闻动态。管理主页功能是由文件admindefault.asp实现的,和登录主页一样,此页面也是框架页面,分别由以下四个页面文件构成:admintoolbar.asp、adminleftframe.asp、adminrighttopframe.asp、news.asp。

4.1.2 用户登录

用户在登录表单输入登录信息后,系统将检验用户信息,并自动判断该用户身份。如果信息正确并且是管理员,则将进入管理主界面;如果是普通用户,则进入考试主界面;如果输入的用户信息不正确,则将不能进入考试系统,返回该页面。用户登录页面如图4-3的页面左侧所示

图4-3 用户登录页面

在用户登录界面还为首次进入系统的新生提供了注册功能,其代码实现如下:

<p align="center" class="STYLE2">用户注册</p>

<form method="POST" action="checkres.asp"><div align="center">

<table border="1" cellpadding="4" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="500" background="32.gif"><tr>             

<td width="100" align="right">ID</td>

<td width="200"><input type="text" name="UserId" size="20" style="height: 22; border-style: solid; border-width: 1px" class="line">

</tr><tr><td width="100" align="right">姓名</td>

<td width="200"><input type="text" name="UserName" size="20" style="height: 22; border-style: solid; border-width: 1px" class="line"></td>

<td width="100" align="right">密码</td>

<td width="200"><input type="text" name="Pwd" size="20" style="height: 22; border-style: solid; border-width: 1px" class="line"></td>

<td width="100" align="right">系别</td>

<td width="200"><select name="Department" size="1" style="border: 1px solid #000000" class="line">

<option value="计算机系" selected>计算机系</option>

<option value="汽车工程">汽车工程系</option>

<option value="电子商务">电子商务</option></select></tr><tr>

<td width="100" align="right">所在单位</td>

 <td width="200"><input type="text" name="Office" size="20" style="height: 22; border-style: solid; border-width: 1px" class="line"></td>

<td width="100" align="right">职务</td>

<td width="200"><input type="text" name="Duties" size="20" style="height: 22; border-style: solid; border-width: 1px" class="line"></td>

<td width="100" align="right">权限</td>

<td width="200"><select name="Department" size="1" style="border: 1px solid #000000" class="line">

<option value="教研室主任" selected>教研室主任</option>

<option value="学生">学生</option> </select> </tr>

用户注册效果如图4-4所示

图4-4 用户注册页面

4.2 管理员模块(后台管理模块)

系统管理员界面的首页与普通用户的公共首页基本上一样,只是上方的工具栏发生变化(如图3-2),增加了对系统数据库维护的几个选项。如,科目管理,题库管理,试卷生成,消息发布等操作。

图3-2 管理员登录页面

4.2.1 题库和科目的管理

(1)科目管理 :主要的功能是实现对科目的添加和删除操作以实现对所添加或删除科目进行试题的添加和科目的删除。首先要实现的是科目的添加,并将添加的科目显示,然后对所有的科目可以进行选择删除。

(2)题库的管理 :主要由文件admindatabase.asp, admindatabaseedit.asp, admindatabaseadd.asp来实现对试题内容的添加、修改操作以及对现有试题库的科目、题型的浏览。首先要实现的是页面中的操作有效性提示部分,其次题库的显示可以按照科目题型分类显示,这里采用一个提供选项的表单。最后是要显示已有的题库。其重要功能及代码分析如下:

<1>试题浏览由admindatabase.asp文件实现

subjectview=request("subjectview")

typeadd=request("typeadd")

mykey=request("mykey")

if subjectview="--选择科目--" or subjectview="" then  subjectview="%"

end if

if typeadd="--题型--" or typeadd="" then  typeadd="%"

end if

if mykey= "--关键字--" or mykey="" then  mykey="%"

end if

PageCount=0

sql="select * from exam_database where subject like '"& subjectview &"' and type like '"& typeadd &"' and question like '" & mykey &"'  order by id desc"

set rs=conn.execute(sql)

while not rs.eof

PageCount=PageCount+1

rs.movenext

wend

sql="select * from exam_database where subject like '"& subjectview &"' and type like '"& typeadd &"' and question like '" & mykey &"'  order by id desc"

set rs=server.createobject("adodb.recordset")

rs.open sql,conn,3,2

on error resume next

此文件的运行界面如图4-3所示

图4-3 题库管理页面

<2>试题添加:选择科目和题型后,单击添加题目按钮,可以进入题目添加页面。此页面效果是由文件admindatabaseadd.asp实现的,其显示效果如图4-4:

图4-4 添加试题页面

从图4-4的显示效果可以看出,文件admindatabaseadd.asp的功能是首先根据获取的题型参数来显示相应的试题添加表单页面。管理员输入相应的数据后,单击保存按钮,执行文件save.asp新的试题将添加到系统库中。其主要代码如下:(以添加判断题为例)

subjectview=request("subjectview")

typeadd=request("typeadd")

if typeadd="判断题" then

  sql="select * from exam_database"

  set rs=server.createobject("adodb.recordset")

  rs.open sql,conn,3,2

  rs.addnew

  rs("subject")=subjectview

  rs("type")=typeadd

  rs("question")=request("question")

  rs("answer")=request("answer")

  rs.update

  topage="admindatabaseadd.asp?subjectview=" & subjectview & "&typeadd=" & typeadd & "&str=添加成功!请继续添加题目!"

  response.redirect topage

end if

<3>查看/编辑试题:单击试题后面对应的编辑链接,进入试题编辑页面,效果如图4-5所示

图4-5试题查看/编辑页面

图4-5所示的效果是由admindatabaseedit.asp文件实现,其功能是首先获取所编辑试题的类型,然后根据类型显示相关表单信息。用户输入编辑的数据,单击保存按钮后,系统将调用admindatabasesaveedit.asp文件。将用户输入的编辑后的数据保存到系统库中。其主要代码如下所示:(同样以判断题为例)

id=request("id")

subjectview=request("subjectview")

typeadd=request("typeadd")

if typeadd="判断题" then

  sql="select * from exam_database where id="& id

  set rs=server.createobject("adodb.recordset")

  rs.open sql,conn,3,2

  rs("subject")=subjectview

  rs("type")=typeadd

  rs("question")=request("question")

  rs("answer")=request("answer")

  rs("difficult")=request("difficult")

  rs.update

end if

<4>由于题库的容量庞大,所以必须采用分页显示。它的实现过程是这样的:首先需要定义每页最多显示试题的数目,然后对页数进行赋值,并循环读取当前页数,如果当前页数<=1,则在第一页显示,如果当前页数>赋值页数,则在下一页显示。其实现代码如下:

PageSize = 10

PageCount=(PageCount+PageSize-1)\PageSize

Page = CLng(Request("Page"))

If not Page >1 Then Page = 1

If Page > PageCount Then Page = PageCount

i=page+(page-1)*9

rs.AbsolutePage = Page

For iPage = 1 To PageSize

4.2.2 试卷的生成

一套试卷是由不同层次、不同难度和不同范围的一定数目的试题所组成,这些基本信息正是构成试卷的主要元素。而试卷基本信息的管理即对要生成的试卷的基本信息按照教师意愿进行录入的功能模块,以便在生成试卷的时候能够根据这些基本信息在题库中进行随机选题。该模块主要由admincreatepaper1.asp,admincreatepaper2.asp这两个文件实现。各个功能介绍及对应文件如下:

(1)试卷基本信息的录入:单击试卷生成链接后将进入生成试卷的第一步,其重要功能及代码分析如下:

<1>科目选择及试题的难度系数:科目的选择要在已有的考试科目中选取一个,并根据参加考试学生的条件选择难度系数。其实现代码如下:

<select size="1" name="subject">

  <option selected>--选择科目--</option><% sql="select * from exam_subject"

      set rs=server.createobject("adodb.recordset")

      rs.open sql,conn,3,2

      do while not rs.eof %>

   <option  value="<%=rs("exam_subject")%>"><%=rs("exam_subject")%></option>

      <% rs.movenext

      loop

      rs.close %></select>

<td>难度系数</td>

      <td align="left"><select name="difficult" size="1">

        <option value="1">1</option> <option value="2">2</option>

        <option value="3">3</option> </select>

其显示效果如图4-6所示:

图4-6  试卷生成的第一步效果图

<2>试卷信息的设计(包括卷面总分,题型分布,考试时间及有效期的设计)

<b>卷面总分(<font color="#FF0000">分</font>)</b>

  <td colspan="3">     <p align="left">

   <input type="text" name="totalper" size="20" value="<%=request("totalper")%>" class="inputnormal" readonly>

      <tr height="20">

      <td align="center" bgcolor="#e1e1e1">

      <p align="center"><b>单选题</b></td>

      <p align="center"><b>多选题</b></td>

      <p align="center"><b>判断题</b></td> </tr>

    <tr height="20">

   <td align="center" "><b>题型分布(<font color="#FF0000">个</font>)</b></td>

<td> <p align="center">

<input type="text" name="singlecount" size="12" value="<%=request("singlecount")%>" class="inputnormal" readonly></td>

  <td> <p align="center">

 <input type="text" name="multicount" size="12" value="<%=request("multicount")%>" class="inputnormal" readonly></td>

 <td><p align="center">

<input type="text" name="judgecount" size="12" value="<%=request("judgecount")%>" class="inputnormal" readonly></td>

<td align="center"><b>分值分布(<font color="#FF0000">分</font>)</b></td>

   <td> <p align="center">

<input type="text" name="singleper" size="12" value="<%=request("singleper")%>" class="inputnormal" readonly></td>

      <td> <p align="center">

<input type="text" name="multiper" size="12" value="<%=request("multiper")%>" class="inputnormal" readonly></td>

      <td> <p align="center">

<input type="text" name="judgeper" size="12" value="<%=request("judgeper")%>" class="inputnormal" readonly></td>

   <td align="center"colspan="4"><b>考试时间设定</b></td>

<td align="center"><b>考试时间(<font color="#FF0000">小时</font>)</b></td>

   <td colspan="3"> <p align="center">

<input type="text" name="testtime" size="12" value="<%=request("testtime")%>" class="inputnormal" readonly></td>

<td align="center"><b>有效期</b></td>

<td colspan="3"><p align="center">

<input type="text" name="starttime" size="20" value="<%=request("starttime")%>" class="inputnormal" readonly>—<input type="text" name="endtime" size="20" value="<%=request("endtime")%>" class="inputnormal" readonly></td>

<3>参考人群,审核人的设定。其中在选择参考人群的时候,页面可以根据用户选择的部门自动列出考试用户信息,供管理员选择哪些人员可以参加该考试。默认的时候是选择所有的部门,也可以从所有部门里选取特定的用户,此时可以判断列表项是选择的是哪一个部门,根据此部门的id在cadre_info表中查询出user_ID等于此id的用户信息,并用循环依次列出每个用户及其详细信息。根据特定的条件来选择

审核人员,并在用户点击“生成试卷”时判断用户是否已经选择了审核人,若没有选择则弹出出错对话框。其效果如图4-7所示:

图4-7  试卷生成的第二步效果图

选择参考人员代码如下:

<p align="center"><b>确定参加考试人员</b>

      <select size="1" name="sdepartment" onChange="this.form.submit();">

      <option selected>所有部门</option>

      <% sql="select * from department"

      set rs=server.createobject("adodb.recordset")

      rs.open sql,conn,3,2

      do while not rs.eof %>

      <option value="<%=rs("department")%>"><%=rs("department")%></option>

      <% rs.movenext

      loop

      rs.close %></select></td>

      <p align="center"> </td>

      <td bgcolor="#EFEFEF"><b>  姓名</b></td>

      <td bgcolor="#EFEFEF"><b>  职务</b></td>

     <td bgcolor="#EFEFEF"><b>  部门</b></td>

      <td bgcolor="#EFEFEF"><b>  单位</b></td>

    </tr><% sdepartment=request("sdepartment")

      response.write department

      if sdepartment="所有部门" or sdepartment="" then

      sql="select * from cadre_info"

      else

      sql="select * from cadre_info where department='" & sdepartment & "'"

      end if

      set rs=server.createobject("adodb.recordset")

      rs.open sql,conn,3,2

      do while not rs.eof %>

  <td><input type="text" name="chkall" size="10" value="<%=rs("userid")%>" class="inputnormal" readonly></td>

<input type="checkbox" name="userid" value="<%=rs("userid")%>" checked></td>

      <td>  <%=rs("username")%></td>

      <td>  <%=rs("duties")%></td>

      <td>  <%=rs("department")%></td>

      <td>  <%=rs("office")%></td>

    </tr>

<% rs.movenext

      loop

      rs.close %>

根据特定的条件选择审核人:当管理员输入完基本信息后,需要向上级领导也就是教研室主任提交进行审批,并且只有教研室主任才可以审批。其实现代码如下:

  <select size="1" name="shenhr">

    <option value="选择审核人">选择审核人</option>

    <% sql="select * from cadre_info where rank='教研室主任'"

set rs=server.createobject("adodb.recordset")

rs.open sql,conn,3,2

do while not rs.eof %>

    <option value="<%=rs("userid")%>"><%=rs("username")%></option>

    <% rs.movenext

      loop

      rs.close %>

  </select>

<4>为防止用户还没有输入信息就进入下一步,在文件头中我们设计了页面控制功能函数来控制用户的动作,在用户点击“下一步”按钮时就触发设定的函数对其进行检查,在该页面中主要包括:防止用户未选择科目,确定已修改考试时间且开始时间要小于结束时间,使卷面总分与设定的总分相同。对于防止用户未选择科目,可以在初始界面中就默认为显示“选择科目”,当用户点击“下一步”按钮时,就进入指定函数进行判断,看列表框的value值是否等于“选择科目”,若等于就出错,弹出出错对话框,并返回该界面重新输入。对于确定已修改考试时间且开始时间要小于结束时间,在初始时使开始时间与结束时间相同,当用户点击“下一步”按钮时,就进入指定函数进行判断,若开始时间小于或等于结束时间就出错,弹出出错对话框,并返回该界面重新输入。对于要使卷面总分与设定的总分相同,当用户输入各个分值或点击“下一步”按钮后,就进入指定函数进行判断,将每种题型的题目数乘以该题型每题的分值,并将各种题型的总分相加得实际的总分,若不等于页面输入的总分值就出错,弹出出错对话框,并返回该界面重新输入。

4.2.3信息的发布

信息发布主要实现考试计划或者考试新闻等相关信息的发布。管理员添加考试新闻需要填写的内容有标题、正文、有效期、审核领导和姓名。审核领导姓名通过查询数据表自动形成。管理确认提交后,系统将信息加入数据库。当一条考试计划或者考试新闻成功添加以后,管理员在这个项目通过审批前有权取消计划。其功能的实现是由文件postnew.asp和savenew.asp实现的。前者的功能是为用户提供信息发布表单,后者的功能是将用户输入的信息保存到系统库中。实现该页面的主要代码如下:

<form name="newsform" method="POST" action="savenews.asp"

onSubmit="return submitit();">

    <tr><td width="80" height="30" align="right"

background="images/32.gif" bgcolor="#EFEFEF">新闻标题:</td>

    <td width="480"><input type="text" name="title" size="75"

onBlur="this.className='inputnormal'"

onFocus="this.className='inputedit';this.select()"

class="inputnormal"></td> </tr><tr>

  <td height="240" align="right" background="images/32.gif"

bgcolor="#EFEFEF"><p align="center">新闻正文:</td>

  <td><textarea rows="15" name="text" cols="65"

class="inputnormal"></textarea></td>

  </tr><tr><td height="30" align="right" background="images/32.gif"

bgcolor="#EFEFEF">有效期:</td>

<td><input type="text" name="youxq" size="12" onKeyUp="if(isNaN

(this.value)) this.value='';" onBlur="this.className='inputnormal'"

onFocus="this.className='inputedit';this.select()"

class="inputnormal"></td>

  </tr><tr><td height="30" align="right" background="images/32.gif"

bgcolor="#EFEFEF">送交谁审核:</td>

      <td><select size="1" name="shenhr">

      <option></option>

      <% do while not rs.eof %>

      <option value="<%=rs("userid")%>"><%=rs("username")%></option>

      <% rs.movenext

      loop

      rs.close %></select></td>

    </tr><tr><td width="100%" cols="2" colspan="2">

<p align="center"><input type="submit" value="提交" name="B1" class="s02"> 

<input type="reset" value="重置" name="B2" class="s02"></td> </tr> </form>

其运行效果如图4-8所示:

图4-8新闻发布页面

4.2.4成绩查询

本功能在系统管理员页面可以查询未审批的考试科目以及考试成绩和考生是否参加考试的记录。系统管理员实现成绩查询的主要代码分析如下:

 <p align="center"><b>考试时间</b></td>

 <p align="center"><b>考试科目</b></td>

<td align="center" bgcolor="#E1E1E1"><b>设定人</b></td>

 <td align="center" bgcolor="#E1E1E1"><b>批准人</b></td>

 <td colspan="2" align="center" bgcolor="#E1E1E1">操作</td>

 </tr><%  subject=request("subject")

if subject="--选择科目--" or subject="" then  sql="select * from exam_test "

else  sql="select * from exam_test where subject='"& subject &"' "

end if

set rs=server.createobject("adodb.recordset")

rs.open sql,conn,3,2

on error resume next

rs.PageSize = 10                //分页显示

Page = CLng(Request("Page"))

If Page < 1 Then Page = 1

If Page > rs.PageCount Then Page = rs.PageCount

i=page+(page-1)*9

rs.AbsolutePage = Page            

For iPage = 1 To rs.PageSize%><tr><td><%=i%></td>      

<td align="center"><%=formatdatetime(rs("starttime"),1)%> — 

<%=formatdatetime(rs("endtime"),1)%> </td>

   <td align="left"> <%=rs("subject")%></td>

   <% sql1="select * from cadre_info where userid="& rs("setuserid")

   set rs1=server.createobject("adodb.recordset")

   rs1.open sql1,conn,3,2 %>

   <td align="center"><%=rs1("username")%><% rs1.close %> </td>

   <% sql1="select * from cadre_info where userid="& rs("passuserid")

   set rs1=server.createobject("adodb.recordset") rs1.open sql1,conn,3,2%>

   <td align="center"><%=rs1("username")%><% rs1.close %> </td>

   <td align="center" width="60">

   <a href="displayscore.asp?testid=<%=rs("testid")%>">考试成绩</a></td>

<td align="center" width="60"><a href="testlog.asp?testid=<%=rs("testid")%>

&starttime=<%=formatdatetime(rs("starttime"),1)%>&endtime=<%=formatdatetime(rs("endtime"),1)%>&subject=<%=rs("subject")%>">考试记录</a></td></tr>

<% rs.MoveNext

If rs.EOF Then Exit For

i=i+1

Next%> <caption></caption> </table></form>

其运行界面如图4-9所示:

图4-9  管理员成绩查询页面

4.3 审核模块

审批模块的管理主要是对管理员定制的试卷和发布的新闻进行审核。实现该功能的页面有:news.asp,passit.asp,unpass.asp,savepass.asp等。由于考虑到权限的问题,该功能由部门领导或院领导调用。首先用户登录系统后将根据用户id号判断该用户是否具有调用该功能的权限,若有则在新闻页面news.asp中显示系统提示信息,包括有需要审核的新闻和考试计划,并为审核提供跳转页面,也可直接使其作废。在需要审核的项目后有进入审核页面的超链接“现在审批”,点击后进入审核页面passit.asp。进入审核界面后首先判断将审核的是考试计划还是新闻,若是考试计划将显示该试卷的基本信息,即在试卷定制时输入的信息,供审核人查看以判定该试卷是否合理,并且审核人是不能修改这些信息的。然后显示该试卷的详细信息,即显示包含在该试卷中的每一道题的题干及选项,供审核人查看试卷的具体内容是否合理。

重要功能代码分析如下:

'如果是教研室主任登录,判断是否有需审批的信息

if request.cookies("userid")<>"" then  rs.close 

sql="select * from waitforpass where havepass=0 and passuserid="&request.cookies("userid")

set rs=server.createobject("adodb.recordset")

rs.open sql,conn,3,2

if not rs.eof then %><table border="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2">  <tr>

<td width="100%" style="border-left-style: solid; border-left-width: 0; border-right-style: solid; border-right-width: 0; border-top-style: solid; border-top-width: 0; border-bottom: 1px solid #000000">

<img border="0" src="images/tishi.gif"></td> </tr>

<% do while not rs.eof %><tr>  

<td width="100%" height="30" background="images/32.gif"><img border="0" src="images/blue.gif">

有一项<font color="#ff0000"><%=rs("objname")%></font>需要您审批。

<a href="passit.asp?id=<%=rs("id")%>&objid=<%=rs("objid")%>">现在审批</a></td>

</tr> <%  rs.movenext loop %></table><%  end if

end if  %>

'如果是管理员登录,判断是否有管理员信息

<%if request.cookies("ifadmin")="True" then  rs.close

sql="select * from waitforpass where havepass=0"

set rs=server.createobject("adodb.recordset")

rs.open sql,conn,3,2

if not rs.eof then %>

<table border="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2"><tr>

    <td width="100%" style="border-left-style: solid; border-left-width: 0; border-right-style: solid; border-right-width: 0; border-top-style: solid; border-top-width: 0; border-bottom: 1px solid #000000">

<img border="0" src="images/tishi.gif"></td> </tr> <% do while not rs.eof %><tr>

    <td width="100%" height="30"><img border="0" src="images/blue.gif">有一项<font color="#ff0000"><%=rs("objname")%></font>[编号:<%=rs("objid")%>]没有通过审批。

<ahref="unpassit.asp?id=<%=rs("id")%>&objname=<%=rs("objname")%>&objid=<%=rs("objid")%>">作废</a></td> </tr> <% rs.movenext loop %></table>

<%end if

end if %>

其运行效果如图4-10所示:

图4-10  登录新闻页面显示待审批考试计划页面

以上是系统提示有需要审批的信息,然后审核人要对该考试计划进行合理性判断,以确定是否让其通过。若通过则将审核意见填如waitforpass表,然后将waitforpass表的havepass字段设置为1,若未通过则将审核意见填入waitforpass表,然后将waitforpass表的havepass字段设置为0。并显示操作成功。注:为确保制卷人知道审核是否通过的原因,审核人在审核意见一栏必须填入审核的意见才能进入下一步。

以下是考试计划审核代码,新闻审核设计同考试计划审核

if request("objname")="考试计划" then   testid=request("testid")

sql="select * from exam_test where testid="& testid

set rs=server.createobject("adodb.recordset")

rs.open sql,conn,3,2

if rs("passuserid")<>0 then

else  rs("passuserid")=request.cookies("userid")

 rs("passtime")=date()

 rs.update

rs.close

 sql="select * from waitforpass where objid="& testid

 set rs=server.createobject("adodb.recordset")

 rs.open sql,conn,3,2

 if request("yesorno")="同意" then  rs("havepass")=1

 else  rs("havepass")=2

 end if

 rs("passuserid")=request.cookies("userid")

 rs("passtime")=date()

 rs("passadvice")=request("passadvice")

 rs.update

 rs.close

 end if %><p><br><br></p>

<div align="center"> <center> <table cellspacing="0" style="border-collapse: collapse" bordercolor="#336699" width="480" id="AutoNumber2" cellpadding="0" border="1">

    <tr><td width="100%" height="25" ><b> 操作成功</font></b></td>

    </tr><tr><td width="100%" height="160" bgcolor="#EFEFEF">

<p align="center"><font size="2">祝贺您,已经成功审批考试计划!</font>    

5软件测试

软件测试(software testing)是软件质量保证的主要活动之一。软件测试是为了发现错误而执行程序的过程。也就是说软件测试是根据软件开发各阶段的规格说明和程序的内部结构而精心设计一批测试用例(即输入数据及其预期的输出结果),并利用这些测试用例去运行程序,以发现程序错误的过程。

5.1 软件测试的目的

从用户的角度出发,普遍希望通过软件测试暴露软件中隐藏的错误和缺陷,以考虑是否可以接受该产品。而从软件开发者的角度出发,则希望测试成为表明软件产品中不存在错误的过程,验证该软件已正确地实现了用户的要求,确立人们对软件质量的信心。

测试的目标是想以最少的时间和人力找出软件中潜在的各种错误和缺陷。如果成功地实施了测试,就能够发现软件中的错误。测试的附带收获是,它能够证明软件的功能和性能与需求说明相符。

5.2 软件测试的方法

软件测试方法有黑盒测试和白盒测试。黑盒式测试是功能测试,主要是为了发现以下几类错误:

(1) 是否有不正确或遗漏了的功能?

(2) 在接口上,输入能否正确地接受?能否输出正确的结果?

(3) 是否有数据结构错误或外部信息(例如数据文件)访问错误?

(4) 性能上是否能够满足要求?

(5) 是否有初始化或终止性错误?

白盒测试又称为结构测试或逻辑驱动测试。使用白盒测试方法,主要想对程序模块进行如下的检查:

(1) 对程序模块的所有独立的执行路径至少测试一次。

(2) 对所有的逻辑判定,取“真”与取“假”的两种情况都至少测试一次。

(3) 在循环的边界和运行界限内执行循环体。

(4) 测试内部数据结构的有效性,等等。

5.3 测试内容设计

为了完成上述的测试过程,发现程序中错误,节省时间和资源,提高测试的效率。黑盒测试的方法有等价类划分,边界值分析,错误推测法等。白盒测试法有逻辑覆盖,条件覆盖,语句覆盖,路径覆盖等。

(1)数据库连接测试

测试要求:能正确的连接到数据库。

(2)用户登录测试

测试要求:用户在登录界面输入正确的用户名和口令后,能够进入到网站。

(3) 科目管理测试

测试要求:能够添加新的科目。

(4) 题库管理测试

测试要求:能够针对选择的科目对相应题型(单选,双选,判断)进行添加、删除、编辑等操作

(5)试卷生成测试

添加、编辑完试题之后,设置好题量,单个题分数、考试时间,有效期限之后能够随机生成一份完整的试卷。

(6)信息发布测试

在新闻发布页面能够发布相关的考试信息。

5.4 测试结果

(1)数据库连接测试

测试结果:能正确的连接到数据库。

(2)用户登录测试

测试结果:在登录界面输入正确的用户名和口令后,能够进入到网站。

(3) 科目管理测试

测试结果:能够添加新的科目。

(4) 题库管理测试

测试结果:能够针对选择的科目对相应题型(单选,双选,判断)进行添加、删除、编辑等操作

(5)试卷生成测试

添加、编辑完试题之后,设置好题量,单个题分数、考试时间,有效期限之后能够随机生成一份完整的试卷。

(6)信息发布测试

在新闻发布页面能够发布相关的考试信息。

6系统维护和改进

6.1 运行维护

系统运行维护的主要内容包括以下内容:

  1. 对软件开发和测试过程中没有发现的问题进行修改和补充。
  2. 对于软件的功能进行扩充或随着计算机技术的发展对软件运行环境进行升级。
  3. 对软件及运行环境进行日常维护。

对于本系统的使用,需要遵循相关的软件使用方式,注意系统的备份和恢复,从多个方面来确保数据能够可靠的保存下来。

6.2 系统的改进与提高

系统针对一般考试管理的工作特点,在二期开发是主要在以下方面进行改进:

1、添加新的功能,并在已有功能上完善。

2、在开发大型软件系统的过程中,需要面对错综复杂的问题,因此,在软件生存周期的每个阶段都不可避免地会产生错误。我们力求在每个阶段结束之前通过严格的技术审查,尽可能早的发现并纠正错误。测试的目的就是在软件投入生产性运行之前,尽可能多地发现软件中的错误。目前软件测试仍然是保证软件质量的关键步骤,它是对软件规格说明、设计和编码的最后复审。

3、在考试系统的开发过程中,每开发完一个模块都会进行模块功能测试,在测试的过程中,主要问题有以下几个:

<1>ASP的中文乱码问题

问题描述及解决办法:显示信息时出现了中文文字显示的问题。Java语言默认的编码方式是Unicode,而我们通常使用的文件和数据库都是基于 GB2312或者BIG5等方式编码的,在程序中经常会碰到汉字的处理及显示的问题。在向网页输出中文字符串的时候,经常会采用out.println(string)或者<%=string%>方式,那么必须转换,方式是通过<%@page ContentType=”text/html;charset=gb2312”%>定义输出字符集,从而实现内码的自动转换。

中文作为参数传递出现了乱码的问题。原因是客户提交的中文信息经浏览器编码到达服务器后,ASP无法将其正确解码。而事实上浏览器缺省的编码方式为ISO-8859-1,所以我们在处理中文参数时,把客户提交的中文参数先转换后再应用。通过以下的方法解决这个问题。

<%@ page content-Type=”text/html;charset=gb2312”%>,就可以解决汉字显示问题。在把数据输入到数据库中前,进行下面的转换:

byte[] temp=srcString.getBytes(“iso-8859-1”);

String desString=new String(temp);

得到的desString就可以写入到数据库中了。

<2>学生使用本系统考试时要防止故意刷新页面

问题描述:在测试时发现,若使用本系统考试时,使用者可以通过刷新页面重新计时考试,从而造成考试不能正常进行。

解决办法:要防止刷新,可以设计一个其实就是一个大的表单的页面,内嵌一个计时页面。使用session集合来存储用户的访问状态,如果mark是1则说明考生已经在刷屏,此时会显示相应的提示信息,若三次刷新的话,就要取消考试资格。

7结 论

考试的智能化可以让你方便地在考试的有效期内,在任何地点参加考试,并立即给出客观题的成绩,大大提高了办公的效率。

 本网上考试系统还存在着一些不足:

由于时间的关系,整体的功能还不是很完善,教师的管理模块功能还有些欠缺,特别是缺少主观题的判断功能。

没有作过专业的市场调查,资料也不够完善,考试系统的定位不是很明确。

对SQL SERVER数据库还不是很了解,建立过程等很多重要的功能还未接触过。

由于没用过支持SQL SERVER数据库的主页空间,所以还不知道上传到主页空间后数据库要怎么连接。

总而言之,这个智能考试系统功能的完善与加强必须要根据具体的实际情况来定,否则只会走进画蛇添足的深渊。

一晃两个月的毕业设计接近了尾声,回想这两个月来,有过欢乐,有过痛苦,自己在生活的磨练中也逐渐走向成熟。想想自己正向着自己的目标一步步的跨近,而感到十分的欣慰。忙碌的生活教会了我如何去合理地安排时间,学习生活上的不解,教会我如何去寻找一个多个答案,从中选出一个最佳的。在这次的毕业设计中,我学到了很多东西,在网络编程中,我经常会遇到一些陌生的技术,不懂的地方,每当这个时候我就很急,不知道该怎么办才好,头脑有时很乱,等冷静下来才懂得打开baidu和google等搜索引擎搜索解决的方法。渐渐的我遇事不再猴急。先理清思路,再看看问题出在哪,某些错误实在不懂的时侯,再去论坛上向ASP编程高手求教。

回忆过去的点点滴滴,我不禁联想翩翩:刚上大学时欢乐心情和兴奋的场景还历历在目。一切都是那么新鲜,那么富有吸引力。

总之,美好的一切都垂青于那些聪明进取,积极向上的人,我要抛开所有的忧愁和烦恼,笑对每一天,以积极的态度看待每一件事,做一个对社会有用的人,从而实现自身的人生价值。

8参考文献

[1]《信息学院的数字化学院系统软件开发任务书》

[2][美]Todd Cook《JSP从入门到精通[M]》.北京电子工业出版社,2003

[3]周绍广.《ASP编程基础与实例》.机械工业出版社 ,2002

[4] 李克东.信息技术与学科教学整合.方数据电子出版社,2001

[5]闪四清.《SQL Sever使用简明教程》 清华大学出版社,2001

[6]萨师煊,王珊.《数据库系统概论》 高等教育出版社,2002

[7]萨师煊,王 珊.《数据库系统概论[M]》北京高等教育出版社

[8]程文.《基于JSP开发动态网站的设计与实现[J]》.现代计算机,2002

[9] 立雅科技.《Dreamweaver MX&ASP网页整合大全》.电子工业出版社, 2004

[10] 李晓黎.《ASP+SQLSERVER网络应用系统开发指南》.人民邮电出版社, 2004

[11] 潘锦平.《软件开发技术》.西安电子科技大学出版社,1999年出版

[12] 李世杰.《Active Server Pages(ASP)网页设计手册》.清华大学出版社

[13] 杨志妹.《ASP+SQL Server基础练习+典型案例》.清华大学出版社,2002

[14] James A. Whittake.《Web入侵安全测试与对策》.清华大学出版社,2006

[15] 杨志妹.《ASP+SQL Server基础练习+典型案例》.清华大学出版社,2002

[16] 崔美善.《设计师谈网页风格视觉特效》.电子工业出版社,2003

[17] 关敬敏.《SQL SERVER 数据库应用教程》.清华大学出版社,2005

[18] 刘乃丽.《精通ASP.NET +SQL Server 2005项目开发》.清华大学出版社

[19] 林宏基.《WEB开发技术教程ASP/ASP.NET/JSP程序设计》.北京大学出版

[20] 甘登岱.《Photoshop CS2中文版平面设计》.机械工业出版社, 2007

[21] 王小科.《ASP.NET数据库系统开发案例精选》.人民邮电出版社,2007

[22] 张跃廷.《ASP.NET数据库系统开发完全手册》.人民邮电出版社,2007

[23] 邱锦伦.《Visual C#.NET程序设计教程》.清华出版社,2007

[24] 张怀庆.《Visual C#.NET 编程指导150例》.冶金工业出版社,2005

[25] 龙马工作室.《ASP+SQL Server网站开发实例精讲》.人民邮电出版社, 2007

[26] Wayne Freeze《ASP.NET DATABASE PROGRAMMING BIBLE America》2005

附录:英文翻译

The Synopsis Of ASP And ASP.NET

The Internet began in the late 1960s as an experiment. Its goal was to create a truly resilient information network—one that could withstand the loss of several computers without preventing the others from communicating. Driven by potential disaster scenar-ios (such as nuclear attack), the U.S. Department of Defense provided the initial funding.The early Internet was mostly limited to educational institutions and defense contractors. It flourished as a tool for academic collaboration, allowing researchers across the globe to share information. In the early 1990s, modems were created that could work over existing phone lines, and the Internet began to open up to commercial users. In 1993, the first HTML browser was created, and the Internet revolution began.

It would be difficult to describe early websites as web applications. Instead, the first generation of websites often looked more like brochures, consisting mostly of fixed HTML pages that needed to be updated by hand. A basic HTML page is a little like a word-processing document—it contains formatted content that can be displayed on your computer, but it doesn’t actually do anything. The following example shows HTML at its simplest, with a document that contains a heading and single line of text. An HTML document has two types of content: the text and the tags that tell the browser how to format it. The tags are easily recognizable, because they occur inside angled brackets (< >). HTML defines tags for different levels of headings, paragraphs, hyperlinks, italic and bold formatting, horizontal lines, and so on. For example, <h1>Some Text</h1> tells the browser to display Some Text in the Heading 1 style, which uses a large, bold font.

HTML 2.0 introduced the first seed of web programming with a technology called HTML forms. HTML forms expand HTML so that it includes not only formatting tags but also tags for graphical widgets, or controls. These controls include common ingredients such as drop-down lists, text boxes, and buttons. Here’s a sample web page created with HTML form controls. In an HTML form, all controls are placed between the <form> and </form> tags. The pre-ceding example includes two check boxes (represented by the <input type="checkbox">tags) and a button (represented by the <input type="submit"> tag).

HTML forms allow web application developers to design standard input pages. When the user clicks the Submit button on the page shown in Figure 1-2, all the data in the input controls (in this case, the two check boxes) is patched together into one long string and sent to the web server. On the server side, a custom application receives and processes the data. Amazingly enough, the controls that were created for HTML forms more than ten years ago are still the basic foundation that you’ll use to build dynamic ASP.NET pages! The difference is the type of application that runs on the server side. In the past, when the user clicked a button on a form page, the information might have been e-mailed to a set account or sent to an application on the server that used the challenging CGI (Common Gateway Interface) standard. Today, you’ll work with the much more capable and elegant ASP.NET platform

To understand why ASP.NET was created, it helps to understand the problems of otherweb development technologies. With the original CGI standard, for example, the web server must launch a completely separate instance of the application for each web request. If the website is popular, the web server must struggle under the weight of hundreds of separate copies of the application, eventually becoming a victim of its own success.

To counter this problem, Microsoft developed ISAPI (Internet Server Application Programming Interface), a higher-level programming model. ISAPI solved the performance problem but at the cost of significant complexity. Even after ISAPI developers master the tricky C++ programming language, they still lie awake at night worrying about confounding issues such as multithreading. ISAPI programming is definitely not for the fainthearted.

ISAPI never really went away. Instead, Microsoft used it to build higher-level development platforms, such as ASP and ASP.NET. Both of these technologies allow developers to program dynamic web pages without worrying about the low-level implementation details. For that reason, both platforms have become incredibly successful. The original ASP platform garnered a huge audience of nearly one million developers. When ASP.NET was first released, it generated even more interest as the centerpiece of the .NET Frame-work. In fact, ASP.NET 1.0 was enthusiastically put to work in dozens of large-scale commercial websites even when it was only in late beta.

Despite having similar underpinnings, ASP and ASP.NET are radically different. ASP is a script-based programming language that requires a thorough understanding of HTML and a good deal of painful coding. ASP.NET, on the other hand, is an object-oriented programming model that lets you put together a web page as easily as you would build a Windows application. In many respects, it’s easier to learn ASP.NET than to master ASP, even though ASP.NET is far more powerful.

Don’t let the version numbers confuse you. ASP.NET 1.x and ASP.NET 2.0 share the same underlying plumbing and use essentially the same technology. Although they run on different versions of the .NET Frame-work, the changes are evolutionary, not revolutionary. This similarity doesn’t hold for classic ASP, which is based on older Microsoft technologies such as COM.

At the same time that server-side web development was moving through an alphabet soup of technologies, a new type of programming was gaining popularity. Developers began to experiment with the different ways they could enhance web pages by embed-ding multimedia and miniature applets built with JavaScript, DHTML (Dynamic HTML), and Java code. These client-side technologies don’t involve any server processing. Instead, the complete application is downloaded to the client browser, which executes it locally.   

The greatest problem with client-side technologies is that they aren’t supported equally by all browsers and operating systems. One of the reasons that web development is so popular in the first place is because web applications don’t require setup CDs, down-loads, and other tedious (and error-prone) deployment steps. Instead, a web application can be used on any computer that has Internet access. But when developers use client-side technologies, they encounter a few familiar headaches. Suddenly, cross-browser compatibility becomes a problem. Developers are forced to test their websites with differ-ent operating systems and browsers, and they might even need to distribute browser updates to their clients. In other words, the client-side model sacrifices some of the most important benefits of web development.

For that reason, ASP.NET is designed as a server-side technology. All ASP.NET code executes on the server. When the code is finished executing, the user receives an ordinary HTML page, which can be viewed in any browser.

These are some other reasons for avoiding client-side programming:Isolation: Client-side code can’t access server-side resources. For example, a clientside application has no easy way to read a file or interact with a database on the server (at least not without running into problems with security and browser compatibility).Security: End users can view client-side code. And once malicious users understand how an application works, they can often tamper with it.

In some cases, ASP.NET allows you to combine the best of client-side programming with server-side programming. For example, the best ASP.NET controls can intelligently detect the features of the client browser. If the browser supports JavaScript, these controls will return a web page that incorporates JavaScript for a richer, more responsive user interface. However, no matter what the capabilities of the browser, your code is always executed on the server.

ASP.NET deals with these problems by introducing a completely new model for web pages. This model is based on a remarkable piece of technology called the NET Framework.

You should understand that the .NET Framework is really a cluster of several technologies:

The .NET languages: These include C# and VB .NET (Visual Basic .NET), the object-oriented and modernized successor to Visual Basic 6.0; these languages also include JScript .NET (a server-side version of JavaScript), J# (a Java clone), and C++ with Managed Extensions.

The CLR (Common Language Runtime): The CLR is the engine that executes all .NET programs and provides automatic services for these applications, such as security checking, memory management, and optimization.

The .NET Framework class library: The class library collects thousands of pieces of prebuilt functionality that you can “snap in” to your applications. These features are sometimes organized into technology sets, such as ADO.NET (the technology for creating database applications) and Windows Forms (the technology for creating desktop user interfaces).

ASP.NET: This is the engine that hosts web applications and web services, with almost any feature from the .NET class library. ASP.NET also includes a set of web-specific services.

Visual Studio: This optional development tool contains a rich set of productivity and debugging features. The Visual Studio setup CDs (or DVD) include the complete .NET Framework, so you won’t need to download it separately.

the next generation of web applications.

.NET 1.0 introduced completely new languages. However, the changes in the .NET 2.0 languages are much more subtle. Both C# 2005 and VB 2005 add a few new features, but most parts of these languages remain unchanged. As a result, any code written according to version 1.0 of the C# language will work identically with version 2.0. In Chapters 2 and 3, you’ll sort through the syntax of C# and learn the basics of object-oriented programming. By learning the fundamentals before you start creating simple web pages, you’ll face less confusion and move more rapidly to advanced topics such as database access and web services.

All the .NET languages are compiled into another lower-level language before the code isexecuted. This lower-level language is the MSIL (Microsoft Intermediate Language), or just IL. The CLR, the engine of .NET, uses only IL code. Because all .NET languages are designed based on IL, they all have profound similarities. This is the reason that the C# and VB .NET languages provide essentially the same features and performance. In fact, the languages are so compatible that a web page written with C# can use a VB .NET component in the same way it uses a C# component, and vice versa.

The .NET Framework formalizes this compatibility with something called the CLS (Common Language Specification). Essentially, the CLS is a contract that, if respected, guarantees that a component written in one .NET language can be used in all the others. One part of the CLS is the CTS (common type system), which defines data types such as strings, numbers, and arrays that are shared in all .NET languages. The CLS also defines object-oriented ingredients such as classes, methods, events, and quite a bit more. For the most part, .NET developers don’t need to think about how the CLS works, even though they rely on it every day.

The CLR runs only IL code, which means it has no idea which .NET language you originally used. Notice, however, that the CLR actually performs another compilation step—it takes the IL code and transforms it to native machine language code that’s appropriate for the current platform. This step occurs when the application is launched, just before the code is actually executed. In an ASP.NET application, these machine-specific files are cached while the web application is running so that they can be reused, ensuring optimum performance.

You might wonder why .NET compilers don’t compile straight to machine code. The reason is that the machine code depends on several factors, including the CPU. For example, if you create machine code for a computer with an Intel processor, the compiler may be able to use Hyper-Threading to produce enhanced code. This machine-specific version isn’t suitable for deployment to other computers, because no guarantee exists that they’re using the same processor.

The CLR is the engine that supports all the .NET languages. Many modern languages use runtimes. In VB 6, the runtime logic is contained in a DLL file named msvbvm60.dll. In C++, many applications link to a file named mscrt40.dll to gain common functionality. These runtimes may provide libraries used by the language, or they may have the additional responsibility of executing the code (as with Java).

Runtimes are nothing new, but the CLR represents a radical departure from Microsoft’s previous strategy. For starters, the CLR and .NET Framework are much larger and more ambitious than the VB 6 or C++ runtime. The CLR also provides a whole set of related services such as code verification, optimization, and garbage collection.

The CLR is the reason that some developers have accused .NET of being a Java clone. The claim is fairly silly. It’s true that .NET is quite similar to Java in key respects (both use a special managed environment and provide features through a rich class library), but it’s also true that every programming language “steals” from and improves on previous programming languages. This includes Java, which adopted parts of the C/C++ language and syntax when it was created. Of course, in many other aspects .NET differs just as radically from Java as it does from VBScript.

All .NET code runs inside the CLR. This is true whether you’re running a Windows application or a web service. For example, when a client requests an ASP.NET web page, the ASP.NET service runs inside the CLR environment, executes your code, and creates a final HTML page to send to the client.

Deep language integration: C# and VB .NET, like all .NET languages, compile to IL. In other words, the CLR makes no distinction between different languages——in fact, it has no way of knowing what language was used to create an executable. This is far more than mere language compatibility; it’s language integration.

Side-by-side execution: The CLR also has the ability to load more than one version of a component at a time. In other words, you can update a component many times, and the correct version will be loaded and used for each application. As a side effect, multiple versions of the .NET Framework can be installed, meaning that you’re able to upgrade to new versions of ASP.NET without replacing the current version or needing to rewrite your applications.

Fewer errors: Whole categories of errors are impossible with the CLR. For example, the CLR prevents many memory mistakes that are possible with lower-level languages such as C++.

Performance: A typical ASP.NET application is much faster than a comparable ASP application, because ASP.NET code is compiled natively. However, other .NET applications probably won’t match the blinding speed of well-written C++ code, because the CLR imposes some additional overhead. Generally, this is a factor only in a few performance-critical high-workload applications (such as real-time games). With high-volume web applications, the potential bottlenecks are rarely processor-related but are usually tied to the speed of an external resource such as a database or the web server’s file system. With ASP.NET caching and some well-written database code, you can ensure excellent performance for any web application.

The .NET class library is a giant repository of classes that provide prefabricated functionality for everything from reading an XML file to sending an e-mail message. If you’ve had any exposure to Java, you may already be familiar with the idea of a class library. However, the .NET class library is more ambitious and comprehensive than just about any other programming framework. Any .NET language can use the .NET class library’s features by interacting with the right objects. This helps encourage consistency among different .NET languages and removes the need to install numerous components on your computer or web server.

ASP.NET is a resoundingly successful platform. Thousands of websites used it while it was still in early beta, and today more than 50,000 public web servers rely on it every day. As dramatic rise, ASP.NET websites overtook JSP (Java Server Pages) websites in a single year.

With .NET version 2.0, Microsoft aims to continue its success by refining and enhancing ASP.NET. The good news is that Microsoft hasn’t removed features, replaced functionality, or reversed direction. Instead, almost all the changes add higher-level features that can make your programming much more productive.

Officially, ASP.NET 2.0 is backward compatible with ASP.NET 1.0. In reality, 100 percent backward compatibility is impossible, because correcting bugs and inconsistencies in the language can change how existing code works.However, you’re unlikely to ever run into a problem when migrating an ASP.NET 1.x project to ASP.NET 2.0. It’s much more likely that you’ll find some cases where the old way of solving a problem still works, but ASP.NET 2.0 introduces a much better approach. In these cases, it’s up to you whether to defer the change or try to reimplement your web application to take advantage of the new features.

The following sections introduce some of the most important changes in the different parts of the .NET Framework.

C# adds several new language features in version 2.0. Some of these are exotic features that only a language aficionado will love, while others are more generally useful. All of them are fairly technical.

The new features include the following:

Partial classes: Partial classes allow you to split a C# class into two or more source code files. This feature is primarily useful for hiding messy details you don’t need to see. Visual Studio uses partial classes in some project types to tuck automatically generated code out of sight.

Generics: Generics allow you to create classes that are flexible enough to work with different class types but still support strong type checking. For example, you could code a collection class using generics that can store any type of object. When you create an instance of the collection, you “lock it in” to the class of your choice so that It can store only a single type of data. The important part in this example is that the locking in happens when you use the collection class, not when you code it.

Anonymous methods: Anonymous methods allow you to define a block of code on the fly, inside another method. You can use this technique to quickly hook up an event handler.

Iterators: Iterators give you an easy way to create classes that support enumeration, which means you can loop through the values they contain using the C# foreach statement.

With ASP.NET 2.0, Microsoft set a bold goal—to help web developers dramatically reduce the amount of code they need to write. To accomplish this, ASP.NET 2.0 introduces new features for security, personalization, and data display. But instead of changing the existing features, ASP.NET 2.0 adds new, higher-level features that are built on top of the existing infrastructure.

For the most part, this article  won’t distinguish between the features that are new in ASP.NET 2.0 and those that have existed since ASP.NET 1.0. However, here are highlights of some of the new features:

Navigation: ASP.NET has a new higher-level model for creating site maps that describe your website. Once you create a site map, you can use it with new navigation controls to let users move comfortably around your website.

Master pages: Need to implement a consistent look across multiple pages? With master pages, you can define a template and reuse it effortlessly. On a similar note, ASP.NET themes let you define a standardized set of appearance characteristics for controls,which you can apply across your website for a consistent look.

Data providers: Tired of managing the retrieval, format, and display of your data? With the new data provider model, you can extract information from a database and control how it’s displayed without writing a single line of code. ASP.NET 2.0 also adds new data controls that are designed to show information with much less hassle (either in a grid or in a browser view that shows a single record at a time).

Membership and profiles: ASP.NET adds a handful of new controls for managing security, allowing users to log in, register, and retrieve passwords without needing any custom code. Instead, you use the higher-level membership classes that ASP.NET provides (see Chapter 19). Profiles offer a similar high-level approach to help you store and retrieve user-specific information in your database, without writing any database code.

Portals: One common type of web application is the portal, which centralizes different information using separate panes on a single web page. Although you could create a portal website in ASP.NET 1.x, you needed to do it by hand. In ASP.NET 2.0, a new Web Parts feature makes life dramatically easier.

Administration: To configure an application in ASP.NET 1.x, you needed to edit a configuration file by hand. Although this process wasn’t too difficult, ASP.NET 2.0 streamlines it with the WAT (Website Administration Tool), which works through a web page interface.

And of course, ASP.NET 2.0 also contains bug fixes, performance improvements, and a

slew of minor enhancements you’ll learn about throughout the book.

Microsoft provided two separate design tools for creating web applications with ASP.NET 1.x—the full-featured Visual Studio .NET and the free Web Matrix. Professional developers strongly favored Visual Studio .NET, but Web Matrix offered a few innovative features of its own. Because Web Matrix included its own scaled-down web server, programmers could create and test web applications without needing to worry about configuring virtual directories on their computer using IIS (Internet Information Services).

With .NET 2.0, Web Matrix disappears, but Visual Studio steals some of its best features, including the integrated web server, which lets you get up and running with a test website in no time.

Another welcome change in Visual Studio 2005 is the support for different coding models. While Visual Studio .NET 2003 locked developers into one approach, Visual Studio 2005 supports a range of different coding models, making it a flexible, all-purpose design tool. That means you can choose to put your HTML tags and event handling code in the same file or in separate files without compromising your ability to use Visual Studio and benefit from helpful features such as IntelliSense.

Visual Studio 2005 is available in several editions. The Standard Edition has all the features you need to build any type of application (Windows or web). The Professional Edition and the Team Edition increase the cost and pile on more tools and frills (which aren’t discussed in this book). For example, they incorporate features for managing source code that’s edited by multiple people on a development team and running automated tests.

The scaled-down Visual Web Developer 2005 Express Edition is much cheaper than any other Visual Studio edition, but it also has a few significant limitations. It gives you full support for developing web applications, but it doesn’t support any other type of application. This means you can’t use it to develop separate components for use in your applications or to develop Windows applications that interact with web services. However, rest assured that Visual Web Developer is a bona fide version of Visual Studio, with a similar set of features and development interface.

This article presented a high-level overview that gave you your first taste of ASP.NET and the .NET Framework. You also looked at how web development has evolved, from the basic HTML forms standard to the latest changes in .NET 2.0.

译文

ASP和ASP.NET简介

因特网是在1960年末在试验中诞生的。它的目标是:建立一个真实的、有弹性的信息网络——可以经受的起若干数量的电脑的崩溃,而不至于阻断其他电脑的正常通信。经得起潜在的重大灾难(如核武器攻击)。美国国防部提供了刚开始的研究基金。最早的因特网局限在教育机构和从事国防的单位。它因为作为学术研究的一种工具而繁荣,它让全球的研究人员可以彼此共享信息。到了1990初,伟大的“猫”诞生了,它通过电话线工作,从此,因特网向商业用户打开了大门。在1993年,第一个HTML浏览器诞生了,标志着因特网革命的到来。

我们很难把最早的网页称为网页程序。第一代的网页看起来更像小册子:主要由固定的HTML页面构成,这些也都需要手动修改。一个简单的HTML页面有点像一个字处理文档——它包含了格式化的内容,可以在你的电脑上显示,但是并不完成其他任何功能。上面的就是一个最简单的例子,文档包括头信息和单行文本。一个HTML文档有两种类型的内容:文本和标记(告诉浏览器如何格式化)。这些标记很容易辨认,因为它们总是出现在< 和 >之间。HTML定义了不同级别的标题、段落、超链接、斜体和粗体格式、水平线等。举个例子:<h1>某个文本<h1>,告诉浏览器用标题1的格式来显示这个文本,就是用最大的黑体字来显示。

 HTML 2.0 首次引入了一个网页编程的新技术,称为HTML表单。HTML表单扩展了HTML的功能,不仅包含了格式化标签,而且包含了窗体小部件或者叫控件。这些控件包含了普通的功能部件,如下拉列表、文本框和按钮。下面是一个由HTML表单控件创建的网页。在HTML表单中,所有的控件都放在<form> 和</form>标签之间。前面讲过的这个例子包括了两个复选框(用<input type="checkbox">标签表示)和一个按钮(用<input type="submit">标签表示)。

网页表单允许网页程序设计师设计标准的输入页面。当用户单击提交按钮,所有在输入控件中的数据(在这个例子中是两个复选框)将打包成一个长字符串,接着发送到服务器。在服务器端,一个客户程序接收和处理这些数据。令人惊奇的是:这些为HTML表单创建有超过十年之久的控件仍然是你用来创建ASP.NET页面的基础。不同的是这些程序控件将运行在服务器端。在过去,当用户单击一个表单页面的按钮时,信息要通过e-mail来发送或者使用在服务器端运行的程序(通过CGI标准)。今天,你将可以使用更强大、更优雅的ASP.NET平台。

 理解ASP.NET的创建原因可以帮助我们了解其他网页开发技术遇到的问题。在原始的CGI标准下,举个例子,网页服务器必须为每个网页请求建立一个单独的程序实例。如果这个网页很受人们欢迎(那访问者将很多),那么网页服务器就要经受得起数以百计的独立程序副本,这样最终导致服务器反而因为受欢迎而成为受害者。

为了解决这个问题,微软开发了ISAPI(网络服务程序编程接口),一个高层次的编程模型。ISAPI解决了性能问题,但是付出了复杂性的代价。即使ISAPI开发者是个C++编程老手,他仍然晚上担心到失眠,因为会遇到多线程处理这样让人麻烦的问题。ISAPI编程是给那些坚强的“夜猫子”,不是给那些懦弱的人。

ISAPI并没有真正消失,取代它的是,微软利用它建立了一个更高级的开发平台,如ASP 和 ASP.NET。这两种技术都可以使开发者编写动态网页,而不需要担心底层的执行细节由于这个原因,这两个平台成功到令人难以置信。最初的ASP平台吸引了将近一百万的开发人员。当ASP.NET第一次发布时,作为.NET Framework的核心部件受到人们更多关注。事实上,ASP.NET 1.0已经在数十个大型商业网络中得到应用,虽然它还在最后的测试阶段。

 虽然拥有类似的基础,ASP 和ASP.NET有根本的不同。ASP是基于脚本的编程语言,需要全面理解HTML,而且还要经过一大堆痛苦的编程训练。而ASP.NET,在另一方面,是面向对象的编程模型,建立网页页面就像建立桌面程序一样容易。在很多方面,学会ASP.NET比精通ASP要容易,而且ASP.NET功能更加强大。

不要被版本号所困惑。ASP.NET 1.x and ASP.NET 2.0共享相同的基础元件,本质上一样的技术。虽然它们运行在不同版本的.NET Frame-work之上,变化只算改进而不是革命性的。这些相似性和经典的ASP是不同的,ASP是基于旧的微软技术,如COM(对象组建模型),同时,服务器端的网络发展为从技术的字母形花片汤到广受欢迎的一类编程。开发人员开始试着使用嵌入多媒体、JavaScript的小程序、DHTML和Java代码来增强网页的功能。这些基于客户端的技术不需要通过服务器的处理就能实现。所有的程序都(从服务器)下载到客户端浏览器,在本地执行。

客户端技术的最大问题就是它们不被所有的浏览器和操作系统完美的支持。其中的一个原因就是网络开发太受欢迎了,首先是网络程序不需要通过CD安装、下载和其他单调的配置。取而代之的是,一个网络程序只要能上网的电脑就可以执行了。但是,一旦开发者使用客户端技术,他们就会遇到一些常见的问题:比如跨浏览器的兼容性。开发者就不得不在不同的浏览器和操作系统中测试他们的网页,甚至他们还要给用户发布浏览器更新。换句话说,客户端模型牺牲了网络程序最重要的优良特性。

 由于上述原因,ASP.NET被设计为服务器端技术。所有的ASP.NET代码都在服务器上执行。当代码执行完毕时,用户就会得到一个普通的HTML页面,这样任何浏览器都可以浏览了。

 这里还有几条原因要避免客户端编程:孤立性:客户端代码无法访问服务器资源。举个例子,没有一种简单的方式让客户端可以读取一个在服务器上的文件或进行数据库连接。(至少不会遇到安全性和浏览器兼容性的问题) 安全性:最终用户可以查看客户端代码。一旦有不怀好意的用户理解了程序是怎么工作的,他们就有可能乱来了。

 在某些方面,ASP.NET允许你通过服务器端编程结合最佳的客户端编程。举个例子:ASP.NET控件可以智能侦测客户端浏览器的属性。如果该浏览器支持JavaScript,那么这些控件将返回一个含有JavaScript的更多功能的页面。尽管如此,不管浏览器的功能有多强大,你的代码始终在服务器端执行。

ASP.NET通过引进全新的模型解决了上述问题。这个模型是基于一个伟大的技术,称之为.NET Framework。

你应该知道的是:.NET Framework是几种技术的群集(集合)。

.NET语言:包括C#和VB.NET(Visual Basic .NET一种面向对象的、现代化的语言(VB 6.0的继任者);这些语言还包括:Jscirpt.NET(服务器端版本的JavaScript,J#(java的兼容产品),还有C++管理扩充。

CLR(公共语言运行库):CLR是执行所有.NET程序和为这些程序提供自动服务的引擎,如安全验证、内存管理和优化等。

.NET Framework类库:类库包含了成千上万个已经预建好的函数,你可以在你的程序中嵌入它们。这些众多属性有时也被成为一个技术集,如ADO.NET(用来创建数据库程序的技术)和Windows Forms(也是一种技术,用来创建基于桌面的用户界面程序)。

ASP.NET:这是一种主机网页程序和网络服务的引擎,从.NET类库中包含了几乎所有特性。ASP.NET还包含了网页特有的服务。

Visual Studio:这个可选的开发工具包含了众多提高效率和调试功能的特性。VS的安装CD(或DVD)包含了完整的.NET Framework,所以你不需要额外下载它。

.NET 1.0引进了一种全新的语言。尽管如此,.NET 2.0语言的变化还是细微的。C# 2005和VB2005都添加了一些新的特性,但是这些语言绝大部分都没有变化。因此,任何使用C#1.0编写的代码都可以同样的在2.0下运行。在第二、三章,就就会学到C#语法和面向对象编程的基础。搞定了这些基础,你就可以开始创建简单的网页了。这样你就会少点困惑,学得更快。向一些高级话题进军,如数据库访问和网络服务。

在代码执行之前,所有的.NET语言都编译成另一种低级语言。这种低级语言叫MSIL(微软中间语言),或者叫just IL。CLR,.NET的引擎,只使用IL代码。因为所有的.NET语言都设计成基于IL,所以他们有很多相似性。这就是C# 和 VB .NET语言可以提供本质上相同的特性和性能。事实上,这些语言是兼容的,就是说用C#可以使用用VB.NET的元件,就像使用用C#写的元件一样。反之亦然。

.NET Framework使用CLS解决兼容性。本质上CLS是一分契约,它保证一个元件按照一种.NET语言的要求来写,就可以在其他所有CLS中使用,其中CTS(公共类型系统)贡献良多,它定义了数据类型,如字符串、数值型和数组,这些在所有.NET语言中共享。CLS也定义了面向对象的元素,诸如类、方法、事件等等。在绝大多数情况下,.NET开发者不需要知道CLS是如何运作的,虽然他们天天都要依赖它。

CLR(公共语言运行库)只能运行IL代码,这就意味着它根本不知道你的源代码是用哪一个语言编写的,尽管如此,CLR竟然完成了另外一个编译步骤——它接受了IL代码并把它转换成适合当前平台的本机机器语言。这个步骤在程序启动时发生,而且在代码被真正执行之前。在ASP.NET程序中,当网络程序正在运行时,这些特定机器文件存储在高速缓存中,所以它们可以被复用(重新使用),以确保最佳性能。

你或许会问.NET为什么不直接编译成机器语言。原因是:机器代码取决于多个因素,包括CPU。举个例子,如果你是为一台含有Intel 处理器的电脑而创建的机器代码,那么编译器将能够使用超线程技术来增强你的代码。这种适用特点机器的版本并不适合在其他电脑中运行,因为你无法保证它们使用同样的处理器。

CLR是支持所有.NET语言的引擎。许多现代语言都使用运行库(运行时间)。在VB6中,运行库逻辑上就是包含在一个叫msvbvm60.dll的DLL文件中。在C++中,许多程序链接到一个叫mscrt40.dll的文件以获取公共函数。这些运行库为语言提供众多的库,或者是一个额外执行代码的功能(和java一样)

运行库并不是什么新的东西,但是CLR(技术)表明和微软以前的策略有较大的差别。对应用程序来说,CLR和.NET Framework比VB 6和C++的运行库更强大。CLR更提供了服务程序的相关集合,例如代码验证、优化和垃圾收集。

CLR被一些开发者认为.NET是java的克隆。这个主张相当白痴。.NET和Java在一些关键方面确实有相似的地方(都使用一个特殊的处理环境和通过丰富的类库提供众多特性)但是我们应该知道这么一个事实:每一种编程语言都从以前的语言那“偷学”精华以提高自己。这也包括Java,采用了大部分的C/C++语言的语法。当然,在许多其他方面,.NET和Java有根本的不同,就像和VBScript不同一样。

所有.NET代码都在CLR内部运行。无论在你运行Windows程序还是一个网络服务都是这样。举个例子:当一个客户端请求一个ASP.NET页面,ASP.NET服务在CLR环境内部运行,执行你的代码,并最终创建一个HTML页面发送给客户端。

深度语言集成:C#和VB.NET,和所有.NET语言一样,要编译成IL。换句话说,CLR让不同的语言变得没有差别——事实上,它根本不知道是使用哪一种语言来创建可执行程序的。这大大超越了语言兼容性的范畴,而是语言集成。

并行执行:CLR也有这一项功能:同时载入多个版本的元件。换句话说,你可以多次升级你的元件,被修改过的版本被装载并用在每个程序上。在这方面的好处是,你可以安装.NET Framework的多个版本,这就意味着你可以随时到一个新的ASP.NET版本,而不需要替换当前版本或者重写你的程序。

更少的错误:CLR对所有种类的错误都很敏感。举个例子,CLR阻止很多内存错误,而像相对低级的C++就不行。

性能:一个典型的ASP.NET程序比一个ASP程序(功能相当)快很多,因为ASP.NET代码在本地编译。尽管如此,其它.NET程序可能和好的C++程序没的比,因为CLR产生了一些额外的开销。一般而言,这只在少数性能要求高、工作量大的程序中存在(如实时游戏)。在高容量网络程序中,潜在的瓶颈很少是处理器,而是外部资源的速度有关,如数据库或者网络服务器的文件系统。通过ASP.NET高速缓存和优质的数据库代码,你就可以在任何网络程序中保证优秀的性能。

.NET类库是一个巨大的类储藏库,它提供了很多预定义的函数:从读XML文件到发送e-mail信息.如果你有接触过Java的话,你就会对类库的概念比较熟悉.尽管如此, .NET类库比其他编程语言的框架库更加全面和强大。任何.NET语言都可以通过连接正确的对象来使用.NET类库的特性。这帮助保证在不同.NET语言之间保持一致性,也就不需要在你的电脑或者网络服务器上安装各种众多的元件。

在网络程序中,有部分的类库中包含的属性是你永远也用不到的(如用Windows接口来创建桌面程序的类)。其他部分的类库就是直接面向网络开发,如用于网络服务和网页页面。不过,仍然有许多类可以用于各种编程场合,而不限定在网络或桌面开发。这些包含了类的基本集合,如定义公共变量类型和数据访问类,

ASP.NET是一个成功的平台。当它还在测试时,就有成千上万的网站使用它了,今天有超过50000个公共网页服务器在使用它。作为一个令人激动的成绩,在一年之间,ASP.NET网站就超过了JSP网站。

对于.NET2.0版本来说,微软立志延续它的成功,继续优化增强ASP.NET。好消息是微软没有去除什么属性,淘汰函数或reversed direction.取而代之的是,所有的更新都是添加了高层属性,让你可以提高编程效率。

官方说,ASP.NET 2.0向后和ASP.NET 1.0兼容。事实上,100%的向后兼容是不可能的,因为修正语言的错误和不一致性会改变现有代码的工作。尽管如此,你在把ASP.NET 1.x工程迁移到ASP.NET 2.x时未必不会遇到麻烦。你更可能发现一些解决问题的方法仍然可以正常工作,但是ASP.NET 2.0提供了一个更好的方法。决定权在你手中,你可以推迟也可以重新配置你的网络程序来利用新的属性。

下面将介绍一些.NET Framework不同部分的一些最重要的变化。

C#2.0增加了几个新的语言属性。一些特殊属性是那些编程狂所喜欢的,其他的就较为有用。

下面时新的特性:

部分类集:部分类集允许你把C#类分离成多个源代码文件。这项技术主要用来隐藏你不希望看到的那些凌乱的细节。VS在某个工程中使用部分类集来自动折叠代码,这样就看不见了。

类属:类属允许你创建能和不同类类型共同工作的类,并且仍然支持强类型检查。例如:你可以编一个使用类属的类集类来存储所有类型的对象。当你创建这个类集的实例时,你把它锁定在你选择的类,这样它只能存储数据的单精度型。这个例子的重要部分是锁定发生在你使用类集类时,不是你对它编码时。

匿名方法:匿名方法让你可以在另外一个方法中灵活地定义代码块。你可以利用这个技术迅速地hook up事件处理程序

迭代器:迭代器提供了一种简单的方式来创建支持枚举的类,这就是说你可以通过循环使用C#foreach语句。 

在ASP.NET 2.0中,微软设置了一个Bold goal,来帮助网络开发者减少所需要的代码量。为了实现这个,ASP.NET 2.0引入了新的安全特性、个性化和数据显示。可以用来代替已经存在的特性,ASP.NET 2.0增加的是新的、更高层的特性,是建立在已经存在的基础架构之上的。

在本文的绝大部分,并不区分特性是来自ASP.NET 2.0还是ASP.NET 1.0。尽管如此,这儿也重点解说九个新的的特性。

导航:ASP.NET有一个新的更高层模型用来创建站点地图(用来描述你的网站)。一旦你建立了一个站点地图,你就可以利用新的导航控件来使用它,这样可以让用户轻松的访问你网站的各个部分。

需要在多页面中保持同一的风格吗?在master pages帮助下,你可以定义一个模版,然后轻松地反复利用。相似的情况,ASP.NET让你为控件定义一个外观特征标准,你就可以在你网页中应用,来保持同一的风格。

Data providers(数据供应器):你曾经对管理检索数据、格式化和显示你的数据感到精疲力竭吗?你可以从数据库中提取信息和控制它如何显示,这些都不需要写一行的代码!ASP.NET 2.0也添加了一个新的数据控件来显示信息(在表格中或在浏览器中每次以单行显示)。

从属关系和定义文件:ASP.NET添加一些管理安全的新控件,允许用户登陆、注册和不需要任何自定义代码来找会密码。你使用ASP.NET提供的更高层次的从属度类。定义文件提供了一个类似高层次的方法来帮助你存储和检索用户指定的信息(在数据库中),这些你都不需要些任何关于数据库的代码。

入口:web程序的一个公共类型就是一个入口,在一页面上使用独立的窗格来集中显示不同的信息。虽然你可以使用ASP.NET 1.x来创建入口(门户)网站,你需要手动实现,在ASP.NET 2.0中,一个新的web部分的特性使这些更容易了。

管理:在ASP.NET 1.x中配置一个程序,你需要手动编辑配置文件(这个不是很复杂)。ASP.NET 2.0使用WAT(网站管理工具)来,它是通过网页接口工作的。

当然,ASP.NET 2.0也包含了对错误的更正、性能的提高和一些你将在本书中学到的局部改进。

微软提供两种创建web程序的分离设计工具集:ASP.NET 1.x——包含VS.NET的全特性和免费的Web Matrix。专业的开发者特别受惠于VS.NET,不过Web Matrix提供了一些它自己的新特性。因为Web Matrix 包含了精简的web server,程序员可以无需考虑他们的计算机上(已安装IIS)是否配置虚拟目录,就可以创建和测试他们的Web 程序。

在. NET 2.0,web atrix消失了,但是VS借鉴了它的一些最后的特性,包括集成网络服务器,让你随时启动、运行一个测试网页。

在VS 2005中,另一个受人欢迎的改变是支持不同的编码模型。而VS2003却受那个困扰,VS 2005支持某个范围的不同编码模型,使它成为具有灵活性、通用性我的设计工具。这就让你可以把HTML标签和事件处理代码放在同一个文件类或者分开存放,而不用委屈的使用VS,这样可以享受有用的特性好处,如代码智能完成。

VS2005有几个可用的版本。标准版拥有所有特性,无论你是建立什么类型的程序(windows 或web)。专业版和团队版增加了更多的工具和frill(本书中不讨论)。例如,他们为管理源代码(由多人的开发团队共同编辑,且自动测试)合并了特性。

精简版的Visual Web Developer 2005的 Express Edition比其他VS版本都便宜很多,但是它有一些对重要功能的限制。它完全支持开发网络程序,但是它不支持其他任何类型的程序。这就意味着你无法用它来为你的程序开发分离元件或者开发和网络服务互联的windows程序。尽管如此,Visual Web Developer是VS的一个版本,有一个类似的特性集和开发接口。

本文采用了高度的概括,让你初步认识了ASP.NET 和 .NET Framework。你也简单地了解网络开发是如何发展的,从基本HTML表单标准到最新的.NET 2.0。

致 谢

经过四个多月的忙碌,随着我学生时代的结束,本次毕业设计已经接近尾声,作为一个本科生的毕业设计,由于经验的匮乏,难免有许多考虑不周全的地方,如果没有指导老师的督促指导,想要完成这个设计是难以想象的。

在这里首先我要感谢学院给我们提供的良好环境,使我们可以把精力全部都放到毕业设计上来。感谢所有帮助过我关心过我的老师和同学,是他们构成了我大学五年生活的全部,让我更加充实地踏入社会。

感谢我的指导老师石教授,石老师平日里工作繁多,但在我做毕业设计的每个阶段,从开题之初查阅资料到设计草案的确定和修改,从中期检查到后期详细设计,毕业设计的整个过程中都给予了我悉心的指导,细心地纠正设计论文中的错误。除了敬佩石老师渊博的专业知识以外,他的治学严谨和科学研究的精神也是我永远学习的榜样,并将积极影响我今后的学习和工作。

同时还要感谢所有的同学们,正是因为有了你们的支持和鼓励,才使我顺利完成了本次毕业设计。 特别要感谢我的同组同学,我们在一起学习研究的过程中,她给了我足够的信心和勇气,让我们共同进步,共同顺利的完成了大学里的最后一次课题设计。

最后还要感谢我的父母,谢谢他们辛辛苦苦供我上完大学,谢谢他们的养育之恩。再次由衷的感谢大家。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

等天晴i

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值