考试系统(考试管理系统)

 2025-07-19 14:45:01  阅读 920  评论 0

摘要:一、项目简述本系统功能包括:支持单选题、多选题、判断题支持学生(student)、教师(teacher)、管理员(admin)三种角色学生:参加考试和查看我的考试教师:学生的所有权限+创建/编辑题目+创建/编辑考试管理员:教师的所有权限+管理用户。二、项目运行环境配置:Jdk1.8 + Tomcat

一、项目简述

本系统功能包括:

支持单选题、多选题、判断题支持学生(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(HttpStatus.INTERNAL_SERVER_ERROR);            }            answerPaper.setAnswerTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));            answerPaper.setPaperName(paper.getName());            answerPaper.setAnswerUser(username);            answerPaper.setChecked("false");            answerPaper.setFinished("true");            answerPaper.setType("official");            examService.updateAnswerPaper(answerPaper);        } else if(type.equals("simulate")) {            /**             * 模拟考试             */            AnswerPaper answerPaper = new AnswerPaper();            if(answerPaperId != null) {                answerPaper.setId(answerPaperId);            }else {                return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);            }            answerPaper.setAnswerTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));            answerPaper.setPaperName(paper.getName());            answerPaper.setAnswerUser(username);            answerPaper.setChecked("false");            answerPaper.setFinished("true");            answerPaper.setType("simulate");            examService.updateAnswerPaper(answerPaper);        }else if(type.equals("practice")) {            /**             * 1.接收提交的试卷             * 2.计算成绩             * 3.记录考试记录             * 4.返回计算结果             */            int score = 0;             //正确题目数            double right = 0.0;             //错误题目数            double wrong = 0.0;             double correctRate = 0.0;             List questions = questionService.getQuestionByPaperId(paper.getId());             AnswerPaper answerPaper = answerPaperService.findByAnswerUserAndPaperName(username, paper.getName());             List answerQuestions = answerQuestionService.findByAnswerPaperId(answerPaper.getId());             /*保存题目信息,返回给前端*/            List results = new ArrayList();             DtoRightAndWrong dtoRightAndWrong = null;             //遍历提交的试卷的题目            for(AnswerQuestion answerQuestion : answerQuestions) {                 //遍历包含正确答案的题目                for(Question question : questions) {                    /**                     * 1.题目序号相同                     * 2.结果与答案相同                     */                    if(answerQuestion.getNumber().equals(question.getNumber())) {                        if(answerQuestion.getAnswer().equals(question.getAnswer())) {                            /*累计得分*/                            score += Integer.parseInt(question.getScore());                            right ++;                        }else {                            wrong ++;                            //记录错题                            dtoRightAndWrong = new DtoRightAndWrong();                            dtoRightAndWrong.setQuestion(question);                            dtoRightAndWrong.setAnswerQuestion(answerQuestion);                            results.add(dtoRightAndWrong);                             //保存错题                            WrongQuestion wrongQuestion = new WrongQuestion();                            try{                                BeanUtils.copyProperties(wrongQuestion, answerQuestion);                                wrongQuestion.setUsername(username);                                wrongQuestion.setRightAnswer(question.getAnswer());                                wrongQuestion.setAnalysis(question.getAnalysis());                                if(wrongQuestionService.getWrongQuestion(wrongQuestion.getId()) == null) {                                    wrongQuestionService.saveQuestion(wrongQuestion);                                }                            }catch (Exception e) {                                System.out.println(wrongQuestion.toString());                            }                         }                    }                }            }            //计算正确率            correctRate = (right/(right + wrong)) * 100;             DtoResult result = new DtoResult();            result.setScore(score);            result.setRight(right);            result.setWrong(wrong);            result.setCorrectRate(correctRate);            result.setResults(results);             Paper paper1 = paperService.getPaperById(paper.getId());            //更新参与人数            paper1.setPeoples(String.valueOf(Integer.parseInt(paper1.getPeoples()) + 1));            paperService.updatePaper(paper1);             return new ResponseEntity(result, HttpStatus.OK);        }        Paper paper1 = paperService.getPaperById(paper.getId());        //更新参与人数        paper1.setPeoples(String.valueOf(Integer.parseInt(paper1.getPeoples() + 1)));        paperService.updatePaper(paper1);        return new ResponseEntity(HttpStatus.OK);    }     /**     * 提交题目     * @param username     * @param dtoAnswerPaper     * @return     */    @RequestMapping(value = "/submit/one/{username}", method = RequestMethod.POST)    @PreAuthorize("hasAuthority('" + Role.ROLE_TEACHER + "') or hasAuthority('" + Role.ROLE_ADMIN + "') or hasAuthority('" + Role.ROLE_STUDENT + "')")    public ResponseEntity submitOne(@PathVariable String username, @RequestBody DtoAnswerPaper dtoAnswerPaper) {        Paper paper = dtoAnswerPaper.getPaper();        Question question = dtoAnswerPaper.getQuestion();        //判断数据库是否保存了这次答卷        AnswerPaper answerPaper = answerPaperService.getAnswerPaperByNameAndUser(paper.getName(), username);        AnswerQuestion answerQuestion = null;        AnswerPaperQuestion answerPaperQuestion = null;        List answerQuestions = null;        //重新生成id        String answerPaperId = IdGen.uuid();        String answerQuestionId = IdGen.uuid();        //答卷为空,则执行保存        if(answerPaper == null) {            answerPaper = new AnswerPaper();            answerPaper.setId(answerPaperId);            answerPaper.setAnswerTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));            answerPaper.setPaperName(paper.getName());            answerPaper.setType(paper.getType());            answerPaper.setAnswerUser(username);            answerPaper.setChecked("false");            answerPaper.setFinished("false");             //保存答卷            answerPaperService.saveAnswerPaper(answerPaper);             // TODO: 2017-04-17 保存试卷答卷            PaperAnswerPaper paperAnswerPaper = new PaperAnswerPaper();            paperAnswerPaper.setPaperId(paper.getId());            paperAnswerPaper.setAnswerPaperId(answerPaperId);            paperAnswerPaperService.save(paperAnswerPaper);             //新记录            answerQuestion = new AnswerQuestion();            //初始化信息            answerQuestion.setId(answerQuestionId);            answerQuestion.setTitle(question.getTitle());            answerQuestion.setType(question.getType());            answerQuestion.setNumber(question.getNumber());            answerQuestion.setOptionA(question.getOptionA());            answerQuestion.setOptionB(question.getOptionB());            answerQuestion.setOptionC(question.getOptionC());            answerQuestion.setOptionD(question.getOptionD());            answerQuestion.setContent(question.getContent());            answerQuestion.setScore(question.getScore());            answerQuestion.setAnalysis(question.getAnalysis());            answerQuestion.setAnswer(question.getAnswer());              answerPaperQuestion = new AnswerPaperQuestion();            answerPaperQuestion.setAnswerPaperId(answerPaper.getId());            answerPaperQuestion.setAnswerQuestionId(answerQuestionId);             //保存            answerQuestionService.saveAnswerQuestion(answerQuestion);            answerPaperQuestionService.saveAnswerPaperQuestion(answerPaperQuestion);             return new ResponseEntity(answerPaper, HttpStatus.OK);        } else {            answerQuestions = answerQuestionService.findByAnswerPaperId(answerPaper.getId());            if(answerQuestions != null && answerQuestions.size() > 0) {                int count = 0;                AnswerQuestion existAnswerQuestion = null;                for(AnswerQuestion question1 : answerQuestions) {                    if (question1.getNumber().equals(question.getNumber())) {                        count++;                        existAnswerQuestion = question1;//保存当前存在的记录                    }                }                //记录不存在                if(count == 0) {                    //新记录                    answerQuestion = new AnswerQuestion();                    answerPaperQuestion = new AnswerPaperQuestion();                      answerQuestion = new AnswerQuestion();                    //初始化信息                    answerQuestion.setId(answerQuestionId);                    answerQuestion.setTitle(question.getTitle());                    answerQuestion.setType(question.getType());                    answerQuestion.setNumber(question.getNumber());                    answerQuestion.setOptionA(question.getOptionA());                    answerQuestion.setOptionB(question.getOptionB());                    answerQuestion.setOptionC(question.getOptionC());                    answerQuestion.setOptionD(question.getOptionD());                    answerQuestion.setContent(question.getContent());                    answerQuestion.setScore(question.getScore());                    answerQuestion.setAnalysis(question.getAnalysis());                    answerQuestion.setAnswer(question.getAnswer());                      answerPaperQuestion = new AnswerPaperQuestion();                    answerPaperQuestion.setAnswerPaperId(answerPaper.getId());                    answerPaperQuestion.setAnswerQuestionId(answerQuestionId);                     //保存                    answerQuestionService.saveAnswerQuestion(answerQuestion);                    answerPaperQuestionService.saveAnswerPaperQuestion(answerPaperQuestion);                } else {                    //记录存在,则执行更新                    // TODO: 2017/3/30                    //更新当前存在的记录                    existAnswerQuestion.setAnswer(question.getAnswer());                     answerQuestionService.updateAnswerQuestion(existAnswerQuestion);                }            }        }        return new ResponseEntity(answerPaper, HttpStatus.OK);    }}

获取试卷题目:

@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进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理!;

原文链接:https://www.yxiso.com/fangfa/1868787.html

标签:考试系统

发表评论:

关于我们
院校搜的目标不仅是为用户提供数据和信息,更是成为每一位学子梦想实现的桥梁。我们相信,通过准确的信息与专业的指导,每一位学子都能找到属于自己的教育之路,迈向成功的未来。助力每一个梦想,实现更美好的未来!
联系方式
电话:
地址:广东省中山市
Email:beimuxi@protonmail.com

Copyright © 2022 院校搜 Inc. 保留所有权利。 Powered by BEIMUCMS 3.0.3

页面耗时0.0468秒, 内存占用1.96 MB, 访问数据库24次

陕ICP备14005772号-15

  • 我要关灯
    我要开灯
  • 客户电话

    工作时间:8:00-18:00

    客服电话

    电子邮件

    beimuxi@protonmail.com

  • 官方微信

    扫码二维码

    获取最新动态

  • 返回顶部