当前位置:   article > 正文

基于SpringBoot的在线考试系统_spring在线考试系统

spring在线考试系统

作者主页:编程指南针

作者简介:Java领域优质创作者、CSDN博客专家 、掘金特邀作者、多年架构师设计经验、腾讯课堂常驻讲师

主要内容:Java项目、毕业设计、简历模板、学习资料、面试题库、技术互助

收藏点赞不迷路  关注作者有好处

文末获取源码 

项目编号:BS-GX-079

一,项目简介

 随着计算机技术的不断发展,我们的日常生活和工作都与计算机技术的关系越来越密切。计算机技术的发展改变了我们日常的生活和工作习惯,也改变了社会的发展速度,使得我们的生活更加便利和高效。伴随着计算机技术发展起来的互联网技术将我们的生活带领进信息化时代,改变了我们的学习和工作环境,例如我们经常面对的考试也随着互联网技术的发展产生了改变,伴随着信息技术的发展,在线无纸化的考试系统应运而生,不仅彻底改变了传统纸质考试的习惯和环境,更是提高了考试效率,保证了考试效果,达到了考试目的[1]。传统的纸质考试具有很多局限性和不足,主要包括以下几点:

1.传统纸质考试需要较多的人力资源和时间资源进行题目的设定,同时题目的难易程度和考核价值水平很难达到基本的要求;

2.传统纸质考试的阅卷采用人工的方式,人工阅卷难免会出现阅卷差错或者分数合算差错,这也会对考试的效果造成影响;

3.传统纸质考试的人工阅卷模式也会浪费大量的人力资源和时间资源,不能保证工作效率和工作质量;

4.传统纸质考试对考试的总结能力较差,不能够全面具体的分析考试结果,教师也很难得到基本的考试结果分析的数据信息,而这些数据信息是提高教学质量和教学效果的关键因素;

5.传统纸质考试对考试时间以及考试纪律的要求不能达到统一,这也会影响到考试的公平性。根据以上分析的传统纸质考试的不足之处,新型的结合计算机技术以及互联网技术的在线考试系统应运而生,不仅通过一种新的技术解决了传统纸质考试的基本问题,还提供了一种新的考试思路和考试理念,纠正了传统纸质考试的弊端,提供更加合理有效的考试过程。

二,环境介绍

语言环境:Java:  jdk1.8

数据库:Mysql: mysql5.7 、redis

应用服务器:Tomcat:  tomcat8.5.31

开发工具:IDEA或eclipse

后台开发技术: springboot、mybatisplus、springmvc、shiro 、jwt等

本系统分为三个角色:管理员、教师端、学生端 

三,系统展示

后台登录首页

管理员列表

角色管理

菜单管理

学生列表

专业列表

 课程题目

 公告管理

试卷列表

新增试卷

批改试卷

学生端首页

我的试卷

考试记录 

