Java如何实现在线高中考试系统(java,开发技术)

时间:2024-04-29 11:58:22 作者 : 石家庄SEO 分类 : 开发技术
  • TAG :

项目分为前台和后台,前台主要为学生角色、后台主要为管理员角色。

管理员添加试题和发布试卷,学生负责在线考试、在线查看成绩和错题记录列表等。

管理员功能有:年级管理、课程管理、试题管理、试卷管理、学生管理等。

运行环境:jdk1.8、mysql5.x、eclipse、tomcat8.5\7.0、maven3.5\3.6。

Java如何实现在线高中考试系统

Java如何实现在线高中考试系统

Java如何实现在线高中考试系统

Java如何实现在线高中考试系统

Java如何实现在线高中考试系统

Java如何实现在线高中考试系统

统一管理学生 教师 管理员信息:

/***统一管理学生教师管理员信息*/@RestControllerpublicclassUserController{@Resource(name="userService")privateIUserServiceuserService;/***查询用户信息*先判断用户类型在查询用户信息*/@RequestMapping(value="/user/qryUserInfo",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})publicResult<User>qryUserInfo(){returnuserService.qryUserInfo();}/***更新用户信息*/@RequestMapping(value="/user/update",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})publicResult<User>update(HttpRequestrequest){Useruser=newUser();user.setUserId(request.getString("user_id"));user.setName(request.getString("name"));user.setSex(request.getInteger("sex"));user.setType(User.UserType.get(request.getInteger("type")));returnuserService.update(user,ImageUtil.stringToBytes(request.getString("user_image")));}/***更新用户密码*/@RequestMapping(value="/user/updatePwd",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})publicResult<User>updatePwd(HttpRequestrequest){returnuserService.updatePwd(request.getString("old_pwd"),request.getString("pwd"));}}

管理员控制器:

