基于SpringBoot的在线考试系统
Posted 编程指南针
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于SpringBoot的在线考试系统相关的知识,希望对你有一定的参考价值。
作者主页:编程指南针
作者简介:Java领域优质创作者、CSDN博客专家 、掘金特邀作者、多年架构师设计经验、腾讯课堂常驻讲师
主要内容:Java项目、毕业设计、简历模板、学习资料、面试题库、技术互助
收藏点赞不迷路 关注作者有好处
文末获取源码
项目编号:
一,项目简介
随着计算机技术的不断发展,我们的日常生活和工作都与计算机技术的关系越来越密切。计算机技术的发展改变了我们日常的生活和工作习惯,也改变了社会的发展速度,使得我们的生活更加便利和高效。伴随着计算机技术发展起来的互联网技术将我们的生活带领进信息化时代,改变了我们的学习和工作环境,例如我们经常面对的考试也随着互联网技术的发展产生了改变,伴随着信息技术的发展,在线无纸化的考试系统应运而生,不仅彻底改变了传统纸质考试的习惯和环境,更是提高了考试效率,保证了考试效果,达到了考试目的[1]。传统的纸质考试具有很多局限性和不足,主要包括以下几点:
1.传统纸质考试需要较多的人力资源和时间资源进行题目的设定,同时题目的难易程度和考核价值水平很难达到基本的要求;
2.传统纸质考试的阅卷采用人工的方式,人工阅卷难免会出现阅卷差错或者分数合算差错,这也会对考试的效果造成影响;
3.传统纸质考试的人工阅卷模式也会浪费大量的人力资源和时间资源,不能保证工作效率和工作质量;
4.传统纸质考试对考试的总结能力较差,不能够全面具体的分析考试结果,教师也很难得到基本的考试结果分析的数据信息,而这些数据信息是提高教学质量和教学效果的关键因素;
5.传统纸质考试对考试时间以及考试纪律的要求不能达到统一,这也会影响到考试的公平性。根据以上分析的传统纸质考试的不足之处,新型的结合计算机技术以及互联网技术的在线考试系统应运而生,不仅通过一种新的技术解决了传统纸质考试的基本问题,还提供了一种新的考试思路和考试理念,纠正了传统纸质考试的弊端,提供更加合理有效的考试过程。
二,环境介绍
语言环境:Java: jdk1.8
数据库:mysql: mysql5.7 、redis
应用服务器:Tomcat: tomcat8.5.31
开发工具:IDEA或eclipse
后台开发技术: springboot、mybatisplus、springmvc、shiro 、jwt等
本系统分为三个角色:管理员、教师端、学生端
三,系统展示
后台登录首页
管理员列表
角色管理
菜单管理
学生列表
专业列表
课程题目
公告管理
试卷列表
新增试卷
批改试卷
学生端首页
我的试卷
考试记录
四,核心代码展示
@Service("paperService")
public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> implements PaperService
@Resource
private QuestionDao questionDao;
@Autowired
private PaperQuestionService paperQuestionService;
@Autowired
private QuestionTypeService questionTypeService;
@Resource
private PaperClazzDao paperClazzDao;
@Autowired
private PaperRecordService paperRecordService;
@Autowired
private StudentService studentService;
@Autowired
private BaseService baseService;
@Override
public PageUtils queryPage(Map<String, Object> params)
String isNoChecked = (String) params.get("isNoChecked");
String title = (String) params.get("title");
String major = (String) params.get("major");
String subjectId = (String) params.get("subjectId");
QueryWrapper<PaperEntity> wrapper = new QueryWrapper<>();
wrapper.eq("is_deleted", 0);
if (StringUtils.hasText(isNoChecked))
wrapper.ne("is_checked", isNoChecked);
if (StringUtils.hasText(title))
wrapper.eq("paper_title", title);
if (StringUtils.hasText(major))
wrapper.eq("major_id", major);
if (StringUtils.hasText(subjectId))
wrapper.eq("subject_id", subjectId);
IPage<PaperEntity> page = this.page(
new Query<PaperEntity>().getPage(params),
wrapper
);
page.setRecords(baseService.relation(page));
return new PageUtils(page);
@Override
public List<PaperQuestionVO> getPageQuestionList(Integer subjectId)
List<PaperQuestionVO> result = new ArrayList<>();
List<QuestionNumVO> questionNumVOList = questionDao.getQuestionNumListBySubjectId(subjectId);
questionNumVOList.forEach(item ->
PaperQuestionVO tempPageQuestion = new PaperQuestionVO();
tempPageQuestion.setQuestionTypeId(item.getQuestionTypeId());
tempPageQuestion.setQuestionTypeName(item.getTypeName());
if (!result.contains(tempPageQuestion))
result.add(tempPageQuestion);
);
result.forEach(pageQuestion ->
List<QuestionNumVO> questionNumList = new ArrayList<>();
questionNumVOList.forEach(questionNumVO ->
if (pageQuestion.getQuestionTypeId().equals(questionNumVO.getQuestionTypeId()))
questionNumList.add(questionNumVO);
);
pageQuestion.setQuestionNumList(questionNumList);
);
return result;
@Transactional(
rollbackFor = Exception.class
)
@Override
public void savePaperInfo(PaperDTO paperDTO)
PaperEntity paperEntity = new PaperEntity();
BeanUtils.copyProperties(paperDTO, paperEntity);
paperEntity.setExamDateStart(DateUtil.parse(paperDTO.getExamDateStart(), "yyyy-MM-dd"));
paperEntity.setExamDateEnd(DateUtil.parse(paperDTO.getExamDateEnd(), "yyyy-MM-dd"));
baseMapper.insert(paperEntity);
List<PaperQuestionEntity> paperQuestionEntityList = new ArrayList<>();
Set<Integer> questionIds = new HashSet<>();
paperDTO.getSeleted().forEach(item ->
List<QuestionEntity> questionEntities = questionDao.selectList(new QueryWrapper<QuestionEntity>()
.eq("is_deleted", 0)
.eq("subject_id", paperEntity.getSubjectId())
.eq("question_type_id", item.getQuestionTypeId())
.eq("score", item.getScore()));
Set<Integer> tempQuestionIds = new HashSet<>();
while (tempQuestionIds.size() != item.getSelectVal())
int num = (int)(Math.random()*questionEntities.size());
tempQuestionIds.add(questionEntities.get(num).getId());
questionIds.addAll(tempQuestionIds);
);
questionIds.forEach(item ->
PaperQuestionEntity paperQuestionEntity = new PaperQuestionEntity();
paperQuestionEntity.setPaperId(paperEntity.getId());
paperQuestionEntity.setQuestionId(item);
paperQuestionEntityList.add(paperQuestionEntity);
);
paperQuestionService.saveBatch(paperQuestionEntityList);
@Override
public PaperInfoVO getPaperInfoByPaperId(String paperId)
PaperEntity paperEntity = baseMapper.selectById(paperId);
PaperInfoVO paperInfoVO = new PaperInfoVO();
BeanUtils.copyProperties(paperEntity, paperInfoVO);
List<Integer> questionIds = paperQuestionService.getBaseMapper()
.selectList(
new QueryWrapper<PaperQuestionEntity>().eq("paper_id", paperId)).stream().map(item -> item.getQuestionId()).collect(Collectors.toList()
);
List<QuestionItemInfo> questionItemInfos = new ArrayList<>();
List<QuestionTypeEntity> questionTypeList = questionTypeService.getBaseMapper().selectList(new QueryWrapper<QuestionTypeEntity>().eq("is_deleted", 0).orderByAsc("sort"));
questionTypeList.forEach(item ->
QuestionItemInfo tempQuestionItemInfo = new QuestionItemInfo();
BeanUtils.copyProperties(item, tempQuestionItemInfo);
tempQuestionItemInfo.setList(
questionDao.selectList(new QueryWrapper<QuestionEntity>().eq("is_deleted", 0).eq("question_type_id", item.getId()).in("id", questionIds))
);
questionItemInfos.add(tempQuestionItemInfo);
);
paperInfoVO.setQuestionList(questionItemInfos);
return paperInfoVO;
@Override
public void updateBatchAffirmByIds(List<String> ids, String updateBy)
List<PaperEntity> paperList = new ArrayList<>();
ids.forEach(id ->
PaperEntity paperEntity = new PaperEntity();
paperEntity.setId(id);
paperEntity.setIsAffirm(1);
paperEntity.setUpdateBy(updateBy);
paperList.add(paperEntity);
);
this.updateBatchById(paperList);
@Override
public void savePaperClazzRelation(String paperId, Integer clazzId)
PaperClazzEntity paperClazzEntity = new PaperClazzEntity();
paperClazzEntity.setPaperId(paperId);
paperClazzEntity.setClazzId(clazzId);
paperClazzDao.insert(paperClazzEntity);
@Override
public IPage<PaperEntity> getPaperByClazzId(PaperDTO paperDTO, String clazzId, String token) throws Exception
String account = JWTTokenUtils.geAccountByToken(token);
StudentEntity currentStudent = studentService.getOne(new QueryWrapper<StudentEntity>().eq("is_deleted", 0).eq("stu_no", account));
List<String> paperIds = paperClazzDao.selectList(new QueryWrapper<PaperClazzEntity>().eq("clazz_id", clazzId)).stream().map(item -> item.getPaperId()).collect(Collectors.toList());
baseMapper.selectBatchIds(paperIds);
QueryWrapper<PaperEntity> wrapper = new QueryWrapper<>();
wrapper.eq("is_deleted", 0).in("id", paperIds);
if (StringUtils.hasText(paperDTO.getPaperTitle()))
wrapper.like("paper_title", paperDTO.getPaperTitle());
if (Objects.nonNull(paperDTO.getMajorId()))
wrapper.eq("major_id", paperDTO.getMajorId());
if (Objects.nonNull(paperDTO.getSubjectId()))
wrapper.eq("subject_id", paperDTO.getSubjectId());
wrapper.eq("major_id", currentStudent.getMajor());
IPage<PaperEntity> resultPage = this.page(
new Page<>(paperDTO.getPageNo(), paperDTO.getPageSize()),
wrapper
);
List<PaperRecordEntity> paperRecordEntities = paperRecordService.list(new QueryWrapper<PaperRecordEntity>().eq("stu_no", currentStudent.getStuNo()));
List<PaperEntity> records = resultPage.getRecords();
records.forEach(item ->
paperRecordEntities.forEach(temp ->
if (item.getId().equals(temp.getPaperId()))
item.setAnswerNum(item.getAnswerNum() - 1);
);
);
resultPage.setRecords(records);
resultPage.setRecords(baseService.relation(resultPage));
return resultPage;
@Override
public PaperEntity getPaperByClazzIdAndPaperId(String paperId)
PaperEntity paperEntity = baseMapper.selectById(paperId);
List<PaperRecordEntity> paperRecordEntities = paperRecordService.list(new QueryWrapper<PaperRecordEntity>().eq("paper_id", paperId));
paperEntity.setAnswerNum(paperEntity.getAnswerNum() - paperRecordEntities.size());
return paperEntity;
@Service("questionService")
public class QuestionServiceImpl extends ServiceImpl<QuestionDao, QuestionEntity> implements QuestionService
@Autowired
private BaseService baseService;
@Autowired
private QuestionTypeService questionTypeService;
@Override
public PageUtils queryPage(Map<String, Object> params)
String key = (String) params.get("key");
String typeId = (String) params.get("typeId");
String subjectId = (String) params.get("subjectId");
QueryWrapper<QuestionEntity> wrapper = new QueryWrapper<>();
wrapper.eq("is_deleted", 0);
wrapper.orderByDesc("create_time");
if (StringUtils.hasText(key))
wrapper.like("question_title", key);
if (StringUtils.hasText(typeId))
wrapper.eq("question_type_id", typeId);
if (StringUtils.hasText(subjectId))
wrapper.eq("subject_id", subjectId);
IPage<QuestionEntity> page = this.page(
new Query<QuestionEntity>().getPage(params),
wrapper
);
page.setRecords(baseService.relation(page));
return new PageUtils(page);
@Override
public List<QuestionNumVO> getQuestionNumWithSubjectIdGroupByType(Integer subjectId)
return baseMapper.getQuestionNumWithSubjectIdGroupByType(subjectId);
@Override
public List<QuestionRecordVO> getPracticeQuestionList(PaperDTO paperDTO)
List<QuestionRecordVO> resultLis = new ArrayList<>();
Integer subjectId = paperDTO.getSubjectId();
List<QuestionSelectedDTO> seleted = paperDTO.getSeleted();
seleted.forEach(item ->
QuestionRecordVO questionRecordVO = new QuestionRecordVO();
questionRecordVO.setTypeName(item.getTypeName());
questionRecordVO.setTypeId(item.getQuestionTypeId());
List<QuestionRecordList> record = new ArrayList<>();
Set<Integer> questionIds = new HashSet<>();
List<QuestionEntity> questionEntities = baseMapper.selectList(new QueryWrapper<QuestionEntity>()
.eq("is_deleted", 0)
.eq("subject_id", subjectId)
.eq("question_type_id", item.getQuestionTypeId()));
while (questionIds.size() != item.getSelectVal())
int num = (int)(Math.random()*questionEntities.size());
questionIds.add(questionEntities.get(num).getId());
questionEntities.forEach(ques ->
if (questionIds.contains(ques.getId()))
QuestionRecordList temp = new QuestionRecordList();
BeanUtils.copyProperties(ques, temp);
record.add(temp);
);
questionRecordVO.setRecord(record);
resultLis.add(questionRecordVO);
);
System.out.println("resultLis: "+resultLis.toString());
return resultLis;
五,项目总结
由于篇幅有限,还有一部分功能没有展现,本项目是一个非常不错的项目,界面美观,功能齐全。非常适合做毕设项目来使用
以上是关于基于SpringBoot的在线考试系统的主要内容,如果未能解决你的问题,请参考以下文章
Java 基于springboot 在线竞价拍卖管理系统+数据库
基于Java+Springboot+vue在线版权登记管理系统设计实现