Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize online Senior High School examination system by Java

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces Java how to achieve online high school examination system, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

The project is divided into the foreground and the backstage, the foreground is mainly for the student role, and the backstage is mainly for the administrator role.

The administrator adds test questions and publishes test papers, and students are responsible for online exams, online viewing of scores and lists of wrong questions, and so on.

Administrator functions are: grade management, curriculum management, test questions management, test paper management, student management and so on.

Running environment: jdk1.8, mysql5.x, eclipse, tomcat8.5\ 7.0, maven3.5\ 3.6.

Unified management of student teacher administrator information:

/ * uniformly manage student and teacher administrator information * / @ RestControllerpublic class UserController {@ Resource (name = "userService") private IUserService userService; / * query user information * first determine the user type and query user information * / @ RequestMapping (value = "/ user/qryUserInfo", method = RequestMethod.POST, produces = {"application/json") Charset=UTF-8 "}) public Result qryUserInfo () {return userService.qryUserInfo ();} / * Update user information * / @ 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") Update user password * / @ 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"));}}

Administrator Controller:

/ * Administrator Controller * / @ RestControllerpublic class AdminController {@ Resource (name = "adminService") private IAdminService adminService; / * Administrator query administrator list * / @ RequestMapping (value = "/ admin/qryPage", method = RequestMethod.POST, produces = {"application/json" Charset=UTF-8 "}) @ RoleAnnotation (types = {RoleEnum.admin}) public ListResult qryPage (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) } / * administrators add administrators * / @ 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") } / * administrator updates administrator * / @ 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") } / * Administrator Deletes Administrator * / @ 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 (); iTunes +) {adminIdList.add (array.getString (I));} return adminService.del (adminIdList);}}

Exam Management Controller:

/ * examination management controller * / @ RestControllerpublic class ExamInfoController {@ Resource (name = "examInfoService") private IExamInfoService examInfoService; / * teacher query exam list * / @ RequestMapping (value = "/ examinfo/qryPage", method = RequestMethod.POST, produces = {"application/json" Charset=UTF-8 "}) @ RoleAnnotation (types = {RoleEnum.teacher}) public ListResult exam (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);} / * * teacher adds new examination information * / @ 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 (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);} / * * teacher updates examination information * / @ 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 ()) The examination information of return examInfoService.update (exam);} / * can be deleted * / @ 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 (); iTunes +) {examIdList.add (array.getInteger (I));} return examInfoService.del (examIdList) } / * teacher publishes examination information * / @ 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")) } / * students query the grouping list of examination questions * / @ 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")) } / * students query the list of examination questions * / @ 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 ")) } / * teacher judges the paper to query the list of test questions * / @ 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 ")) } / * teacher records student test scores 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) } / * teacher completed rating * / @ 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"));}}

Log in to the control layer:

@ RestControllerpublic class LoginController {@ Resource (name = "loginService") private ILoginService loginService; / * user login call generates two token after login and returns their home page * * student student/student * * teacher teacher/teacher * * administrator admin/admin * / @ RequestMapping (value = "/ login/login", method = RequestMethod.POST, produces = {"application/json" Charset=UTF-8 "}) public Result login (HttpRequest request) {return loginService.login (request.getString (" login_name "), request.getString (" pwd "));} / * * login check * / @ RequestMapping (value =" / login/check ", method = RequestMethod.POST, produces = {" application/json;charset=UTF-8 "}) public Result check () {return new Result () } / * token renewal * / @ 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 ((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 ((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) } / * exit the system * / @ 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 ();}} Thank you for reading this article carefully. I hope the article "how to implement the online High School examination system in Java" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report