这次是我第一次用asp.net 做的东西,由于时间比较急,临近考试也没有太多的精力来做这个系统,系统做的很垃圾也烂的惨不忍睹,但我希望各位能多多批评指导,能多提宝贵意见能让我能对系统进行改进同时也能更好的提高自身的水平,谢谢!!
本系统的设计说明
本系统使用Microsoft .net架构下的VB.NET和Access2000的数据库开发的在线考试系统
本系统将实现将传统的笔试和手动改卷利用WWW服务扩展到网络层面,并对所有的考生进行信息化的管理,本系统程序中简单的设计了四个模块。这四个模块分别如下:
学生考试登陆模块:对学生输入的信息进行查询,让考生在考试前对个人信息进行核对
学生考试模块:不同的考生根据不同的ID号生成不同的试卷,防止了考生作弊的情况
教师登陆模块:通过对教师的登陆控制不同的教师有不同的权限
教师管理模块:让教师可以对考生的信息进行添加,修改,删除
主页面(WEBMAIN)的设计:
让老师和考生可以通过不同的HyperLink来进行选择登陆
学生考试登陆模块:
考生Login页面的设计:
3个lable(lable1.text=请输入准考证号:, lable2.text=请输入姓名: , lable3.text=欢迎登陆考试系统),2个textbox(textbox1,2.text都为空值),并用requiredFieldValidator控件分别对textbox1,textbox2进行验证.不允许2个textbox的值为空(requiredFieldValidator1对textbox1进行验证 , (requiredFieldValidator2对textbox2进行验证) ,1个botton(通过查询ACCESS数据库来对textbox1和textbox2输入的值进行查询,如果匹配把查询结果赋给的LABEL和IMAGE)
详细代码如下:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cn As New System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=F:/mysite/考试系统/database/Examination.mdb")
Dim cmd As New OleDbCommand("select * from Basicinfo where Examinee_id=@i and name=@j ", cn)
cmd.Parameters.Add("@i", TextBox1.Text)
cmd.Parameters.Add("@j", TextBox2.Text)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds)
'DataGrid1.DataSource = ds
'DataGrid1.DataBind()
Image1.ImageUrl = ds.Tables(0).Rows(0)("user_img")
Session("examinee_id") = ds.Tables(0).Rows(0)("examinee_id")
Session("name") = ds.Tables(0).Rows(0)("name")
Session("sex") = ds.Tables(0).Rows(0)("sex")
Session("age") = ds.Tables(0).Rows(0)("age")
Session("test_room") = ds.Tables(0).Rows(0)("test_room")
Session("text") = ds.Tables(0).Rows(0)("text")
Label6.Text = Session("examinee_id")
Label12.Text = Session("name")
Label13.Text = Session("sex")
Label14.Text = Session("age")
Label15.Text = Session("test_room")
当考生在确认自己的个人信息无误后就可以单击“开始”按钮进行考试
这里通过一个VB.NET 的内置对象Session将考生的信息传递给考试页面,通过
Me.Response.Redirect("exam.aspx")连接到考试页面
学生考试模块:
由于时间的关系只能将考试的试题设计为图片并根据查询数据库与准考证进行对应,可以由不同的准考证号生成不同的试题,IMG1为显示考试题目
LABEL2和LABEL4分别用来接受由Session("examinee_id") = ds.Tables(0).Rows(0)("examinee_id")
Session("name") = ds.Tables(0).Rows(0)("name")
传递过来的参数
再答题后把答案写到textbox1-textbox5中,在单击"提交答案"后label25-label29中显示你所输入的答案,代码如下:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label25.Text = TextBox1.Text
Label26.Text = TextBox2.Text
Label27.Text = TextBox3.Text
Label28.Text = TextBox4.Text
Label29.Text = TextBox5.Text
End Sub
在确认交卷后答案将被写入到数据库,答案将不可以再修改,在按”确认交卷”后,把数据写入数据库的同时对所提交的答案与数据库保存的标准答案进行匹配,得出每一题的得分,在进行统计后在LABEL35中显示所得分数,并把所得分数保存到数据库相应的地方,在提交后为防止再次修改答案情况“提交答案”按钮将不可见 Me.Button1.Visible = False
代码如下:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim cn As New System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=F:/mysite/考试系统/database/Examination.mdb")
Dim cmd As New OleDbCommand("update answer set user_answer=@i where answer_id=@j ", cn)
cmd.Parameters.Add("@i", Label25.Text)
cmd.Parameters.Add("@j", Label8.Text)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds)
Dim cn1 As New System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=F:/mysite/考试系统/database/Examination.mdb")
Dim cmd1 As New OleDbCommand("update answer set user_answer=@k where answer_id=@l ", cn1)
cmd1.Parameters.Add("@k", Label26.Text)
cmd1.Parameters.Add("@l", Label9.Text)
Dim da1 As New OleDbDataAdapter(cmd1)
Dim ds1 As New DataSet
da1.Fill(ds1)
Dim cn2 As New System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=F:/mysite/考试系统/database/Examination.mdb")
Dim cmd2 As New OleDbCommand("update answer set user_answer=@m where answer_id=@n ", cn2)
cmd2.Parameters.Add("@m", Label27.Text)
cmd2.Parameters.Add("@n", Label13.Text)
Dim da2 As New OleDbDataAdapter(cmd2)
Dim ds2 As New DataSet
da2.Fill(ds2)
Dim cn3 As New System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=F:/mysite/考试系统/database/Examination.mdb")
Dim cmd3 As New OleDbCommand("update answer set user_answer=@o where answer_id=@p ", cn3)
cmd3.Parameters.Add("@o", Label28.Text)
cmd3.Parameters.Add("@p", Label14.Text)
Dim da3 As New OleDbDataAdapter(cmd3)
Dim ds3 As New DataSet
da3.Fill(ds3)
Dim cn4 As New System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=F:/mysite/考试系统/database/Examination.mdb")
Dim cmd4 As New OleDbCommand("update answer set user_answer=@k where answer_id=@l ", cn4)
cmd4.Parameters.Add("@k", Label29.Text)
cmd4.Parameters.Add("@l", Label15.Text)
Dim da4 As New OleDbDataAdapter(cmd4)
Dim ds4 As New DataSet
da4.Fill(ds4)
'向数据库保存答案
Dim cn5 As New System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=F:/mysite/考试系统/database/Examination.mdb")
Dim cmd5 As New OleDbCommand("select * from answer where answer_id=@a ", cn5)
cmd5.Parameters.Add("@a", Label8.Text)
Dim da5 As New OleDbDataAdapter(cmd5)
Dim ds5 As New DataSet
da5.Fill(ds5)
Session("answer") = ds5.Tables(0).Rows(0)("answer")
Session("user_answer") = ds5.Tables(0).Rows(0)("user_answer")
If Session("answer") = Session("user_answer") Then
Label10.Text = 1
Else
Label10.Text = 0
End If
Dim cn6 As New System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=F:/mysite/考试系统/database/Examination.mdb")
Dim cmd6 As New OleDbCommand("select * from answer where answer_id=@b ", cn6)
cmd6.Parameters.Add("@b", Label9.Text)
Dim da6 As New OleDbDataAdapter(cmd6)
Dim ds6 As New DataSet
da6.Fill(ds6)
Session("answer") = ds6.Tables(0).Rows(0)("answer")
Session("user_answer") = ds6.Tables(0).Rows(0)("user_answer")
If Session("answer") = Session("user_answer") Then
Label11.Text = 1
Else
Label11.Text = 0
End If
Dim cn7 As New System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=F:/mysite/考试系统/database/Examination.mdb")
Dim cmd7 As New OleDbCommand("select * from answer where answer_id=@c ", cn7)
cmd7.Parameters.Add("@c", Label13.Text)
Dim da7 As New OleDbDataAdapter(cmd7)
Dim ds7 As New DataSet
da7.Fill(ds7)
Session("answer") = ds7.Tables(0).Rows(0)("answer")
Session("user_answer") = ds7.Tables(0).Rows(0)("user_answer")
If Session("answer") = Session("user_answer") Then
Label16.Text = 1
Else
Label16.Text = 0
End If
Dim cn8 As New System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=F:/mysite/考试系统/database/Examination.mdb")
Dim cmd8 As New OleDbCommand("select * from answer where answer_id=@d ", cn8)
cmd8.Parameters.Add("@d", Label14.Text)
Dim da8 As New OleDbDataAdapter(cmd8)
Dim ds8 As New DataSet
da8.Fill(ds8)
Session("answer") = ds8.Tables(0).Rows(0)("answer")
Session("user_answer") = ds8.Tables(0).Rows(0)("user_answer")
If Session("answer") = Session("user_answer") Then
Label17.Text = 1
Else
Label17.Text = 0
End If
Dim cn9 As New System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=F:/mysite/考试系统/database/Examination.mdb")
Dim cmd9 As New OleDbCommand("select * from answer where answer_id=@e ", cn9)
cmd9.Parameters.Add("@e", Label15.Text)
Dim da9 As New OleDbDataAdapter(cmd9)
Dim ds9 As New DataSet
da9.Fill(ds9)
Session("answer") = ds9.Tables(0).Rows(0)("answer")
Session("user_answer") = ds9.Tables(0).Rows(0)("user_answer")
If Session("answer") = Session("user_answer") Then
Label18.Text = 1
Else
Label18.Text = 0
End If
Label32.Text = Session("name")
Dim score As Single
score = Val(Label10.Text) + Val(Label11.Text) + Val(Label16.Text) + Val(Label16.Text) + Val(Label18.Text)
Label35.Text = Val(score)
Me.Button1.Visible = False
Dim cn10 As New System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=F:/mysite/考试系统/database/Examination.mdb")
Dim cmd10 As New OleDbCommand("update Basicinfo set score=@z where Examinee_id=@u ", cn10)
cmd10.Parameters.Add("@z", Label35.Text)
cmd10.Parameters.Add("@u", Label2.Text)
Dim da10 As New OleDbDataAdapter(cmd10)
Dim ds10 As New DataSet
da10.Fill(ds10)
教师登陆模块:
这里的界面做的比较简单,只有两个TEXTBOX和两个requiredFieldValidator控件分别对textbox1,textbox2进行验证.不允许2个textbox的值为空(requiredFieldValidator1对textbox1进行验证 , (requiredFieldValidator2对textbox2进行验证)botten用来提交登陆信息并查询数据库,如果有匹配的记录就跳转到Webmanage.aspx页面
并根据不同教师得出不同的权限
Session("pepdom") = ds.Tables(0).Rows(0)("pepdom")
Me.Response.Redirect("Webmanage.aspx")
如果在数据库里查询不到匹配的记录LABEL3将会显示 Label3.Text = "没有这个用户或密码错误!"
代码如下:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cn As New System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=F:/mysite/考试系统/database/teacher.mdb")
Dim cmd As New OleDbCommand("select * from teacher where teacher_id=@i and password=@j ", cn)
cmd.Parameters.Add("@i", TextBox1.Text)
cmd.Parameters.Add("@j", TextBox2.Text)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
Dim pepdom As Integer
da.Fill(ds)
If ds.Tables(0).Rows.Count > 0 Then
Session("pepdom") = ds.Tables(0).Rows(0)("pepdom")
Me.Response.Redirect("Webmanage.aspx")
Else
Label3.Text = "没有这个用户或密码错误!"
End If
End Sub
教师管理模块:
这里只有简单的四个HyperLink,但不同权限登陆的教师这里显示的情况是不同的:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim pepdom As Integer
If IsPostBack = False Then
If Session("pepdom") = 1 Then
Me.HyperLink4.Visible = False
End If
If Session("pepdom") = 2 Then
Me.HyperLink2.Visible = False
Me.HyperLink4.Visible = False
End If
End If
End Sub
在考生管理页面
DataGrid1控件用来显示所以考生的信息
Textbox1用来输入要查找的考生:在查找后DataGrid1只显示查找考生的信息,IMAGE用来显示考生的照片
代码如下:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
Dim cn As New System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=F:/mysite/考试系统/database/Examination.mdb")
Dim cmd As New OleDbCommand("select * from Basicinfo", cn)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds)
DataGrid1.DataSource = ds
DataGrid1.DataBind()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cn As New System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=F:/mysite/考试系统/database/Examination.mdb")
Dim cmd As New OleDbCommand("select examinee_id as 准考证号,name as 姓名,sex as 性别, age as 年龄,test_room as 考场, user_img as 考生照片,text as 考题,score as 考试成绩 from Basicinfo where Examinee_id=@i", cn)
cmd.Parameters.Add("@i", TextBox1.Text)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds)
DataGrid1.DataSource = ds
DataGrid1.DataBind()
Image1.ImageUrl = ds.Tables(0).Rows(0)("考生照片")
End Sub
添加考生页面
该页面用于添加考生,把输入TEXTBOX的信息保存到数据库中
代码如下:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cn As New System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=F:/mysite/考试系统/database/Examination.mdb")
Dim cmd As New OleDbCommand("insert into Basicinfo(Examinee_id,name,sex,age,test_room) values(@a,@b,@c,@d,@e)", cn)
cmd.Parameters.Add("@a", TextBox1.Text)
cmd.Parameters.Add("@b", TextBox2.Text)
cmd.Parameters.Add("@c", TextBox3.Text)
cmd.Parameters.Add("@d", TextBox4.Text)
cmd.Parameters.Add("@e", TextBox5.Text)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds)
End Sub
版权所有:卢彦