|
@@ -1,5 +1,6 @@
|
|
|
package com.ynfy.buss.exam.examreview.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.NumberUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -81,7 +82,7 @@ public class ExamReviewServiceImpl extends ServiceImpl<ExamReviewMapper, ExamRev
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void submitPreview(PreviewSubmitDTO dto) {
|
|
|
+ public void submitPreview(PreviewSubmitDTO dto, LoginUser user) {
|
|
|
if (StringUtils.isEmpty(dto.getUserExamId())) {
|
|
|
throw new JeecgBootException("考试ID不能为空");
|
|
|
}
|
|
@@ -111,7 +112,6 @@ public class ExamReviewServiceImpl extends ServiceImpl<ExamReviewMapper, ExamRev
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(examPreviews)) {
|
|
|
List<UserExamQuestion> resultList = new ArrayList<>();
|
|
|
- double subjectiveScore = 0;
|
|
|
for (ExamPreviewDTO o : examPreviews) {
|
|
|
//根据题目序号中获取考题
|
|
|
UserExamQuestion userExamQuestion = examService.getUserExamQuestionByIndex(o.getIndex(), userExamQuestionMap);
|
|
@@ -121,8 +121,9 @@ public class ExamReviewServiceImpl extends ServiceImpl<ExamReviewMapper, ExamRev
|
|
|
userExamQuestion.setActualScore(o.getActualScore());
|
|
|
userExamQuestion.setIsRight(o.getIsRight());
|
|
|
resultList.add(userExamQuestion);
|
|
|
- subjectiveScore += o.getActualScore();
|
|
|
}
|
|
|
+ //主观题得分
|
|
|
+ double subjectiveScore = resultList.stream().mapToDouble(UserExamQuestion::getActualScore).sum();
|
|
|
//组合题
|
|
|
List<UserExamQuestion> combinationQuestionList = rootQuestionList.stream().filter(q ->
|
|
|
QuestionType.COMBINATION.getCode().equals(q.getQuestionType())).collect(Collectors.toList());
|
|
@@ -132,6 +133,7 @@ public class ExamReviewServiceImpl extends ServiceImpl<ExamReviewMapper, ExamRev
|
|
|
long simpleCount = question.getSubQuestionList().stream().filter(q -> QuestionType.SIMPLE.getCode()
|
|
|
.equals(q.getQuestionType())).count();
|
|
|
if (simpleCount > 0) {
|
|
|
+ //更新组合题得分
|
|
|
question.setActualScore(question.getSubQuestionList().stream().filter(o ->
|
|
|
!Objects.isNull(o.getActualScore())).mapToDouble(UserExamQuestion::getActualScore).sum());
|
|
|
if (question.getActualScore() > 0) {
|
|
@@ -151,9 +153,10 @@ public class ExamReviewServiceImpl extends ServiceImpl<ExamReviewMapper, ExamRev
|
|
|
|
|
|
//用户得分,主观题得分,更新阅卷人,阅卷时间,考试状态
|
|
|
userExam.setSubjectiveScore(subjectiveScore);//主观题得分
|
|
|
- userExam.setUserScore(userExam.getUserScore() + subjectiveScore);//用户最终得分
|
|
|
+ userExam.setUserScore(NumberUtil.round(NumberUtil.add(userExam.getUserScore().doubleValue(), subjectiveScore),
|
|
|
+ 1).doubleValue());//用户最终得分
|
|
|
userExam.setPreviewTime(new Date());
|
|
|
- LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ //阅卷人
|
|
|
userExam.setPreviewUser(user.getRealname());
|
|
|
userExam.setState(PaperState.FINISHED);
|
|
|
int pass = userExam.getUserScore() >= userExam.getQualifyScore() ? 1 : 0;
|