Hi,同学们好呀,被评为全网最细的丹成学长ヾ(•ω•`)o,今天带大家复盘一个学长帮往届同学做的一个毕业作品
基于springboot+vue的在线考试系统
计算机毕设选题大全及项目分享:
https://blog.csdn.net/WEB_DC/article/details/125563252
面向组织、公司、高校的一款通用在线考试系统,节约人力财力,轻松完成在线考核。系统拥有自行添加题库,考试随机抽题,线上监考,自动阅卷评分,实现了无纸化考试,自动化阅卷等功能。
一键安装:
server:
port: 8080
# ssl:
# key-store: classpath:keystore.p12
# key-store-password: qwertyuiop
# key-store-type: PKCS12
# key-alias: tomcat
spring:
jackson:
time-zone: GMT+8
date-format: com.fasterxml.jackson.databind.util.StdDateFormat
application:
name: voes
datasource:
url: jdbc:mysql://127.0.0.1:3306/voes?useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=utf8
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: 123456
type: com.alibaba.druid.pool.DruidDataSource
# 数据源其他配置
initialSize: 5
minIdle: 5
maxActive: 20
maxWait: 60000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
# 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
filters: stat,wall
maxPoolPreparedStatementPerConnectionSize: 20
useGlobalDataSourceStat: true
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500
servlet:
multipart:
max-file-size: 1024MB
main:
allow-bean-definition-overriding: true
# token配置
token:
# 令牌自定义标识
header: Authorization
# 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期(默认60分钟)
expireTime: 60
mybatis:
mapper-locations: classpath*:/mapper/**/*.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
@Override
public QuestionBank queryById(Integer id, boolean answer) {
Integer type = questionBankMapper.queryTypeById(id);
//单选题
if (QuestionType.SINGLE_CHOICE.equals(type)) {
log.info("单选题");
QuestionBank questionBank = questionBankMapper.queryByIdWithOption(id);
QuestionOption questionOption = questionBank.getQuestionOption();
if (!answer) {
questionOption.setRightKey(null);
questionOption.setExplain(null);
}
return questionBank;
}
//多选题
if (QuestionType.MULTIPLE_CHOICE.equals(type)) {
log.info("多选题");
QuestionBank questionBank = questionBankMapper.queryByIdWithOption(id);
QuestionOption questionOption = questionBank.getQuestionOption();
if (!answer) {
questionOption.setRightKey(null);
questionOption.setExplain(null);
}
return questionBank;
}
//填空题
if (QuestionType.FILL_IN_THE_BLANKS.equals(type)) {
log.info("填空题");
QuestionBank questionBank = questionBankMapper.queryByIdWithFill(id);
QuestionFillBlanks questionFillBlank = questionBank.getQuestionFillBlank();
if (!answer) {
questionFillBlank.setAnswer(null);
}
return questionBank;
}
//判断题
if (QuestionType.JUDGE.equals(type)) {
log.info("判断题");
QuestionBank questionBank = questionBankMapper.queryByIdWithJudgment(id);
if (!answer) {
QuestionJudgment questionJudgment = questionBank.getQuestionJudgment();
questionJudgment.setRightKey(null);
questionJudgment.setExplain(null);
}
return questionBank;
}
//主观题目
//与填空题保持一致
if (QuestionType.SUBJECTIVE.equals(type)) {
log.info("主观题");
QuestionBank questionBank = questionBankMapper.queryByIdWithFill(id);
QuestionFillBlanks questionFillBlank = questionBank.getQuestionFillBlank();
if (!answer) {
questionFillBlank.setAnswer(null);
}
return questionBank;
}
return null;
}
@Override
public QuestionBank queryById(Integer id) {
return queryById(id, true);
}
/**
* 查询多条数据
*
* @param offset 查询起始位置
* @param limit 查询条数
* @return 对象列表
*/
@Override
public List<QuestionBank> queryAllByLimit(int offset, int limit) {
return this.questionBankMapper.queryAllByLimit(offset, limit);
}
/**
* 查询多条数据
*
* @return 对象列表
*/
@Override
public PageInfo<QuestionBank> queryAll(QuestionBank questionBank, int currentPage, int pageSize) {
PageHelper.startPage(currentPage, pageSize);
List<QuestionBank> questionBanks = questionBankMapper.queryAll(questionBank);
return new PageInfo<QuestionBank>(questionBanks);
}
/**
* 新增数据
*
* @param questionBank 实例对象
* @return 实例对象
*/
@Override
public QuestionBank insert(QuestionBank questionBank) {
Integer type = questionBank.getType();
//插入题库
questionBankMapper.insert(questionBank);
Integer primary = questionBank.getId();
//插入答案
//单选题
if (QuestionType.SINGLE_CHOICE.equals(type)) {
QuestionOption questionOption = questionBank.getQuestionOption();
questionOption.setQuestionBankId(primary);
questionOptionMapper.insert(questionOption);
}
//多选题
if (QuestionType.MULTIPLE_CHOICE.equals(type)) {
QuestionOption questionOption = questionBank.getQuestionOption();
questionOption.setQuestionBankId(primary);
questionOptionMapper.insert(questionOption);
}
//填空题
if (QuestionType.FILL_IN_THE_BLANKS.equals(type)) {
QuestionFillBlanks questionFillBlank = questionBank.getQuestionFillBlank();
questionFillBlank.setQuestionBankId(primary);
questionFillBlanksMapper.insert(questionFillBlank);
}
//判断题
if (QuestionType.JUDGE.equals(type)) {
QuestionJudgment questionJudgment = questionBank.getQuestionJudgment();
questionJudgment.setQuestionBankId(primary);
questionJudgmentMapper.insert(questionJudgment);
}
//主观题
//等于填空题
if (QuestionType.SUBJECTIVE.equals(type)) {
QuestionFillBlanks questionFillBlank = questionBank.getQuestionFillBlank();
questionFillBlank.setQuestionBankId(primary);
questionFillBlanksMapper.insert(questionFillBlank);
}
return questionBank;
}
/**
* 修改数据
*
* @param questionBank 实例对象
* @return 实例对象
*/
@Override
public QuestionBank update(QuestionBank questionBank) {
//题编号
Integer id = questionBank.getId();
//题型
Integer type = questionBank.getType();
//单选题
if (QuestionType.SINGLE_CHOICE.equals(type)) {
QuestionOption questionOption = questionBank.getQuestionOption();
questionOption.setQuestionBankId(id);
questionOptionMapper.update(questionOption);
}
//多选题
if (QuestionType.MULTIPLE_CHOICE.equals(type)) {
QuestionOption questionOption = questionBank.getQuestionOption();
questionOption.setQuestionBankId(id);
questionOptionMapper.update(questionOption);
}
//填空题
if (QuestionType.FILL_IN_THE_BLANKS.equals(type)) {
QuestionFillBlanks questionFillBlank = questionBank.getQuestionFillBlank();
questionFillBlank.setQuestionBankId(id);
questionFillBlanksMapper.update(questionFillBlank);
}
//判断题
if (QuestionType.JUDGE.equals(type)) {
QuestionJudgment questionJudgment = questionBank.getQuestionJudgment();
questionJudgment.setQuestionBankId(id);
questionJudgmentMapper.update(questionJudgment);
}
//主观题
//等于填空题
if (QuestionType.SUBJECTIVE.equals(type)) {
QuestionFillBlanks questionFillBlank = questionBank.getQuestionFillBlank();
questionFillBlank.setQuestionBankId(id);
questionFillBlanksMapper.update(questionFillBlank);
}
questionBankMapper.update(questionBank);
return this.queryById(questionBank.getId());
}
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
@Override
public boolean deleteById(Integer id) {
//删除答卷上面的题
testPaperMapper.deleteByQuestionBankId(id);
scoreMapper.deleteByQuestionBankId(id);
//先删除答案
//再删除题
QuestionBank questionBank = questionBankMapper.queryById(id);
Integer type = questionBank.getType();
//单选题
if (QuestionType.SINGLE_CHOICE.equals(type)) {
questionOptionMapper.deleteByQuestionBankId(id);
}
//多选题
if (QuestionType.MULTIPLE_CHOICE.equals(type)) {
questionOptionMapper.deleteByQuestionBankId(id);
}
//填空题
if (QuestionType.FILL_IN_THE_BLANKS.equals(type)) {
questionFillBlanksMapper.deleteByQuestionBankId(id);
}
//判断题
if (QuestionType.JUDGE.equals(type)) {
questionJudgmentMapper.deleteByQuestionBankId(id);
}
//主观题
if (QuestionType.SUBJECTIVE.equals(type)) {
questionFillBlanksMapper.deleteByQuestionBankId(id);
}
return questionBankMapper.deleteById(id) > 0;
}
@Override
public boolean deleteByIds(List<Integer> ids) {
if (ids != null && ids.size() > 0) {
ids.forEach(id -> {
boolean b = this.deleteById(id);
});
}
return true;
}
3.4控制层代码
@Autowired
QuestionBankService questionBankService;
@RequestMapping("/questionBanks")
public AjaxResult list(
QuestionBank questionBank,
@RequestParam(defaultValue = "1") int currentPage,
@RequestParam(defaultValue = "10") int pageSize) {
PageInfo<QuestionBank> questionBankPageInfo = questionBankService.queryAll(questionBank, currentPage, pageSize);
return AjaxResult.success(questionBankPageInfo);
}
@RequestMapping("/get/{id}")
public AjaxResult list(@PathVariable int id) {
QuestionBank questionBank = questionBankService.queryById(id);
return AjaxResult.success(questionBank);
}
// 下面的记得添加权限
@RequestMapping("/add")
public AjaxResult add(@Valid @RequestBody QuestionBank questionBank) {
QuestionBank insert = questionBankService.insert(questionBank);
return AjaxResult.success(insert);
}
@RequestMapping("/update")
public AjaxResult update(@Valid @RequestBody QuestionBank questionBank) {
QuestionBank insert = questionBankService.update(questionBank);
return AjaxResult.success(insert);
}
@RequestMapping("/delete")
public AjaxResult delete(Integer id) {
boolean flag = questionBankService.deleteById(id);
return AjaxResult.success(flag);
}
@RequestMapping("/deletes")
public AjaxResult deletes(IdsVo idsVo) {
List<Integer> ids = idsVo.getIds();
questionBankService.deleteByIds(ids);
return AjaxResult.success();
}
@RequestMapping("/searchCount")
public AjaxResult searchCount(String keyWord) {
Map<String, Long> map = questionBankService.searchCount(keyWord);
return AjaxResult.success(map);
}
注意:项目内采用的logo、图片等素材均来源于网络,数据均是模拟测试数据。
登录
主页
考试管理
报名成功
我的考试
查看成绩
考试页面
考场实时监控平台
考试管理
题库管理
用户管理
查看试卷
随机抽题
计算机毕设选题大全及项目分享:
https://blog.csdn.net/WEB_DC/article/details/125563252