package dhu.cst.ExamSystem.service.Impl;
import com.alibaba.fastjson.JSON;
import dhu.cst.ExamSystem.common.AccuracyResult;
import dhu.cst.ExamSystem.common.RateResult;
import dhu.cst.ExamSystem.dao.*;
import dhu.cst.ExamSystem.entity.*;
import dhu.cst.ExamSystem.service.IQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service("QuestionService")
@Transactional
public class QuestionServiceImpl implements IQuestionService {
@Autowired
QuestionRepository questionRepository;
@Autowired
PdetailRepository pdetailRepository;
@Autowired
ExamRepository examRepository;
@Autowired
PaperRepository paperRepository;
@Autowired
PointRepository pointRepository;
@Autowired
AnswerRepository answerRepository;
@Override
public List<String> getbank(long subjectId){
return questionRepository.getbanks(subjectId);
}
@Override
public List<Question> getquestion(long subjectId,Integer page,Integer size){
Pageable pageable = PageRequest.of(page-1,size);
Page<Question> qp = questionRepository.findBySubjectIdAndPointIdIsNotNull(subjectId,pageable);
return qp.getContent();
}
@Override
public Map integratedquery(String bankName,long pointId,long type,Integer page,Integer size){
Pageable pageable = PageRequest.of(page-1,size);
System.out.println(type);
Page<Question> pq = questionRepository.integratedquery(bankName,pointId,type,pageable);
Map m = new HashMap();
Integer qnum = questionRepository.integratedquery(bankName,pointId,type);
m.put("questions",pq.getContent());
m.put("quesnum",qnum);
return m;
}
@Override
public Map getquefromexam(long paperId,Integer page,Integer size){
Pageable pageable = PageRequest.of(page-1,size);
Page<Pdetail> pd = pdetailRepository.findByPaperIdOrderByQuestionType(paperId,pageable);
Map m = new HashMap();
int qnum = pdetailRepository.countByPaperId(paperId);
m.put("questions",pd.getContent());
m.put("quesnum",qnum);
return m;
}
@Override
public List<Question> getquestionbybank(String bankName,Integer page,Integer size){
Pageable pageable = PageRequest.of(page-1,size);
Page<Question> qp = questionRepository.findByBankNameAndPointIdIsNotNull(bankName,pageable);
return qp.getContent();
}
@Override
public List<Question> getquestionbypoint(long subjectId,long pointId,Integer page,Integer size){
Pageable pageable = PageRequest.of(page-1,size);
Page<Question> qp = questionRepository.findBySubjectIdAndPointId(subjectId,pointId,pageable);
return qp.getContent();
}
@Override
public List<Question> getquestionbytype(long subjectId,long type,Integer page,Integer size){
Pageable pageable = PageRequest.of(page-1,size);
Page<Question> qp = questionRepository.findBySubjectIdAndQuestionType(subjectId,type,pageable);
return qp.getContent();
}
@Override
public List<Pdetail> getquefromexambypoint(long paperId,long pointId,Integer page,Integer size){
Pageable pageable = PageRequest.of(page-1,size);
Page<Pdetail> pd = pdetailRepository.findByPaperIdAndPointIdOrderByQuestionType(paperId,pointId,pageable);
return pd.getContent();
}
@Override
public List<Pdetail> getquefromexambytype(long paperId,long type,Integer page,Integer size){
Pageable pageable = PageRequest.of(page-1,size);
Page<Pdetail> pd = pdetailRepository.findByPaperIdAndQuestionTypeOrderByQuestionType(paperId,type,pageable);
return pd.getContent();
}
@Override
public Map addquestion(String queinfo){
Map m = new HashMap();
List<Question> lquestion = JSON.parseArray(JSON.parseObject(queinfo).getString("question"), Question.class);
if(lquestion.size()!=0){
Question question = lquestion.get(0);
String opt = question.getOpt();
questionRepository.save(question);
m.put("msg","Operating successfully!");
}
return m;
}
@Override
public boolean saveall(List<Question> lq){
questionRepository.saveAll(lq);
return true;
}
@Override
public Map delquestion(long questionid){
Map m = new HashMap();
questionRepository.deleteByQuestionId(questionid);
m.put("msg","Delete successfully!");
return m;
}
@Override
public boolean addbank(long subjectId,String bankname){
questionRepository.savebank(subjectId,bankname);
return true;
}
@Override
public boolean changebankname(String oldname,String newname){
questionRepository.updatebankname(oldname,newname);
return true;
}
@Override
public boolean delbank(String bankname){
questionRepository.deleteByBankName(bankname);
return true;
}
@Override
public Map addquestiontoexam(long questionId, long paperId){
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Map m = new HashMap();
List<Pdetail> pdl = pdetailRepository.findByPaperIdAndQuestionId(paperId,questionId);
if(pdl.size()!=0){
m.put("msg","请勿重复添加");
return m;
}
List<Question> que = questionRepository.findByQuestionIdAndPointIdIsNotNull(questionId);
Map n = getquestionnum(paperId);
switch((int) que.get(0).getQuestionType()){
case 0:
if(n.get("single_added")==n.get("single_total")){
m.put("msg","单选题数量已超出范围,添加失败!");
return m;
}
break;
case 1:
if(n.get("multiple_added")==n.get("multiple_total")){
m.put("msg","多选题数量已超出范围,添加失败!");
return m;
}
break;
case 2:
if(n.get("blank_added")==n.get("blank_total")){
m.put("msg","填空题数量已超出范围,添加失败!");
return m;
}
break;
}
if(que.size()!=0){
Question question = que.get(0);
Pdetail pd = new Pdetail();
pd.setPaperId(paperId);
pd.setQuestionId(questionId);
pd.setQuestionType(question.getQuestionType());
pd.setQuestionName(question.getQuestionName());
pd.setOpt(question.getOpt());
pd.setCorAnswer(question.getQuestionAnswer());
pd.setPointId(question.getPointId());
pdetailRepository.save(pd);
n = getquestionnum(paperId);
System.out.println(n.get("single_added"));
switch((int) pd.getQuestionType()){
case 0:
m.put("msg","添加成功! 单选题:"+n.get("single_added")+"/"+n.get("single_total"));
break;
case 1:
m.put("msg","添加成功! 多选题:"+n.get("multiple_added")+"/"+n.get("multiple_total"));
break;
case 2:
m.put("msg","添加成功! 填空题:"+n.get("blank_added")+"/"+n.get("blank_total"));
break;
}
}
return m;
}
@Override
public Map delquefromexam(long questionid, long paperid){
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于SpringBoot+Vue 在线考试系统,项目经过测试,可完美运行! 后端 ExamSystem 前端 admin_teacher (管理员和教师端) 前端 student(学生端) 部署: 本地环境需要装有mysql、redis、vue 部署项目需要运行exam.sql并确定运行成功 需要在后端源代码中application.properties中改mysql数据库密码为本地数据库密码 需要在dhu.cst.ExamSystem.config.BaiDuAiConfig中更改三个密钥为百度AI平台自己的密钥 分别进入admin_teacher和student,npm install安装依赖,速度慢可以装淘宝镜像使用cnpm 运行: 启动redis、mysql后并启动后端在8080端口 分别进入admin、student目录执行npm run dev启动前端 实现功能 管理员端:用户信息增删查改 用户权限启用、禁用 教师端:题库管理 试卷管理 组卷 考试管理 可视化成绩查询 试卷分析 学生端:参加考试 成绩查询 题目收藏 题目讨论
资源推荐
资源详情
资源评论
收起资源包目录
课程设计项目,基于SpringBoot+Vue 在线考试系统 (484个子文件)
.babelrc 230B
mvnw.cmd 6KB
index.css 414KB
app.1bc3928e 3.css 246KB
app.1bc3928e.css 246KB
chunk-libs.3dfb7769 3.css 3KB
chunk-libs.3dfb7769.css 3KB
iconfont.css 2KB
chunk-6c8d09e6.4abd9f8b 3.css 2KB
chunk-6c8d09e6.4abd9f8b.css 2KB
chunk-7dd6497f.486eb35b 3.css 1KB
chunk-7dd6497f.486eb35b.css 1KB
waves.css 825B
chunk-52730f3f.d279b7eb 3.css 366B
chunk-24cc7be2.d279b7eb.css 366B
chunk-52730f3f.d279b7eb.css 366B
chunk-3016c385.3d0613af.css 123B
chunk-7fb58113.5e7c2707.css 82B
chunk-72604a67.5e7c2707.css 82B
chunk-7fb58113.5e7c2707 3.css 82B
chunk-76502484.5e7c2707.css 82B
chunk-72604a67.5e7c2707 3.css 82B
.env.development 555B
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.editorconfig 244B
.editorconfig 147B
iconfont.eot 2KB
.eslintignore 34B
401.gif 160KB
.gitignore 333B
.gitignore 299B
.gitignore 256B
.gitignore 154B
.gitkeep 0B
index.hbs 302B
index.hbs 302B
index.hbs 185B
index 3.html 4KB
index.html 4KB
index.html 488B
index.html 273B
favicon.ico 66KB
favicon 3.ico 66KB
favicon.ico 66KB
maven-wrapper.jar 50KB
QuestionServiceImpl.java 11KB
ExamServiceImpl.java 11KB
QuestionController.java 8KB
DiscussServiceImpl.java 6KB
excelController.java 6KB
ExamsetServiceImpl.java 6KB
AdminUserServiceImpl.java 5KB
MavenWrapperDownloader.java 5KB
AuthController.java 4KB
JWTAuthenticationFilter.java 4KB
GradeController.java 3KB
SecurityConfig.java 3KB
VerifyCode.java 3KB
ExamTeaController.java 3KB
PaperServiceImpl.java 3KB
JWTAuthorizationFilter.java 3KB
StuExamController.java 3KB
ExportEncodeUtil.java 3KB
GradeServiceImpl.java 3KB
SubjectImportListener.java 2KB
TeaServiceImpl.java 2KB
JwtTokenUtils.java 2KB
QuestionRepository.java 2KB
DiscussController.java 2KB
OptcontextConverter.java 2KB
CorsConfig.java 2KB
Exam.java 2KB
PointServiceImpl.java 2KB
SwaggerConfig.java 2KB
DiscussRepository.java 2KB
JwtUser.java 2KB
SubjectTypeConverter.java 2KB
PointConverter.java 1KB
PaperController.java 1KB
PointController.java 1KB
RoleUtil.java 1KB
IQuestionService.java 1KB
QuecontextConverter.java 1KB
AdminDiscussController.java 1KB
PdetailRepository.java 1KB
ScoreviewRepository.java 1KB
ExamRepository.java 1KB
Paperview.java 1KB
RedisUtil.java 1KB
AnswerController.java 1KB
MyRedisConfig.java 993B
GlobalExceptionHandler.java 974B
ExcelToolUtil.java 968B
AnswerRepository.java 959B
VerifyCodeController.java 913B
共 484 条
- 1
- 2
- 3
- 4
- 5
资源评论
白话机器学习
- 粉丝: 8910
- 资源: 7681
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功