/***管理员控制器*/@RestControllerpublicclassAdminController{@Resource(name="adminService")privateIAdminServiceadminService;/***管理员查询管理员列表*/@RequestMapping(value="/admin/qryPage",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})@RoleAnnotation(types={RoleEnum.admin})publicListResult<Admin>qryPage(HttpRequestrequest){Map<String,Object>param=newHashMap<>();intpageNo=request.containsKey("page_no")?request.getInteger("page_no"):1;intpageSize=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"));}returnadminService.qryPage(param,pageNo,pageSize);}/***管理员添加管理员*/@RequestMapping(value="/admin/add",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})@RoleAnnotation(types={RoleEnum.admin})publicResult<Admin>insert(HttpRequestrequest){Adminadmin=newAdmin();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(newDate());returnadminService.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})publicResult<Admin>update(HttpRequestrequest){Adminadmin=newAdmin();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(newDate());returnadminService.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})publicResult<Admin>del(HttpRequestrequest){List<String>adminIdList=newArrayList<>();JSONArrayarray=request.getJSONArray("admin_id_list");for(inti=0;i<array.size();i++){adminIdList.add(array.getString(i));}returnadminService.del(adminIdList);}}

考试管理控制器:

/***考试管理控制器*/@RestControllerpublicclassExamInfoController{@Resource(name="examInfoService")privateIExamInfoServiceexamInfoService;/***教师查询考试列表*/@RequestMapping(value="/examinfo/qryPage",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})@RoleAnnotation(types={RoleEnum.teacher})publicListResult<ExamInfo>exam(HttpRequestrequest){Map<String,Object>param=newHashMap<>();intpageNo=request.containsKey("page_no")?request.getInteger("page_no"):1;intpageSize=request.containsKey("page_size")?request.getInteger("page_size"):20;returnexamInfoService.qryPage(param,pageNo,pageSize);}/***教师添加新的考试信息*/@RequestMapping(value="/examinfo/add",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})@RoleAnnotation(types={RoleEnum.teacher})publicResult<ExamInfo>insert(HttpRequestrequest){ExamInfoexam=newExamInfo();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(newDate());returnexamInfoService.insert(exam);}/***教师更新考试信息*/@RequestMapping(value="/examinfo/update",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})@RoleAnnotation(types={RoleEnum.teacher})publicResult<ExamInfo>update(HttpRequestrequest){ExamInfoexam=newExamInfo();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(newDate());exam.setUpdateTime(newDate());returnexamInfoService.update(exam);}/***教师新建状态的考试信息可以删除*/@RequestMapping(value="/examinfo/del",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})@RoleAnnotation(types={RoleEnum.teacher})publicResult<ExamInfo>del(HttpRequestrequest){List<Integer>examIdList=newArrayList<>();JSONArrayarray=request.getJSONArray("exam_id_list");for(inti=0;i<array.size();i++){examIdList.add(array.getInteger(i));}returnexamInfoService.del(examIdList);}/***教师发布考试信息*/@RequestMapping(value="/examinfo/release",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})@RoleAnnotation(types={RoleEnum.teacher})publicResult<ExamInfo>updateState(HttpRequestrequest){returnexamInfoService.release(request.getInteger("exam_id"));}/***学生查询考试试题分组列表*/@RequestMapping(value="/examinfo/qryExamQueGroupList",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})@RoleAnnotation(types={RoleEnum.student,RoleEnum.teacher})publicResult<TestPaperQuestionGroup>qryExamQueGroupList(HttpRequestrequest){returnexamInfoService.qryExamQueGroupList(request.getInteger("exam_id"));}/***学生查询考试试题列表*/@RequestMapping(value="/examinfo/qryExamQuestionList",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})@RoleAnnotation(types={RoleEnum.student})publicResult<StudentExamQuestionRecord>qryExamQuestionList(HttpRequestrequest){returnexamInfoService.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})publicResult<StudentExamQuestionRecord>qryMarkQueList(HttpRequestrequest){returnexamInfoService.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})publicResult<ExamInfo>updateQueScore(HttpRequestrequest){StudentExamQuestionRecordrecord=newStudentExamQuestionRecord();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"));returnexamInfoService.updateQueScore(record);}/***教师完成评分*/@RequestMapping(value="/examinfo/complete",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})@RoleAnnotation(types={RoleEnum.teacher})publicResult<ExamInfo>complete(HttpRequestrequest){returnexamInfoService.complete(request.getInteger("exam_id"),request.getString("student_id"));}}

登录控制层:

@RestControllerpublicclassLoginController{@Resource(name="loginService")privateILoginServiceloginService;/***用户登录调用在登陆成功生成两个token同时返回各自首页**学生student/student**老师teacher/teacher**管理员admin/admin*/@RequestMapping(value="/login/login",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})publicResult<Token>login(HttpRequestrequest){returnloginService.login(request.getString("login_name"),request.getString("pwd"));}/***登录检查*/@RequestMapping(value="/login/check",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})publicResult<Token>check(){returnnewResult<>();}/***token续约*/@RequestMapping(value="/login/refresh",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})publicResult<Token>refresh(HttpRequestrequest){StringrefreshToken=request.getString("refresh_token");StringurlId=request.getString("url_id");Tokentoken=TokenCache.getInstance().get(urlId);if(token==null){ExceptionHelper.error(ErrorCode.ERROR_CODE_0003);}try{Claimsclaims=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(Exceptione){ExceptionHelper.error(ErrorCode.ERROR_CODE_0003);}returnnewResult<>(token);}/***退出系统*/@RequestMapping(value="/login/exit",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})publicResult<Token>exit(HttpRequestrequest){StringurlId=request.getString("url_id");if(StringUtils.isNotEmpty(urlId)){TokenCache.getInstance().remove(urlId);}returnnewResult<>();}}
 </div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:Java如何实现在线高中考试系统的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:Java如何实现医院预约挂号系统下一篇:

16 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18