From b9c9e52187fd8f47218ddefa514987c59d98f72c Mon Sep 17 00:00:00 2001
From: hjl <1657978663@qq.com>
Date: 星期四, 20 六月 2024 11:25:07 +0800
Subject: [PATCH] fix: 学习端bug

---
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java |   58 +++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 47 insertions(+), 11 deletions(-)

diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java
index 17ba213..3ce58ac 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java
@@ -852,26 +852,62 @@
         if (null == userStudy) {
             userStudy = createUserStudy(userid);
         }
+        Integer quarter = exitLearn.getQuarter();
+        Integer week = exitLearn.getWeek();
+        Integer day = exitLearn.getDay();
         if (userStudy.getWeek().equals(exitLearn.getWeek()) && userStudy.getDay().equals(exitLearn.getDay())) {
             // 计算完成率
-            int completionRate = exitLearn.getTopicIds().split(",").length * 5;
+            List<String> teamList = Arrays.stream(exitLearn.getTeamIds().split(",")).collect(Collectors.toList());
             Integer type = exitLearn.getType();
             // 更新用户学习完成率
-            if (Constants.ONE.equals(type) && userStudy.getListen() < completionRate) {
+            if (Constants.ONE.equals(type)) {
                 // 听音选图
-                userStudy.setListen(completionRate);
-            } else if (Constants.TWO.equals(type) && userStudy.getLook() < completionRate) {
+                List<TStudyListen> studyListens = studyListenService.listenSelectPicture(quarter, week, day);
+                int item = 0;
+                for (TStudyListen studyListen : studyListens) {
+                    item += studyListen.getSubject().split(",").length;
+                }
+                int i = exitLearn.getTopicIds().split(",").length / item;
+                if (i > userStudy.getListen()) {
+                    userStudy.setListen(100 - i);
+                }
+            } else if (Constants.TWO.equals(type)) {
                 // 看图选音
-                userStudy.setLook(completionRate);
-            } else if (Constants.THREE.equals(type) && userStudy.getInduction() < completionRate) {
+                List<TStudyLook> lookList = studyLookService.pictureSelectVoice(quarter, week, day);
+                if (!lookList.isEmpty()) {
+                    int item = lookList.size();
+                    int i = exitLearn.getSchedule() / item;
+                    if (i > userStudy.getLook()) {
+                        userStudy.setLook(100 - i);
+                    }
+                }
+            } else if (Constants.THREE.equals(type)) {
                 // 归纳排除
-                userStudy.setInduction(completionRate);
-            } else if (Constants.FOUR.equals(type) && userStudy.getAnswer() < completionRate) {
+                List<TStudyInduction> inductionList = studyInductionService.induceExclude(quarter, week, day);
+                if (!inductionList.isEmpty()) {
+                    int item = inductionList.size();
+                    int i = exitLearn.getSchedule() / item;
+                    if (i > userStudy.getInduction()) {
+                        userStudy.setInduction(100 - i);
+                    }
+                }
+            } else if (Constants.FOUR.equals(type)) {
                 // 有问有答
-                userStudy.setAnswer(completionRate);
-            } else if (Constants.FIVE.equals(type) && userStudy.getPair() < completionRate) {
+                List<TStudyAnswer> answerList = studyAnswerService.questionsAndAnswers(quarter, week, day);
+                if (answerList.size() % Constants.TWO == Constants.ZERO) {
+                    int i = exitLearn.getSchedule() / (answerList.size() / 2);
+                    if (i > userStudy.getAnswer()) {
+                        userStudy.setAnswer(100 - i);
+                    }
+                }
+            } else if (Constants.FIVE.equals(type)) {
                 // 音图相配
-                userStudy.setPair(completionRate);
+                List<TStudyPair> pairList = studyPairService.pictureMateVoice(quarter, week, day);
+                int item = pairList.size();
+                int i = exitLearn.getSchedule() / item;
+                if (i > userStudy.getPair()) {
+                    userStudy.setPair(100 - i);
+                }
             }
         }
         // 学习时长更新

--
Gitblit v1.7.1