package com.mindskip.xzs.service.impl;
import com.mindskip.xzs.domain.*;
import com.mindskip.xzs.domain.*;
import com.mindskip.xzs.domain.enums.ExamPaperAnswerStatusEnum;
import com.mindskip.xzs.domain.enums.ExamPaperTypeEnum;
import com.mindskip.xzs.domain.enums.QuestionTypeEnum;
import com.mindskip.xzs.domain.exam.ExamPaperTitleItemObject;
import com.mindskip.xzs.domain.other.KeyValue;
import com.mindskip.xzs.domain.other.ExamPaperAnswerUpdate;
import com.mindskip.xzs.domain.task.TaskItemAnswerObject;
import com.mindskip.xzs.repository.*;
import com.mindskip.xzs.repository.ExamPaperAnswerMapper;
import com.mindskip.xzs.repository.ExamPaperMapper;
import com.mindskip.xzs.repository.TaskExamCustomerAnswerMapper;
import com.mindskip.xzs.service.ExamPaperAnswerService;
import com.mindskip.xzs.service.ExamPaperQuestionCustomerAnswerService;
import com.mindskip.xzs.service.TextContentService;
import com.mindskip.xzs.utility.DateTimeUtil;
import com.mindskip.xzs.utility.ExamUtil;
import com.mindskip.xzs.utility.JsonUtil;
import com.mindskip.xzs.viewmodel.student.exam.ExamPaperSubmitItemVM;
import com.mindskip.xzs.viewmodel.student.exam.ExamPaperSubmitVM;
import com.mindskip.xzs.viewmodel.student.exampaper.ExamPaperAnswerPageVM;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mindskip.xzs.repository.QuestionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class ExamPaperAnswerServiceImpl extends BaseServiceImpl<ExamPaperAnswer> implements ExamPaperAnswerService {
private final ExamPaperAnswerMapper examPaperAnswerMapper;
private final ExamPaperMapper examPaperMapper;
private final TextContentService textContentService;
private final QuestionMapper questionMapper;
private final ExamPaperQuestionCustomerAnswerService examPaperQuestionCustomerAnswerService;
private final TaskExamCustomerAnswerMapper taskExamCustomerAnswerMapper;
@Autowired
public ExamPaperAnswerServiceImpl(ExamPaperAnswerMapper examPaperAnswerMapper, ExamPaperMapper examPaperMapper, TextContentService textContentService, QuestionMapper questionMapper, ExamPaperQuestionCustomerAnswerService examPaperQuestionCustomerAnswerService, TaskExamCustomerAnswerMapper taskExamCustomerAnswerMapper) {
super(examPaperAnswerMapper);
this.examPaperAnswerMapper = examPaperAnswerMapper;
this.examPaperMapper = examPaperMapper;
this.textContentService = textContentService;
this.questionMapper = questionMapper;
this.examPaperQuestionCustomerAnswerService = examPaperQuestionCustomerAnswerService;
this.taskExamCustomerAnswerMapper = taskExamCustomerAnswerMapper;
}
@Override
public PageInfo<ExamPaperAnswer> studentPage(ExamPaperAnswerPageVM requestVM) {
return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() ->
examPaperAnswerMapper.studentPage(requestVM));
}
@Override
public ExamPaperAnswerInfo calculateExamPaperAnswer(ExamPaperSubmitVM examPaperSubmitVM, User user) {
ExamPaperAnswerInfo examPaperAnswerInfo = new ExamPaperAnswerInfo();
Date now = new Date();
ExamPaper examPaper = examPaperMapper.selectByPrimaryKey(examPaperSubmitVM.getId());
ExamPaperTypeEnum paperTypeEnum = ExamPaperTypeEnum.fromCode(examPaper.getPaperType());
//任务试卷只能做一次
if (paperTypeEnum == ExamPaperTypeEnum.Task) {
ExamPaperAnswer examPaperAnswer = examPaperAnswerMapper.getByPidUid(examPaperSubmitVM.getId(), user.getId());
if (null != examPaperAnswer)
return null;
}
String frameTextContent = textContentService.selectById(examPaper.getFrameTextContentId()).getContent();
List<ExamPaperTitleItemObject> examPaperTitleItemObjects = JsonUtil.toJsonListObject(frameTextContent, ExamPaperTitleItemObject.class);
List<Integer> questionIds = examPaperTitleItemObjects.stream().flatMap(t -> t.getQuestionItems().stream().map(q -> q.getId())).collect(Collectors.toList());
List<Question> questions = questionMapper.selectByIds(questionIds);
//将题目结构的转化为题目答案
List<ExamPaperQuestionCustomerAnswer> examPaperQuestionCustomerAnswers = examPaperTitleItemObjects.stream()
.flatMap(t -> t.getQuestionItems().stream()
.map(q -> {
Question question = questions.stream().filter(tq -> tq.getId().equals(q.getId())).findFirst().get();
ExamPaperSubmitItemVM customerQuestionAnswer = examPaperSubmitVM.getAnswerItems().stream()
.filter(tq -> tq.getQuestionId().equals(q.getId()))
.findFirst()
.orElse(null);
return ExamPaperQuestionCustomerAnswerFromVM(question, customerQuestionAnswer, examPaper, q.getItemOrder(), user, now);
})
).collect(Collectors.toList());
ExamPaperAnswer examPaperAnswer = ExamPaperAnswerFromVM(examPaperSubmitVM, examPaper, examPaperQuestionCustomerAnswers, user, now);
examPaperAnswerInfo.setExamPaper(examPaper);
examPaperAnswerInfo.setExamPaperAnswer(examPaperAnswer);
examPaperAnswerInfo.setExamPaperQuestionCustomerAnswers(examPaperQuestionCustomerAnswers);
return examPaperAnswerInfo;
}
@Override
@Transactional
public String judge(ExamPaperSubmitVM examPaperSubmitVM) {
ExamPaperAnswer examPaperAnswer = examPaperAnswerMapper.selectByPrimaryKey(examPaperSubmitVM.getId());
List<ExamPaperSubmitItemVM> judgeItems = examPaperSubmitVM.getAnswerItems().stream().filter(d -> d.getDoRight() == null).collect(Collectors.toList());
List<ExamPaperAnswerUpdate> examPaperAnswerUpdates = new ArrayList<>(judgeItems.size());
Integer customerScore = examPaperAnswer.getUserScore();
Integer questionCorrect = examPaperAnswer.getQuestionCorrect();
for (ExamPaperSubmitItemVM d : judgeItems) {
ExamPaperAnswerUpdate examPaperAnswerUpdate = new ExamPaperAnswerUpdate();
examPaperAnswerUpdate.setId(d.getId());
examPaperAnswerUpdate.setCustomerScore(ExamUtil.scoreFromVM(d.getScore()));
boolean doRight = examPaperAnswerUpdate.getCustomerScore().equals(ExamUtil.scoreFromVM(d.getQuestionScore()));
examPaperAnswerUpdate.setDoRight(doRight);
examPaperAnswerUpdates.add(examPaperAnswerUpdate);
customerScore += examPaperAnswerUpdate.getCustomerScore();
if (examPaperAnswerUpdate.getDoRight()) {
++questionCorrect;
}
}
examPaperAnswer.setUserScore(customerScore);
examPaperAnswer.setQuestionCorrect(questionCorrect);
examPaperAnswer.setStatus(ExamPaperAnswerStatusEnum.Complete.getCode());
examPaperAnswerMapper.updateByPrimaryKeySelective(examPaperAnswer);
examPaperQuestionCustomerAnswerService.updateScore(examPaperAnswerUpdates);
ExamPaperTypeEnum examPaperTypeEnum = ExamPaperTypeEnum.fromCode(examPaperAnswer.getPaperType());
switch (examPaperTypeEnum) {
case Task:
//任务试卷批改完成后,需要更新任务的状态
ExamPaper examPaper = examPaperMapper.selectByPrimaryKey(examPaperAnswer.getExamPaperId());
Integer taskId = examPaper.getTaskExamId();
Integer userId = examPaperAnswer.getCreateUser();
TaskExamCustomerAnswer taskExamCustomerAnswer = taskExamCustomerAnswerMapper.getB
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
学之思开源考试系统是一款 java + vue 的前后端分离的考试系统。主要优点是开发、部署简单快捷、界面设计友好、代码结构清晰。支持web端和微信小程序,能覆盖到pc机和手机等设备。 支持多种部署方式:集成部署、前后端分离部署、docker部署
资源推荐
资源详情
资源评论
收起资源包目录
一款 java + vue 的前后端分离的考试系统 (2864个子文件)
.browserslistrc 21B
.browserslistrc 21B
mvnw.cmd 5KB
index.css 414KB
index.css 414KB
index.00dcbe53.css 253KB
index.00dcbe53.css 253KB
chunk-vendors.768910bf.css 239KB
chunk-vendors.768910bf.css 239KB
ueditor.css 34KB
ueditor.css 34KB
ueditor.css 34KB
ueditor.min.css 34KB
ueditor.min.css 34KB
ueditor.min.css 34KB
style.664abab6.css 32KB
image.css 14KB
image.css 14KB
image.css 14KB
ui.css 9KB
ui.css 9KB
ui.css 9KB
fui.min.css 7KB
fui.min.css 7KB
fui.min.css 7KB
fui.css 7KB
fui.css 7KB
fui.css 7KB
chunk-494016cc.439404de.css 6KB
chunk-98ece67a.a43e0c22.css 6KB
chunk-98ece67a.a43e0c22.css 6KB
chunk-494016cc.439404de.css 6KB
index.a703c7b0.css 5KB
index.a703c7b0.css 5KB
chunk-41c3a950.ee265b23.css 5KB
chunk-41c3a950.ee265b23.css 5KB
chunk-41c3a950.ee265b23.css 5KB
chunk-41c3a950.ee265b23.css 5KB
chunk-vendors.ee57d822.css 3KB
chunk-vendors.ee57d822.css 3KB
chunk-0c7a3844.d650a2aa.css 3KB
chunk-0c7a3844.d650a2aa.css 3KB
codemirror.css 2KB
codemirror.css 2KB
codemirror.css 2KB
chunk-7a0d1fd4.4037e603.css 2KB
chunk-7a0d1fd4.4037e603.css 2KB
dialogbase.css 1KB
dialogbase.css 1KB
dialogbase.css 1KB
scrollbar.css 1KB
scrollbar.css 1KB
scrollbar.css 1KB
edittable.css 878B
edittable.css 878B
edittable.css 878B
chunk-794d8528.89936c18.css 846B
chunk-794d8528.89936c18.css 846B
chunk-bf758010.b56209ba.css 712B
chunk-bf758010.b56209ba.css 712B
webuploader.css 428B
webuploader.css 428B
webuploader.css 428B
base.css 361B
base.css 361B
base.css 361B
chunk-5b83bb9c.f72e8178.css 260B
chunk-74726782.ad364b97.css 260B
chunk-198da4ac.54efd6ce.css 260B
chunk-198da4ac.54efd6ce.css 260B
chunk-5b83bb9c.f72e8178.css 260B
chunk-74726782.ad364b97.css 260B
chunk-1068de0c.c8588555.css 162B
chunk-1068de0c.c8588555.css 162B
chunk-e81d5cb2.c306629d.css 114B
chunk-3f21a632.c306629d.css 114B
chunk-681bebab.c306629d.css 114B
chunk-3b7817a1.c306629d.css 114B
chunk-5ddf2900.c306629d.css 114B
chunk-fc8742d6.c306629d.css 114B
chunk-3071721c.c306629d.css 114B
chunk-5c04caf2.c306629d.css 114B
chunk-22c2a89e.c306629d.css 114B
chunk-6ec1d454.c306629d.css 114B
chunk-915add6c.dd8c5d56.css 114B
chunk-71c463ea.dd8c5d56.css 114B
chunk-24cb0fc9.dd8c5d56.css 114B
chunk-7af7a684.dd8c5d56.css 114B
chunk-5c04caf2.c306629d.css 114B
chunk-5ddf2900.c306629d.css 114B
chunk-6ec1d454.c306629d.css 114B
chunk-22c2a89e.c306629d.css 114B
chunk-fc8742d6.c306629d.css 114B
chunk-e81d5cb2.c306629d.css 114B
chunk-3071721c.c306629d.css 114B
chunk-3f21a632.c306629d.css 114B
chunk-681bebab.c306629d.css 114B
chunk-3b7817a1.c306629d.css 114B
chunk-915add6c.dd8c5d56.css 114B
chunk-7af7a684.dd8c5d56.css 114B
共 2864 条
- 1
- 2
- 3
- 4
- 5
- 6
- 29
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 7454
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 大气橙色风格的摄影爱好者作品整站网站模板.zip
- 大气的国外摄影html5网站模板下载.zip
- 大气的餐饮管理培训网站响应式模板.zip
- 大气的广告品牌策划公司网站响应式模板.zip
- 大气动画的商业App引导页网站模板下载.zip
- 大气的网络推广建站公司网站响应式模板.rar
- 大气的网络建站公司网站html5响应式模板.rar
- 大气动画效果的互联网软件公司网站模板下载.zip
- 大气仿实物设计的咖啡屋网站模板下载.zip
- 大气仿FLASH交互的服装设计企业网站模板下载.zip
- 大气风格的安卓App应用开发公司企业模板下载.zip
- 大气风格的电工仪器企业单页模板下载.zip
- 大气风格的服装展示网站模板下载.rar
- 大气风格的app开发者产品单页模板下载.zip
- 大气风格的房地产开发企业网站模板下载.zip
- 大气风格的儿童学前教育培训学校网站模板下载.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功