Преглед изворни кода

修正练习取题计数判断

mingfu пре 1 недеља
родитељ
комит
caec438697

+ 3 - 0
ie-admin/src/main/java/com/ruoyi/web/service/ExamService.java

@@ -471,6 +471,9 @@ public class ExamService {
             paperMapper.updateLearnPaper(up);
         }
         List<LearnPaperQuestion> pqList = paperService.getQuestionsByRandom(studentId,  15, knowledgeId, Arrays.stream(QuestionType.values()).map(QuestionType::getTitle).collect(Collectors.toList()));
+        if(CollectionUtils.isEmpty(pqList)) {
+            throw new RuntimeException("本知识点题已做完");
+        }
         paper.setPaperSource(0);
         paper.setFenshu(0);
         paper.setSubjectId(knowledgeTree.getSubjectId());

+ 3 - 2
ie-admin/src/main/java/com/ruoyi/web/service/PaperService.java

@@ -416,15 +416,16 @@ public class PaperService {
                     qCond.setKnowledgeId(knowledgeId);
                     qCond.setQtpye(knowTypeAssign.getType());
                     qCond.setId(studentId);
-                    qCond.setNumber(knowTypeAssign.exclAssign > 500 ? (long) random.nextInt(knowTypeAssign.exclAssign.intValue() - 500) :  0L);
+                    qCond.setNumber(knowTypeAssign.exclCount > 500 ? (long) random.nextInt(knowTypeAssign.exclCount.intValue() - 500) :  0L);
                     qCond.setIsSubType("1");
                     questions = questionsMapper.selectQuestionsForPaper(qCond);
                     typeQuestionMap.put(knowTypeAssign.getType(), questions);
                 }
                 if(!questions.isEmpty()) {
                     int oldSize = pqList.size();
-                    knowTypeAssign.exclAssign = addRandomList(knowledgeId, knowTypeAssign.getType(), questions, random, total.longValue(), 1L, 1.0, existQuestionIdSet, 1, pqList);
+                    addRandomList(knowledgeId, knowTypeAssign.getType(), questions, random, total.longValue(), 1L, 1.0, existQuestionIdSet, 1, pqList);
                     if(oldSize != pqList.size()) {
+                        knowTypeAssign.exclAssign++;
                         for(; oldSize < pqList.size(); oldSize++) {
                             pqList.get(oldSize).setSeq(QuestionType.of(knowTypeAssign.getType()).getVal());
                         }

+ 3 - 1
ie-system/src/main/java/com/ruoyi/learn/domain/TestPaperVO.java

@@ -146,7 +146,7 @@ public class TestPaperVO {
                         types.add(cType);
                         typeMap.put(qt.name(), cType);
                     } else {
-                        cType.setScore(cType.getScore() + typeDef.getScore());
+                        cType.setScore(cType.getScore() + typeDef.getScore() * typeDef.getCount());
                         cType.setCount(cType.getCount() + typeDef.getCount());
                     }
                     this.total += typeDef.getCount();
@@ -159,6 +159,7 @@ public class TestPaperVO {
                 }
                 this.score += ktd.getScore();
             });
+            types.forEach(t -> t.setScore(t.getScore() / t.getCount()));
         }
     }
 
@@ -175,6 +176,7 @@ public class TestPaperVO {
     public static class TypeDef2 {
         String title;
         QuestionType type;
+        Integer subType; // 是否子题 1是 0不是
         Integer count;
         Double score;
     }