四,核心代码展示

  1. @Service("paperService")
  2. public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> implements PaperService {
  3. @Resource
  4. private QuestionDao questionDao;
  5. @Autowired
  6. private PaperQuestionService paperQuestionService;
  7. @Autowired
  8. private QuestionTypeService questionTypeService;
  9. @Resource
  10. private PaperClazzDao paperClazzDao;
  11. @Autowired
  12. private PaperRecordService paperRecordService;
  13. @Autowired
  14. private StudentService studentService;
  15. @Autowired
  16. private BaseService baseService;
  17. @Override
  18. public PageUtils queryPage(Map<String, Object> params) {
  19. String isNoChecked = (String) params.get("isNoChecked");
  20. String title = (String) params.get("title");
  21. String major = (String) params.get("major");
  22. String subjectId = (String) params.get("subjectId");
  23. QueryWrapper<PaperEntity> wrapper = new QueryWrapper<>();
  24. wrapper.eq("is_deleted", 0);
  25. if (StringUtils.hasText(isNoChecked)) {
  26. wrapper.ne("is_checked", isNoChecked);
  27. }
  28. if (StringUtils.hasText(title)) {
  29. wrapper.eq("paper_title", title);
  30. }
  31. if (StringUtils.hasText(major)) {
  32. wrapper.eq("major_id", major);
  33. }
  34. if (StringUtils.hasText(subjectId)) {
  35. wrapper.eq("subject_id", subjectId);
  36. }
  37. IPage<PaperEntity> page = this.page(
  38. new Query<PaperEntity>().getPage(params),
  39. wrapper
  40. );
  41. page.setRecords(baseService.relation(page));
  42. return new PageUtils(page);
  43. }
  44. @Override
  45. public List<PaperQuestionVO> getPageQuestionList(Integer subjectId) {
  46. List<PaperQuestionVO> result = new ArrayList<>();
  47. List<QuestionNumVO> questionNumVOList = questionDao.getQuestionNumListBySubjectId(subjectId);
  48. questionNumVOList.forEach(item -> {
  49. PaperQuestionVO tempPageQuestion = new PaperQuestionVO();
  50. tempPageQuestion.setQuestionTypeId(item.getQuestionTypeId());
  51. tempPageQuestion.setQuestionTypeName(item.getTypeName());
  52. if (!result.contains(tempPageQuestion)) {
  53. result.add(tempPageQuestion);
  54. }
  55. });
  56. result.forEach(pageQuestion -> {
  57. List<QuestionNumVO> questionNumList = new ArrayList<>();
  58. questionNumVOList.forEach(questionNumVO -> {
  59. if (pageQuestion.getQuestionTypeId().equals(questionNumVO.getQuestionTypeId())) {
  60. questionNumList.add(questionNumVO);
  61. }
  62. });
  63. pageQuestion.setQuestionNumList(questionNumList);
  64. });
  65. return result;
  66. }
  67. @Transactional(
  68. rollbackFor = Exception.class
  69. )
  70. @Override
  71. public void savePaperInfo(PaperDTO paperDTO) {
  72. PaperEntity paperEntity = new PaperEntity();
  73. BeanUtils.copyProperties(paperDTO, paperEntity);
  74. paperEntity.setExamDateStart(DateUtil.parse(paperDTO.getExamDateStart(), "yyyy-MM-dd"));
  75. paperEntity.setExamDateEnd(DateUtil.parse(paperDTO.getExamDateEnd(), "yyyy-MM-dd"));
  76. baseMapper.insert(paperEntity);
  77. List<PaperQuestionEntity> paperQuestionEntityList = new ArrayList<>();
  78. Set<Integer> questionIds = new HashSet<>();
  79. paperDTO.getSeleted().forEach(item -> {
  80. List<QuestionEntity> questionEntities = questionDao.selectList(new QueryWrapper<QuestionEntity>()
  81. .eq("is_deleted", 0)
  82. .eq("subject_id", paperEntity.getSubjectId())
  83. .eq("question_type_id", item.getQuestionTypeId())
  84. .eq("score", item.getScore()));
  85. Set<Integer> tempQuestionIds = new HashSet<>();
  86. while (tempQuestionIds.size() != item.getSelectVal()) {
  87. int num = (int)(Math.random()*questionEntities.size());
  88. tempQuestionIds.add(questionEntities.get(num).getId());
  89. }
  90. questionIds.addAll(tempQuestionIds);
  91. });
  92. questionIds.forEach(item -> {
  93. PaperQuestionEntity paperQuestionEntity = new PaperQuestionEntity();
  94. paperQuestionEntity.setPaperId(paperEntity.getId());
  95. paperQuestionEntity.setQuestionId(item);
  96. paperQuestionEntityList.add(paperQuestionEntity);
  97. });
  98. paperQuestionService.saveBatch(paperQuestionEntityList);
  99. }
  100. @Override
  101. public PaperInfoVO getPaperInfoByPaperId(String paperId) {
  102. PaperEntity paperEntity = baseMapper.selectById(paperId);
  103. PaperInfoVO paperInfoVO = new PaperInfoVO();
  104. BeanUtils.copyProperties(paperEntity, paperInfoVO);
  105. List<Integer> questionIds = paperQuestionService.getBaseMapper()
  106. .selectList(
  107. new QueryWrapper<PaperQuestionEntity>().eq("paper_id", paperId)).stream().map(item -> item.getQuestionId()).collect(Collectors.toList()
  108. );
  109. List<QuestionItemInfo> questionItemInfos = new ArrayList<>();
  110. List<QuestionTypeEntity> questionTypeList = questionTypeService.getBaseMapper().selectList(new QueryWrapper<QuestionTypeEntity>().eq("is_deleted", 0).orderByAsc("sort"));
  111. questionTypeList.forEach(item -> {
  112. QuestionItemInfo tempQuestionItemInfo = new QuestionItemInfo();
  113. BeanUtils.copyProperties(item, tempQuestionItemInfo);
  114. tempQuestionItemInfo.setList(
  115. questionDao.selectList(new QueryWrapper<QuestionEntity>().eq("is_deleted", 0).eq("question_type_id", item.getId()).in("id", questionIds))
  116. );
  117. questionItemInfos.add(tempQuestionItemInfo);
  118. });
  119. paperInfoVO.setQuestionList(questionItemInfos);
  120. return paperInfoVO;
  121. }
  122. @Override
  123. public void updateBatchAffirmByIds(List<String> ids, String updateBy) {
  124. List<PaperEntity> paperList = new ArrayList<>();
  125. ids.forEach(id -> {
  126. PaperEntity paperEntity = new PaperEntity();
  127. paperEntity.setId(id);
  128. paperEntity.setIsAffirm(1);
  129. paperEntity.setUpdateBy(updateBy);
  130. paperList.add(paperEntity);
  131. });
  132. this.updateBatchById(paperList);
  133. }
  134. @Override
  135. public void savePaperClazzRelation(String paperId, Integer clazzId) {
  136. PaperClazzEntity paperClazzEntity = new PaperClazzEntity();
  137. paperClazzEntity.setPaperId(paperId);
  138. paperClazzEntity.setClazzId(clazzId);
  139. paperClazzDao.insert(paperClazzEntity);
  140. }
  141. @Override
  142. public IPage<PaperEntity> getPaperByClazzId(PaperDTO paperDTO, String clazzId, String token) throws Exception {
  143. String account = JWTTokenUtils.geAccountByToken(token);
  144. StudentEntity currentStudent = studentService.getOne(new QueryWrapper<StudentEntity>().eq("is_deleted", 0).eq("stu_no", account));
  145. List<String> paperIds = paperClazzDao.selectList(new QueryWrapper<PaperClazzEntity>().eq("clazz_id", clazzId)).stream().map(item -> item.getPaperId()).collect(Collectors.toList());
  146. baseMapper.selectBatchIds(paperIds);
  147. QueryWrapper<PaperEntity> wrapper = new QueryWrapper<>();
  148. wrapper.eq("is_deleted", 0).in("id", paperIds);
  149. if (StringUtils.hasText(paperDTO.getPaperTitle())) {
  150. wrapper.like("paper_title", paperDTO.getPaperTitle());
  151. }
  152. if (Objects.nonNull(paperDTO.getMajorId())) {
  153. wrapper.eq("major_id", paperDTO.getMajorId());
  154. }
  155. if (Objects.nonNull(paperDTO.getSubjectId())) {
  156. wrapper.eq("subject_id", paperDTO.getSubjectId());
  157. }
  158. wrapper.eq("major_id", currentStudent.getMajor());
  159. IPage<PaperEntity> resultPage = this.page(
  160. new Page<>(paperDTO.getPageNo(), paperDTO.getPageSize()),
  161. wrapper
  162. );
  163. List<PaperRecordEntity> paperRecordEntities = paperRecordService.list(new QueryWrapper<PaperRecordEntity>().eq("stu_no", currentStudent.getStuNo()));
  164. List<PaperEntity> records = resultPage.getRecords();
  165. records.forEach(item -> {
  166. paperRecordEntities.forEach(temp -> {
  167. if (item.getId().equals(temp.getPaperId())) {
  168. item.setAnswerNum(item.getAnswerNum() - 1);
  169. }
  170. });
  171. });
  172. resultPage.setRecords(records);
  173. resultPage.setRecords(baseService.relation(resultPage));
  174. return resultPage;
  175. }
  176. @Override
  177. public PaperEntity getPaperByClazzIdAndPaperId(String paperId) {
  178. PaperEntity paperEntity = baseMapper.selectById(paperId);
  179. List<PaperRecordEntity> paperRecordEntities = paperRecordService.list(new QueryWrapper<PaperRecordEntity>().eq("paper_id", paperId));
  180. paperEntity.setAnswerNum(paperEntity.getAnswerNum() - paperRecordEntities.size());
  181. return paperEntity;
  182. }
  183. }

  1. @Service("questionService")
  2. public class QuestionServiceImpl extends ServiceImpl<QuestionDao, QuestionEntity> implements QuestionService {
  3. @Autowired
  4. private BaseService baseService;
  5. @Autowired
  6. private QuestionTypeService questionTypeService;
  7. @Override
  8. public PageUtils queryPage(Map<String, Object> params) {
  9. String key = (String) params.get("key");
  10. String typeId = (String) params.get("typeId");
  11. String subjectId = (String) params.get("subjectId");
  12. QueryWrapper<QuestionEntity> wrapper = new QueryWrapper<>();
  13. wrapper.eq("is_deleted", 0);
  14. wrapper.orderByDesc("create_time");
  15. if (StringUtils.hasText(key)) {
  16. wrapper.like("question_title", key);
  17. }
  18. if (StringUtils.hasText(typeId)) {
  19. wrapper.eq("question_type_id", typeId);
  20. }
  21. if (StringUtils.hasText(subjectId)) {
  22. wrapper.eq("subject_id", subjectId);
  23. }
  24. IPage<QuestionEntity> page = this.page(
  25. new Query<QuestionEntity>().getPage(params),
  26. wrapper
  27. );
  28. page.setRecords(baseService.relation(page));
  29. return new PageUtils(page);
  30. }
  31. @Override
  32. public List<QuestionNumVO> getQuestionNumWithSubjectIdGroupByType(Integer subjectId) {
  33. return baseMapper.getQuestionNumWithSubjectIdGroupByType(subjectId);
  34. }
  35. @Override
  36. public List<QuestionRecordVO> getPracticeQuestionList(PaperDTO paperDTO) {
  37. List<QuestionRecordVO> resultLis = new ArrayList<>();
  38. Integer subjectId = paperDTO.getSubjectId();
  39. List<QuestionSelectedDTO> seleted = paperDTO.getSeleted();
  40. seleted.forEach(item -> {
  41. QuestionRecordVO questionRecordVO = new QuestionRecordVO();
  42. questionRecordVO.setTypeName(item.getTypeName());
  43. questionRecordVO.setTypeId(item.getQuestionTypeId());
  44. List<QuestionRecordList> record = new ArrayList<>();
  45. Set<Integer> questionIds = new HashSet<>();
  46. List<QuestionEntity> questionEntities = baseMapper.selectList(new QueryWrapper<QuestionEntity>()
  47. .eq("is_deleted", 0)
  48. .eq("subject_id", subjectId)
  49. .eq("question_type_id", item.getQuestionTypeId()));
  50. while (questionIds.size() != item.getSelectVal()) {
  51. int num = (int)(Math.random()*questionEntities.size());
  52. questionIds.add(questionEntities.get(num).getId());
  53. }
  54. questionEntities.forEach(ques -> {
  55. if (questionIds.contains(ques.getId())) {
  56. QuestionRecordList temp = new QuestionRecordList();
  57. BeanUtils.copyProperties(ques, temp);
  58. record.add(temp);
  59. }
  60. });
  61. questionRecordVO.setRecord(record);
  62. resultLis.add(questionRecordVO);
  63. });
  64. System.out.println("resultLis: "+resultLis.toString());
  65. return resultLis;
  66. }
  67. }

五,项目总结

由于篇幅有限,还有一部分功能没有展现,本项目是一个非常不错的项目,界面美观,功能齐全。非常适合做毕设项目来使用

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号