本系统功能包括:
支持单选题、多选题、判断题支持学生(student)、教师(teacher)、管理员(admin)三种角色学生:参加考试和查看我的考试教师:学生的所有权限+创建/编辑题目+创建/编辑考试管理员:教师的所有权限+管理用户。
环境配置:
Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。
项目技术:
Springboot + Maven + Jpa+ Vue 等等组成,B/S模式 + Maven管理等等。
/** * 考试控制层,负责试卷提交等 */@RestController@RequestMapping("/v1/exam")public class ExamController { @Autowired ExamService examService; @Autowired AnswerPaperService answerPaperService; @Autowired AnswerQuestionService answerQuestionService; @Autowired AnswerPaperQuestionService answerPaperQuestionService; @Autowired QuestionService questionService; @Autowired PaperService paperService; @Autowired WrongQuestionService wrongQuestionService; @Autowired PaperAnswerPaperService paperAnswerPaperService; @ApiOperation(value = "根据试卷id和题目编号获取题目信息", notes = "根据题目id获取题目详细信息") @ApiImplicitParams({ @ApiImplicitParam(name = "paperId", value = "试卷ID", required = true, dataType = "String", paramType = "path"), @ApiImplicitParam(name = "number", value = "题目编号", required = true, dataType = "String", paramType = "path") }) @RequestMapping(value = "/questions/{number}", method = RequestMethod.GET) @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')") public Question getQuestionByPaperIdAndQuestionId(@RequestParam String paperId, @RequestParam String username, @RequestParam(required = false) String answerPaperId, @PathVariable Integer number) { Question question = null; AnswerQuestion answerQuestion = null; if(answerPaperId == null) { Paper paper = paperService.getPaperById(paperId); if(paper != null) { AnswerPaper answerPaper = answerPaperService.findByAnswerUserAndPaperName(username, paper.getName()); if(answerPaper != null) { answerQuestion = answerQuestionService.getAnswerQuestionByPaperIdAndQuestionNumber(answerPaper.getId(), number); } } }else { answerQuestion = answerQuestionService.getAnswerQuestionByPaperIdAndQuestionNumber(answerPaperId, number); } if(answerQuestion == null) { question = questionService.getQuestionByPaperIdAndQuestionNumber(paperId, number); if(question != null) { //答案不返回 question.setAnswer(""); } } else { question = new Question(); question.setId(answerQuestion.getId()); question.setNumber(answerQuestion.getNumber()); question.setTitle(answerQuestion.getTitle()); question.setScore(answerQuestion.getScore()); question.setType(answerQuestion.getType()); question.setOptionA(answerQuestion.getOptionA()); question.setOptionB(answerQuestion.getOptionB()); question.setOptionC(answerQuestion.getOptionC()); question.setOptionD(answerQuestion.getOptionD()); question.setAnswer(answerQuestion.getAnswer()); } return question; } @RequestMapping(value = "/submit/{type}/{username}", method = RequestMethod.POST) @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')") public ResponseEntity> submit(@RequestBody Paper paper, @PathVariable String type, @PathVariable String username, @RequestParam(required = false) String answerPaperId) { /** * 更改试卷状态,finished:true */ if(type.equals("official")) { /** * 正式考试 */ AnswerPaper answerPaper = new AnswerPaper(); if(answerPaperId != null) { answerPaper.setId(answerPaperId); }else { return new ResponseEntity@RestController@RequestMapping("/v1/answer-questions")public class AnswerQuestionController { @Autowired AnswerQuestionService answerQuestionService; /** * 获取试卷题目分页列表 * @param paperId * @return */ @RequestMapping(value = "/{paperId}", method = RequestMethod.GET) @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')") public List getAnswerQuestionListByPaper(@PathVariable String paperId) { return answerQuestionService.findByAnswerPaperId(paperId); } @RequestMapping(value = "", method = RequestMethod.PUT) @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')") public ResponseEntity> putPaper(@RequestBody AnswerQuestion answerQuestion) { answerQuestionService.updateAnswerQuestion(answerQuestion); return new ResponseEntity(HttpStatus.OK); }} /** * 答卷控制层,用于获取已经提交的答卷 */@RestController@RequestMapping("/v1/answer-papers")public class AnswerPaperController { @Autowired AnswerPaperService answerPaperService; @Autowired AnswerQuestionService answerQuestionService; /** * 根据ID查找 * @param id * @return */ @RequestMapping(value = "/{id}", method = RequestMethod.GET) @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')") public AnswerPaper getAnswerPaper(@PathVariable String id) { return answerPaperService.getAnswerPaperById(id); } /** * 根据name查找 * @param name * @return */ @RequestMapping(value = "/name/{name}", method = RequestMethod.GET) @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')") public List getAnswerPaperByName(@PathVariable String name) { return answerPaperService.getAnswerPaperFuzzy(name); } /** * 根据答卷id和题目编号获取题目信息 * @param paperId * @param number * @return */ @RequestMapping(value = "/papers/{paperId}/questions/{number}", method = RequestMethod.GET) @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')") public AnswerQuestion getQuestionByPaperIdAndQuestionId(@PathVariable String paperId, @PathVariable Integer number) { AnswerQuestion answerQuestion = answerQuestionService.getAnswerQuestionByPaperIdAndQuestionNumber(paperId, number); return answerQuestion; } /** * 已分页方式获取数据 * @param username * @param pageIndex * @param pageSize * @param limit * @param offset * @return */ @RequestMapping(value = "/users/{username}", method = RequestMethod.GET) @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')") public PageInfo getListByUser(@PathVariable("username") String username, @RequestParam(required = false) Integer pageIndex, @RequestParam(required = false) Integer pageSize, @RequestParam(required = false) Integer limit, @RequestParam(required = false) Integer offset) { if(pageIndex != null && pageSize != null) { PageHelper.startPage(pageIndex, pageSize); } List answerPapers = answerPaperService.getAnswerPaperListByAnswerUser(username); PageInfo pageInfo = new PageInfo(answerPapers); return pageInfo; } @RequestMapping(value = "/users/{username}/type/{type}", method = RequestMethod.GET) @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')") public PageInfo getListByUserAndType(@PathVariable("username") String username, @PathVariable("type") String type, @RequestParam(required = false) Integer pageIndex, @RequestParam(required = false) Integer pageSize, @RequestParam(required = false) Integer limit, @RequestParam(required = false) Integer offset) { if(pageIndex != null && pageSize != null) { PageHelper.startPage(pageIndex, pageSize); } List answerPapers = answerPaperService.getAnswerPaperListByAnswerUserAndType(username, type); PageInfo pageInfo = new PageInfo(answerPapers); return pageInfo; } /** * 获取未批改或已批改的答卷数量, * @return */ @RequestMapping("/check") @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')") public DtoTask countUnCheckAnswerPaper() { DtoTask dtoTask = new DtoTask(); Integer checked = answerPaperService.countCheck("true"); Integer unChecked = answerPaperService.countCheck("false"); dtoTask.setChecked(checked); dtoTask.setUnChecked(unChecked); return dtoTask; } /** * 以分页方式获取数据 * @param pageIndex * @param pageSize * @param limit * @param offset * @return */ @RequestMapping(value = "", method = RequestMethod.GET) @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')") public PageInfo getListByUser(@RequestParam(required = false) Integer pageIndex, @RequestParam(required = false) Integer pageSize, @RequestParam(required = false) Integer limit, @RequestParam(required = false) Integer offset) { if(pageIndex != null && pageSize != null) { PageHelper.startPage(pageIndex, pageSize); } List answerPapers = answerPaperService.getAnswerPaperList(); PageInfo pageInfo = new PageInfo(answerPapers); return pageInfo; } /** * 更新 * @param answerPaper * @return */ @RequestMapping(value = "", method = RequestMethod.PUT) @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')") public ResponseEntity> putPaper(@RequestBody AnswerPaper answerPaper) { answerPaperService.updatePaper(answerPaper); return new ResponseEntity(HttpStatus.OK); } /** * 计算考试成绩 * @param id * @return */ @RequestMapping(value = "/{id}/calculate", method = RequestMethod.PUT) @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')") public ResponseEntity> CalculationScore(@PathVariable String id) { /** * 计算成绩 */ List questions = answerQuestionService.findByAnswerPaperId(id); if(questions != null && questions.size() > 0) { int score = 0; try { for(AnswerQuestion question : questions) { score += Integer.parseInt(question.getMarkScore()); } } catch (Exception e) { // TODO: 2017/4/1 } /** * 保存成绩 */ AnswerPaper answerPaper = new AnswerPaper(); answerPaper.setId(id); answerPaper.setScore(Integer.toString(score)); answerPaper.setChecked("true"); answerPaperService.updatePaper(answerPaper); } else { // TODO: 2017/4/1 } return new ResponseEntity(HttpStatus.OK); } @RequestMapping(value = "/analysis/paper") @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "')") public List analysisPaper() { return answerPaperService.analysisPaper(); }} 由于限制,这里不能直接放链接,需要项目源码与开发文档的同学转发本文+关注+私信【0211】即可获取
版权声明:我们致力于保护作者版权,注重分享,被刊用文章【考试系统(考试管理系统)】因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理! 部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理!;
工作时间:8:00-18:00
客服电话
电子邮件
beimuxi@protonmail.com
扫码二维码
获取最新动态
