Bläddra i källkod

前端过滤非定向知识点

mingfu 1 månad sedan
förälder
incheckning
56c031f123

+ 23 - 1
ie-admin/src/main/java/com/ruoyi/web/controller/front/FrontPaperController.java

@@ -12,6 +12,7 @@ import com.ruoyi.dz.domain.DzSubject;
 import com.ruoyi.dz.service.IDzControlService;
 import com.ruoyi.dz.service.IDzSubjectService;
 import com.ruoyi.enums.PaperType;
+import com.ruoyi.learn.domain.LearnKnowledgeTree;
 import com.ruoyi.learn.domain.LearnPaper;
 import com.ruoyi.learn.domain.LearnStudent;
 import com.ruoyi.learn.domain.LearnTest;
@@ -93,7 +94,28 @@ public class FrontPaperController {
     public AjaxResult getKnowledge(@ApiParam("定向") @RequestParam(defaultValue = "false") boolean directed, @ApiParam("科目ID") Long subjectId) {
         LearnStudent learnStudent = learnStudentService.selectLearnStudentByStudentId(SecurityUtils.getUserId());
         Long[] planIds = null != learnStudent ? new Long[] { learnStudent.getMajorPlanId() } : null;
-        return AjaxResult.success(learnTeacherService.getKnowledgeTree(subjectId, planIds, true));
+        List<LearnTeacherService.TreeNode> nodeList = learnTeacherService.getKnowledgeTree(subjectId, planIds, true);
+        List<LearnTeacherService.TreeNode> finalList = Lists.newArrayList();
+        for(LearnTeacherService.TreeNode parent : nodeList) {
+            if(CollectionUtils.isEmpty(parent.getChildren())) {
+                continue;
+            }
+            parent.setQuestionCount(0);
+            parent.setFinishedCount(0);
+            List<LearnTeacherService.TreeNode> childList = Lists.newArrayList();
+            for(LearnTeacherService.TreeNode child : parent.getChildren()) {
+                if(child.getStatus().equals(1)) { // TODO 暂不过滤无题的  && child.getQuestionCount() > 0
+                    childList.add(child);
+                    parent.setQuestionCount(parent.getQuestionCount() + child.getQuestionCount());
+                    parent.setFinishedCount(parent.getFinishedCount() + child.getFinishedCount());
+                }
+            }
+            if(childList.size() > 0) {
+                parent.setChildren(childList);
+                finalList.add(parent);
+            }
+        }
+        return AjaxResult.success(finalList);
     }
 
     @ApiOperation("04 取试卷")