Procházet zdrojové kódy

分数计算不正确

yangfeng před 1 rokem
rodič
revize
1d94d93cbe

+ 1 - 1
web/src/main/java/com/ynfy/buss/exam/paper/service/impl/PaperServiceImpl.java

@@ -92,7 +92,7 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, Paper> implements
         if (Objects.isNull(dto.getJoinType())) {
             throw new JeecgBootException("组卷方式不能为空!");
         }
-        if (Objects.isNull(dto.getTotalScore()) || dto.getTotalScore().intValue() == 0) {
+        if (Objects.isNull(dto.getTotalScore()) || dto.getTotalScore().doubleValue() == 0) {
             throw new JeecgBootException("试卷总分不能为空!");
         }
         if (Objects.isNull(dto.getQuestionCount()) || dto.getQuestionCount().intValue() == 0) {

+ 1 - 1
web/src/main/java/com/ynfy/buss/exam/paperquestion/service/impl/PaperQuestionServiceImpl.java

@@ -84,7 +84,7 @@ public class PaperQuestionServiceImpl extends ServiceImpl<PaperQuestionMapper, P
                 if (!CollectionUtils.isEmpty(questionList)) {
                     if (QuestionType.COMBINATION.getCode().equals(g.getQuestionType())) {//组合题
                         for (Question q : questionList) {
-                            double questionScore = (int) q.getSubQuestionList().stream().mapToDouble(Question::getScore).sum();
+                            double questionScore = q.getSubQuestionList().stream().mapToDouble(Question::getScore).sum();
                             PaperQuestion root = generatePaperQuestion(paperId, g, q, sort, questionScore);
                             paperQuestionList.add(root);
                             //子题目

+ 2 - 2
web/src/main/java/com/ynfy/buss/exam/paperquestionanswer/service/impl/PaperQuestionAnswerServiceImpl.java

@@ -56,12 +56,12 @@ public class PaperQuestionAnswerServiceImpl extends ServiceImpl<PaperQuestionAns
                 if (QuestionType.MULTI.getCode().equals(question.getType())) {
                     //找出正确答案
                     answerList = examService.findRightList(answerList);
-                    double pathScore = NumberUtil.div(question.getScore().intValue(), answerList.size(), 2);
+                    double pathScore = NumberUtil.div(question.getScore().doubleValue(), answerList.size(), 2);
                     answerList.stream().forEach(answer ->
                             //生成试卷试题答案
                             paperQuestionAnswerList.add(generatePaperQuestionAnswer(paperId, question.getId(), answer.getId(), pathScore)));
                 } else if (QuestionType.BLANK.getCode().equals(question.getType())) {
-                    double pathScore = NumberUtil.div(question.getScore().intValue(), answerList.size(), 2);
+                    double pathScore = NumberUtil.div(question.getScore().doubleValue(), answerList.size(), 2);
                     answerList.stream().forEach(answer ->
                             paperQuestionAnswerList.add(generatePaperQuestionAnswer(paperId, question.getId(), answer.getId(), pathScore)));
                 }