Java如何实现在线高中考试系统
发表于:2025-01-17 作者:千家信息网编辑
千家信息网最后更新 2025年01月17日,这篇文章主要介绍了Java如何实现在线高中考试系统,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。项目分为前台和后台,前台主要为学生角色
千家信息网最后更新 2025年01月17日Java如何实现在线高中考试系统
这篇文章主要介绍了Java如何实现在线高中考试系统,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。
项目分为前台和后台,前台主要为学生角色、后台主要为管理员角色。
管理员添加试题和发布试卷,学生负责在线考试、在线查看成绩和错题记录列表等。
管理员功能有:年级管理、课程管理、试题管理、试卷管理、学生管理等。
运行环境:jdk1.8、mysql5.x、eclipse、tomcat8.5\7.0、maven3.5\3.6。
统一管理学生 教师 管理员信息:
/** * 统一管理学生 教师 管理员信息 */@RestControllerpublic class UserController { @Resource(name = "userService") private IUserService userService; /** * 查询用户信息 * 先判断用户类型 在查询用户信息 */ @RequestMapping(value = "/user/qryUserInfo", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public ResultqryUserInfo() { return userService.qryUserInfo(); } /** * 更新用户信息 */ @RequestMapping(value = "/user/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public Result update(HttpRequest request) { User user = new User(); user.setUserId(request.getString("user_id")); user.setName(request.getString("name")); user.setSex(request.getInteger("sex")); user.setType(User.UserType.get(request.getInteger("type"))); return userService.update(user, ImageUtil.stringToBytes(request.getString("user_image"))); } /** * 更新用户密码 */ @RequestMapping(value = "/user/updatePwd", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public Result updatePwd(HttpRequest request) { return userService.updatePwd(request.getString("old_pwd"), request.getString("pwd")); }}
管理员控制器:
/** * 管理员控制器 */@RestControllerpublic class AdminController { @Resource(name = "adminService") private IAdminService adminService; /** * 管理员 查询管理员列表 */ @RequestMapping(value = "/admin/qryPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.admin}) public ListResultqryPage(HttpRequest request) { Map param = new HashMap<>(); int pageNo = request.containsKey("page_no") ? request.getInteger("page_no") : 1; int pageSize = request.containsKey("page_size") ? request.getInteger("page_size") : 20; if (request.containsKey("login_name")) { param.put("login_name", request.getString("login_name")); } if (request.containsKey("name")) { param.put("name", request.getString("name")); } return adminService.qryPage(param, pageNo, pageSize); } /** * 管理员 添加管理员 */ @RequestMapping(value = "/admin/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.admin}) public Result insert(HttpRequest request) { Admin admin = new Admin(); admin.setLoginName(request.getString("login_name")); admin.setName(request.getString("admin_name")); admin.setPwd(request.getString("login_name")); admin.setSex(request.getInteger("sex")); admin.setUpdateTime(new Date()); return adminService.insert(admin, ImageUtil.stringToBytes(request.getString("admin_image"))); } /** * 管理员 更新管理员 */ @RequestMapping(value = "/admin/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.admin}) public Result update(HttpRequest request) { Admin admin = new Admin(); admin.setLoginName(request.getString("login_name")); admin.setName(request.getString("admin_name")); admin.setPwd(request.getString("login_name")); admin.setSex(request.getInteger("sex")); admin.setUpdateTime(new Date()); return adminService.update(admin, ImageUtil.stringToBytes(request.getString("admin_image"))); } /** * 管理员 删除管理员 */ @RequestMapping(value = "/admin/del", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.admin}) public Result del(HttpRequest request) { List adminIdList = new ArrayList<>(); JSONArray array = request.getJSONArray("admin_id_list"); for (int i = 0; i < array.size(); i++) { adminIdList.add(array.getString(i)); } return adminService.del(adminIdList); }}
考试管理控制器:
/** * 考试管理控制器 */@RestControllerpublic class ExamInfoController { @Resource(name = "examInfoService") private IExamInfoService examInfoService; /** * 教师 查询考试列表 */ @RequestMapping(value = "/examinfo/qryPage", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.teacher}) public ListResultexam(HttpRequest request) { Map param = new HashMap<>(); int pageNo = request.containsKey("page_no") ? request.getInteger("page_no") : 1; int pageSize = request.containsKey("page_size") ? request.getInteger("page_size") : 20; return examInfoService.qryPage(param, pageNo, pageSize); } /** * 教师 添加新的考试信息 */ @RequestMapping(value = "/examinfo/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.teacher}) public Result insert(HttpRequest request) { ExamInfo exam = new ExamInfo(); exam.setTestPaperId(request.getInteger("test_paper_id")); exam.setClassId(request.getString("class_id")); exam.setState(1); exam.setTime(request.getInteger("time")); exam.setEffTime(DateUtils.toDate(request.getString("eff_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI)); exam.setExpTime(DateUtils.toDate(request.getString("exp_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI)); exam.setUpdateTime(new Date()); return examInfoService.insert(exam); } /** * 教师 更新考试信息 */ @RequestMapping(value = "/examinfo/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.teacher}) public Result update(HttpRequest request) { ExamInfo exam = new ExamInfo(); exam.setExamId(request.getInteger("exam_id")); exam.setTestPaperId(request.getInteger("test_paper_id")); exam.setClassId(request.getString("class_id")); exam.setState(1); exam.setTime(request.getInteger("time")); exam.setEffTime(DateUtils.toDate(request.getString("eff_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI)); exam.setExpTime(DateUtils.toDate(request.getString("exp_time"), DateConst.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI)); exam.setUpdateTime(new Date()); exam.setUpdateTime(new Date()); return examInfoService.update(exam); } /** * 教师 新建状态的考试信息可以删除 */ @RequestMapping(value = "/examinfo/del", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.teacher}) public Result del(HttpRequest request) { List examIdList = new ArrayList<>(); JSONArray array = request.getJSONArray("exam_id_list"); for (int i = 0; i < array.size(); i++) { examIdList.add(array.getInteger(i)); } return examInfoService.del(examIdList); } /** * 教师 发布考试信息 */ @RequestMapping(value = "/examinfo/release", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.teacher}) public Result updateState(HttpRequest request) { return examInfoService.release(request.getInteger("exam_id")); } /** * 学生 查询考试试题分组列表 */ @RequestMapping(value = "/examinfo/qryExamQueGroupList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.student, RoleEnum.teacher}) public Result qryExamQueGroupList(HttpRequest request) { return examInfoService.qryExamQueGroupList(request.getInteger("exam_id")); } /** * 学生 查询考试试题列表 */ @RequestMapping(value = "/examinfo/qryExamQuestionList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.student}) public Result qryExamQuestionList(HttpRequest request) { return examInfoService.qryExamQuestionList(request.getInteger("exam_id"), request.getString("student_id"), request.getInteger("question_group_id")); } /** * 教师 判卷查询试题列表 */ @RequestMapping(value = "/examinfo/qryMarkQueList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.teacher}) public Result qryMarkQueList(HttpRequest request) { return examInfoService.qryMarkQueList(request.getInteger("exam_id"), request.getString("student_id"), request.getInteger("question_group_id")); } /** * 教师 记录学生考试分数 complete */ @RequestMapping(value = "/examinfo/updateQueScore", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.teacher}) public Result updateQueScore(HttpRequest request) { StudentExamQuestionRecord record = new StudentExamQuestionRecord(); record.setExamId(request.getInteger("exam_id")); record.setStudentId(request.getString("student_id")); record.setQuestionGroupId(request.getInteger("question_group_id")); record.setQuestionId(request.getLong("question_id")); record.setScore(request.getFloat("score")); record.setCorrect(request.getBoolean("correct")); return examInfoService.updateQueScore(record); } /** * 教师 完成评分 */ @RequestMapping(value = "/examinfo/complete", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) @RoleAnnotation(types = {RoleEnum.teacher}) public Result complete(HttpRequest request) { return examInfoService.complete(request.getInteger("exam_id"), request.getString("student_id")); } }
登录控制层:
@RestControllerpublic class LoginController { @Resource(name = "loginService") private ILoginService loginService; /** * 用户登录调用 在登陆成功生成两个token 同时返回各自首页 * * 学生 student/student * * 老师 teacher/teacher * * 管理员 admin/admin */ @RequestMapping(value = "/login/login", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public Resultlogin(HttpRequest request) { return loginService.login(request.getString("login_name"), request.getString("pwd")); } /** * 登录检查 */ @RequestMapping(value = "/login/check", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public Result check() { return new Result<>(); } /** * token 续约 */ @RequestMapping(value = "/login/refresh", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public Result refresh(HttpRequest request) { String refreshToken = request.getString("refresh_token"); String urlId = request.getString("url_id"); Token token = TokenCache.getInstance().get(urlId); if(token == null){ ExceptionHelper.error(ErrorCode.ERROR_CODE_0003); } try { Claims claims = TokenUtils.parseToken(refreshToken); if (StringUtils.isNotEmpty((String.valueOf(claims.getOrDefault("student_id", ""))))) { claims.put("student_id", SessionContext.get("student_id")); } if (StringUtils.isNotEmpty((String.valueOf(claims.getOrDefault("teacher_id", ""))))) { claims.put("teacher_id", SessionContext.get("teacher_id")); } if (StringUtils.isNotEmpty((String.valueOf(claims.getOrDefault("login_name", ""))))) { claims.put("login_name", SessionContext.get("login_name")); } claims.put("name", claims.get("name")); token.setToken(TokenUtils.createToken(claims, TokenUtils.expireTime)); token.setRefreshToken(TokenUtils.createToken(claims, TokenUtils.long_expireTime)); TokenCache.getInstance().add(token); } catch (Exception e) { ExceptionHelper.error(ErrorCode.ERROR_CODE_0003); } return new Result<>(token); } /** * 退出系统 */ @RequestMapping(value = "/login/exit", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public Result exit(HttpRequest request) { String urlId = request.getString("url_id"); if (StringUtils.isNotEmpty(urlId)) { TokenCache.getInstance().remove(urlId); } return new Result<>(); }}
感谢你能够认真阅读完这篇文章,希望小编分享的"Java如何实现在线高中考试系统"这篇文章对大家有帮助,同时也希望大家多多支持,关注行业资讯频道,更多相关知识等着你来学习!
管理
管理员
考试
教师
信息
学生
查询
用户
试题
控制
在线
控制器
篇文章
更新
系统
登录
高中
前台
同时
后台
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
铜陵进销存软件开发平台
北京海信软件开发
构造可持续发展的网络安全空间
keep服务器异常怎么办
广州软件开发机构
数据库中可以有几个主文件组
网络安全技术情报中心
碳数据库标语
你对网络安全现状满意吗
万方数据库遴选期刊
ubuntu搭建svn服务器
递归服务器的功能
网络安全运维优化服务
网络安全训练营晓逸编程达人
报表工具软件开发工程师
android清除数据库
sql改数据库密码修改
网络安全大赛小米退役
数据库可否读取动态标签
页面怎么保存数据库中
merc网络安全密钥
网络安全隐私信息
阿里云智能事业群系统软件开发
绝地求生未来之役香港服务器
益阳数据库营销是什么意思
服务器单用户多窗口
江苏电商软件开发商
驾照被录入数据库
哪里是数据库管理模块
管理linux服务器的