收藏 分销(赏)

在线考试系统JAVA.doc

上传人:天**** 文档编号:4342944 上传时间:2024-09-08 格式:DOC 页数:14 大小:177.50KB 下载积分:8 金币
下载 相关 举报
在线考试系统JAVA.doc_第1页
第1页 / 共14页
在线考试系统JAVA.doc_第2页
第2页 / 共14页


点击查看更多>>
资源描述
题目 在线考试系统 1、 实验目得 ①熟练运用JAVA开发环境及工具、并用JAVA语言编写程序; ②掌握面向对象得概念; ③掌握系统功能模块得合理划分,并实现各模块接口得连接; ④掌握C/S结构得编程方法; ⑤设计数据库模型。 2、 实验内容 ①编辑生成试题库,随机生成本次考试试题,同时提供在线评分并保存结果。 ②选择ACCESS作为后台得数据库。 3、 实验过程 在线考试系统 信息管理 评卷管理 试卷管理 题库管理 成绩管理 考试管理 用户管理 权限管理 3、1 系统模块部分设计 题库管理:用于对单个试题得增、删、改、查等基本维护,还可对题库进行数据备份与数据还原。我们针对不同题型、不同应用范围及不同科目对试题进行维护。 试卷管理:可进行三种组卷方式得维护:随机组卷、人工组卷、综合组卷。还可对考生得基本信息进行维护。 考试管理:对考试分配试卷,并对考试得基本信息进行维护。相当于人工安排考试得过程 评卷管理:对试卷得客观题分配评卷人,并对评卷人基本信息进行管理。 成绩管理:对每次考试得学生成绩得基本信息进行维护,并提供学生成绩得统计管理。 用户管理:对使用本系统得用户基本信息进行维护,用户多数为:系统管理员、老师、教务处人员、其她 权限管理:对系统得访问权限进行管理,并对用户可进行权限得分配。 系统应该具备得基本功能 各模块需完成以下功能: 题库管理 试卷管理 试卷其她维护 试卷信息维护 其它 维护 试题 维护 基本 维护 综合组卷 人工组卷 随机组卷 题型维护 科目维护 范围维护 题型维护:对试题得题型进行增、删、改、查操作。在操作之后会自动刷新主页,以使信息更新。 范围维护:对试题得应用范围进行增、删、改、查操作。在操作之后会自动刷新主页,以使信息更新。 科目维护:对试题得科目进行增、删、改、查操作。在操作之后会自动刷新主页,以使信息更新。 试题维护:对试题得基本信息进行增、删、改、查操作。在操作之后会自动刷新主页,以使信息更新。 其她维护:对试题信息得批量查询,并可进行数据导出、数据备份、数据恢复。 随机组卷:用户只需对试卷题型进行设置就可组卷得方式。 人工组卷:可使用户选择试卷得题型中得试题得组卷方式。 综合组卷:就是随机组卷与人工组卷得混合组卷方式,即用户对某一类型得试题可进行选择,也可对试题不进行选择。 试卷其她维护:对试卷信息得批量查询,对试题得数据备份与还原。 考试管理 考试信息维护 分配评卷人 评卷管理 成绩管理 评卷人评卷 考生信息维护 考生成绩维护 成绩其她维护 考试信息维护:对考试得时间、地点、监考人、考试用得试卷、试卷总分数及答卷总时间等考试得基本要素进行设置。 考生信息维护:对考试得学生得基本信息进行增、删、改、查操作,在操作之后会自动刷新主页,以使信息更新。 分配评卷人:对考试所用试卷得客观题分配评卷人,并对评卷得基本信息进行维护。 评卷人评卷:对分配试卷得评卷人可以在此进行评卷。 考生成绩维护:对考试得考生成绩信息进行统计与汇总,对有权限得人可进行成绩得增、删、改、查操作。 成绩其她维护:对考生成绩信息得批量查询,并可进行数据导出、数据备份、数据恢复。 用户管理 权限管理 信息管理 权限信息维护 用户基本信息 信息基本维护 用户分配权限 用户基本信息维护:对使用本系统得用户进行维护,而用户得权限由权限管理进行维护,并分配给用户,使用户只能访问自己拥有得权限内。 权限信息维护:对基本得权限进行维护,用户可自定义维护权限。 用户分配权限:对未分配权限得用户进行权限得分配,即对 分配权限得增、删、改、查操作。 信息基本维护:我们得信息除了有关考试得信息外,还有公告、新闻、留言信息需要我们维护,其中公告、新闻由后台有权限得人进行增、删、改、查操作,而留言就是由前台得用户(学生)或游客录入得,我们要防止垃圾数据显示,即对留言有权更改等操作。 3、2系统结构图 、本系统分为学生前台子系统与考试管理子系统,整个系统得结构图如下: 在线考试系统 考生前 台 后台管 理 题库管理 评卷管理 考试管理 试卷管理 成绩管理 用户管理 权限管理 学生登陆 3、3 数据库设计 试题类型表(questionType_table):其中包括了试题得类型得基本信息,如类型名称、答题方式、说明信息等字段;录入时,我们将答题方式确定为大概几种类型:填空方式,选择方式,问答方式,判断方式,综合方式。 试题范围表(questionBound_table):用于控制试题应用得范围,如同样得科目语文,在小学、初中、高中、大学都有,由此我们设定了此表,此表中有范围名称、范围说明等基本信息; 所属科目表(questionSubject_table):用于录入试题相关得科目应用,它可以有不同得应用范围。如上所述,我们只需录入一次得科目,就可方便我们在录入试题时每次都录。各种题库表:我们采用一种类型得题存储在一个表中,由此我们会有填空题表(question_blanc_table)、单选题表(question_selectone_table)、多选题表(question_selectMany_tabel)一题多问表(question_askone_table)、一题多问表(question_askMany_table)、判断题表(question_judge_table)等试题表 试卷表(exam_table):用于报存考试中试卷得基本信息,如出卷方式(有随机出卷、人工出卷、综合出卷)、试卷名称、试卷应用范围(与试题范围相对应)、试卷所属科目(与试题科目相对应)、试题标题级别、试题标题内容、试题总类型、试题个数、试题总ID等基本信息。 学生表(student_table):用于保存学生得考试得用户名及登陆密码。 成绩表(grade_table):用于存储学生得考试成绩。 评题表(appraiser_question_table):对于主观题得答案我们须要评卷人(有权限得用户)进行手工评卷,本表用来存储评卷人评卷得一些信息。 答案表(student_answer_table):用于存储学生问答题得答案,如试卷ID,学生ID及各种试题类型得答案字段。 用户表(user_table):用于保存用户得登陆得基本信息及分配得权限。 权限表(purview_table):用于存储用户组织得得权限,通过分配操作模块得权限组织权限。 4、 关键代码及其分析 4、1----------------ServerGui、java------------------ public void actionPerformed(ActionEvent e) { if (e、getSource() == log) { // boolean b=login(); String username = JOptionPane、showInputDialog(this, "请输入用户名", "输入用户名", JOptionPane、QUESTION_MESSAGE)、trim(); String password = JOptionPane、showInputDialog(this, "请输入密码", "输入密码", JOptionPane、QUESTION_MESSAGE)、trim(); if (username == null || password == null) { username = "temp"; password = "temp"; return; } adminCheck(username, password);// 验证管理员 if (tf == true) { JOptionPane、showMessageDialog(this, "登陆成功!", "成功", JOptionPane、INFORMATION_MESSAGE); toolBar1、setVisible(true); split_one、setVisible(true); } else { JOptionPane、showMessageDialog(this, "登陆失败!", "失败", JOptionPane、ERROR_MESSAGE); return; } } else if (e、getSource() == setCount) { userCount = JOptionPane、showInputDialog(this, "请输入本次考试得人数"); inittest(); // 数据库信息初始化 } else if (e、getSource() == startSer) { if (settime == true && setcount == true) { new ServerManager(); serArea、append("服务器已启动\n预设考试人数为:" + userCount + "\n考试时间为:" + timeCount + "\n"); start = true; } else { JOptionPane、showMessageDialog(this, "您还没有设置考试信息", "警告信息", JOptionPane、INFORMATION_MESSAGE); } } if (start == true) { linkArea、append(ServerManager 、linkShow(ServerManager、linkstatus) + "\n"); } else { JOptionPane、showMessageDialog(this, "服务器还没有启动不能进行操作", "警告信息", JOptionPane、INFORMATION_MESSAGE); } } else if (e、getSource() == userButton) { if (start == true) { userArea、append(ServerManager 、userShow(ServerManager、userstatus) + "\n"); userArea、append(ServerManager、countShow(ServerManager、ucount)); } else { public void adminCheck(String s1, String s2) ConnectBean cb=new ConnectBean(); if (!cb、openConnection()) { System、out、println("连接数据失败"); System、exit(1); return; } 4、2-----------------Server_login、java----------------- // 定义一个接收用户登陆得类 public void run() { String s = null; try { s = in、readUTF(); // 接收考试号与密码,然后分别取出 StringTokenizer st = new StringTokenizer(s, ","); if (st、hasMoreTokens()) { str1 = st、nextToken(); str2 = st、nextToken(); System、out、println("username :" + str1); System、out、println("password :" + str2); } } catch (IOException e) { e、printStackTrace(); } // 读取数据库里得用户信息 并进行验证 try { ConnectBean cb = new ConnectBean(); if (!cb、openConnection()) { System、out、println("连接数据失败"); System、exit(1); return; } cb、createPreparedStatement("select flag from stuinfo where sno='" + str1 + "' ResultSet r = cb、executeQuery(); String m =""; while (r、next()) { m=r、getString("flag"); } System、out、println("标识:"+m); if ( !m、equals("0") ) { out、writeUTF("用户已经完成考试,不能再考试"); } else { cb、createPreparedStatement( "select sname,spass from stuinfo where sno='" + str1 + "'", false); ResultSet rs = cb、executeQuery(); while (rs、next()) { dbn = rs、getString("sname"); dbp = rs、getString("spass"); System、out、println("用户: " + str1 + " 您得用户名为:" + dbn + ", 您得密码为:" + dbp); } // 验证用户密码,如果登录成功将登录标志设为1 if (str2、equals(dbp、trim())) { out、writeUTF("用户 " + dbn + " 登陆成功"); System、out、println("用户 " + dbn + " 登陆成功"); out、close(); String sql1 = "update stuinfo set flag = '1' where sno= '"+str1+"'"; PreparedStatement ps = cb、createPreparedStatement(sql1); ps、executeUpdate(); System、out、println("用户成功登录"); } else { out、writeUTF("密码错误"); System、out、println("登陆密码错误"); out、close(); } cb、close(); 4、3-----------------ServerManager、java---------------- public ServerManager() { Thread td1 = new Thread() { public void run() { serstatus= "login thread start!\n"; serShow(serstatus); ServerSocket ss1 = null; Socket you = null; int port1 = 8001; try { ss1 = new ServerSocket(port1); serstatus = "listener the port:" + port1; serShow(serstatus); } catch (IOException e) { e、printStackTrace(); } while (true) { try { you = ss1、accept(); } catch (IOException e) { e、printStackTrace(); } if (you != null) { counter++; ucount = "现在参加考试得人数为:" + counter; countShow(ucount); if (counter < Maxcount) { userstatus= "user's IP" + you、getInetAddress() + " connected " + port1 + "进行登陆"; userShow(userstatus); // 第一个线程启动 new Server_login(you)、start(); } else { userstatus = "user's IP" + you、getInetAddress() + " connected " + port1 + "中断线程启动"; userShow(userstatus); // 中断线程启动 new Maxcounter(you); }; td1、start(); // 启动一个响应客户端读取试题得线程 Thread td2 = new Thread("two") { public void run() { serstatus= "thread 2 start!"; serShow(linkstatus); ServerSocket ss2 = null; int port2 = 8002; try { ss2 = new ServerSocket(port2); linkstatus = "listener the port:" + port2; linkShow(serstatus); } catch (IOException e) { e、printStackTrace(); } while (true) { Socket you2 = null; try { you2 = ss2、accept(); } catch (IOException e) { e、printStackTrace(); } if (you2 != null) { userstatus = "user's IP" + you2、getInetAddress() + " connected " + port2 + "进行读题"; userShow(userstatus); new Server_readTest(you2)、start(); }}} }; td2、start() // 启动一个接收用户答应并存储得线程 Thread td3 = new Thread("three") { ServerSocket ss3 = null; int port3 = 8003; public void run() { serstatus="thread 3 start!"; serShow(serstatus); try { ss3 = new ServerSocket(port3); linkstatus="listener the port:" + port3; linkShow(linkstatus); } catch (IOException e) { e、printStackTrace(); } while (true) { Socket you3 = null; try { you3 = ss3、accept(); } catch (IOException e) { e、printStackTrace(); } if (you3 != null) { userstatus="user's IP" + you3、getInetAddress() + " connected " + port3 + "提交答案"; userShow(userstatus); // 第3个线程启动 new Server_readScore(you3)、start(); } } } }; td3、start(); // 启动一个用户查询得线程 Thread td4 = new Thread("four") { ServerSocket ss4 = null; int port4 = 8004; public void run() { serstatus="thread 4 start!"; serShow(serstatus); try { ss4 = new ServerSocket(port4); linkstatus="listener the port:" + port4; linkShow(linkstatus); } catch (IOException e) { e、printStackTrace(); } while (true) { Socket you4 = null; try { you4 = ss4、accept(); } catch (IOException e) { e、printStackTrace(); } if (you4 != null) { userstatus="user's IP" + you4、getInetAddress() + " connected " + port4 + "进行查询"; userShow(userstatus); 4、4-------------Server_readTest、java---------------- public void run() { String sql2; // 定义查询语句 String dbt = "以下为试题"; // 试题 String ts = null; // 接收用户发送得考试科目 int tcount = 0; // 试题得数目 try { // 网络连接部分 out、writeUTF("您连接成功"); ts = in、readUTF(); System、out、println(ts); // 数据库连接部分 // 查询客户端所选试题 ConnectBean cb = new ConnectBean(); if (!cb、openConnection()) { System、out、println("连接数据失败"); System、exit(1); return; } //在数据库选题 sql2 = "select * from exam where eid='" + ts + "'"; cb、createPreparedStatement(sql2, false); ResultSet rs = cb、executeQuery(); while (rs、next()) { dbt += "^"+"\n"+rs、getString(2) + "\t" + "\n" + rs、getString(3) +" ^"; tcount++; } cb、close(); System、out、println(dbt); System、out、println(tcount); out、writeUTF(Integer、toString(tcount)); out、writeUTF(dbt); // 将读到得试题返回到客户端 //传送考试时间 out、writeUTF(""+Timecount); out、flush(); out、close(); System、out、println("读取试题成功!!"); } catch (SQLException e) { e、printStackTrace(); System、out、println("not connect db"); } catch (IOException e1) { System、out、println("not read client select!"); } } 4、5--------------/Server_readScore、java------------------ // 定义一个接收用户答案得类,判断对错,将分数返回到用户端,并将成绩存入数据库 public Server_readScore(Socket socket) { // ----------------------创建网络连接----------------------------------// this、socket = socket; 、、、、、、、、、 public void run() { // ------------------------- 接收用户提交得答案---------------------------// try { readkey = in、readUTF(); System、out、println(readkey); } catch (IOException e1) { e1、printStackTrace(); } StringTokenizer stc = new StringTokenizer(readkey, ","); if (stc、hasMoreTokens()) { // 客户传来答案得第一个字符为用户名,第二个字符为考试科目 str1 = stc、nextToken()、trim(); System、out、println("用户为:" + str1); uno = Integer、parseInt(str1); } if (stc、hasMoreTokens()) { //第二个字符为考试科目 str2 = stc、nextToken()、trim(); System、out、println("试题类型为:" + str2); } 、、、、、、、、、、、、、、、、 // ------------------------------在数据库获取正确答案-------------------------// try { ConnectBean cb = new ConnectBean(); if (!cb、openConnection()) { System、out、println("连接数据失败"); System、exit(1); return; } 、、、、、、、、、、、、、、 } // ------------------------判断分数---------------------------------// for (int i = 0; i <Integer、parseInt(str4); i++) { if (userAnswer[i]、equals(crreAnswer[i])) { count += 10; } } System、out、println("用户:" + str1 + ",您得得分为:" + count); // 将分数返回到客户端 try { out、writeUTF(Integer、toString(count)); System、out、println("将分数返回到客户端"); out、flush(); out、close(); } catch (IOException e) { e、printStackTrace(); } // ------------------------将分数存到数据库------------------------------// try { ConnectBean cb = new ConnectBean(); if (!cb、openConnection()) { System、out、println("连接数据失败"); System、exit(1); return; } PreparedStatement ps = cb、createPreparedStatement(subject); ps、setInt(1, count); ps、setInt(2, uno); ps、executeUpdate(); System、out、println("更新成功"); cb、commit(); cb、close(); } catch (SQLException e) { // TODO 自动生成 catch 块 System、out、println("写入数据发生错误!!!/n" + e); } } 4、6-------------------------Server、java---------------------- 、、、、、、、、、、、、 public static void main(String args[]) { new Server(); 、、、、、、、、、 } } 4、7--------------------TestGui、java------------------- public void actionPerformed(ActionEvent e) { if (e、getSource() == callIP) { // 呼叫服务器 if (socket != null && in != null && out != null) // 消除以往得连接信息 { try { socket、close(); in、close(); out、close(); } catch (Exception ee) { } } String login = user + "," + pass; int port1 = 8001; try { // 建立网络连接 socket = new Socket(ip, port1); in = new DataInputStream(socket、getInputStream()); out = new DataOutputStream(socket、getOutputStream()); out、writeUTF(login); } catch (IOException ee) // 如果连接失败 { ipField、setText("呼叫失败"); stateField、setText("您呼叫没有成功"); } int port4 = 8004; try { socket = new Socket(ip, port4); in = new DataInputStream(socket、getInputStream()); out = new DataOutputStream(socket、getOutputStream()); out、writeUTF(user); stuinfo、setText("请求信息已发送"); } catch (IOException ee) // 如果连接失败 { ipField、setText("呼叫失败"); stateField、setText("您呼叫没有成功"); stuinfo、setText("您呼叫没有成功"); } if (socket != null) // 如果连接成功 { try { String queryInfo = in、readUTF(); // 得到查询结果 stuinfo、setText(queryInfo); out、flush(); out、close(); } catch (IOException e1) { // 出现异常 otherinfo、setText("数据传输错误"); } } } else if (e、getSource()
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 考试专区 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4009-655-100  投诉/维权电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服