Forráskód Böngészése

错题及知识点统计调整

mingfu 1 hete
szülő
commit
16bbf1fecb

+ 8 - 2
ie-admin/src/main/java/com/ruoyi/web/controller/front/FrontWrongBookController.java

@@ -1,5 +1,6 @@
 package com.ruoyi.web.controller.front;
 
+import com.alibaba.fastjson2.util.DateUtils;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.page.TableDataInfo;
@@ -8,6 +9,7 @@ import com.ruoyi.learn.service.ILearnWrongBookService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
 @Api(tags = "前端V2 错题本")
@@ -32,11 +34,15 @@ public class FrontWrongBookController extends BaseController {
 
     @ApiOperation("错题列表")
     @GetMapping("wrongQuestions")
-    public TableDataInfo wrongQuestions(@ApiParam("科目id") @RequestParam Long subjectId,
+    public TableDataInfo wrongQuestions(@ApiParam("科目id") @RequestParam(required = false) Long subjectId,
+                                        @ApiParam("开始日期yyyy-MM-dd") @RequestParam(required = false) String start,
+                                        @ApiParam("结束时间yyyy-MM-dd") @RequestParam(required = false) String end,
                                         @ApiParam(value = "页数", example = "1") @RequestParam Integer pageNum,
                                         @ApiParam(value = "页大小", example = "15") @RequestParam Integer pageSize) {
         startPage();
-        return getDataTable(wrongBookService.findWrongQuestions(subjectId));
+        return getDataTable(wrongBookService.findWrongQuestions(subjectId,
+                StringUtils.isNotBlank(start) ? DateUtils.parseDate(start, "yyyy-MM-dd") : null,
+                StringUtils.isNotBlank(end) ? DateUtils.parseDate(end, "yyyy-MM-dd") : null));
     }
 
     @ApiOperation("错题考卷列表")

+ 8 - 1
ie-admin/src/main/java/com/ruoyi/web/service/CommService.java

@@ -77,8 +77,15 @@ public class CommService {
     public List<LearnTeacherService.TreeNode> buildTree(List<LearnKnowledgeTree> ktList, Set<Long> knowledgeIdSet, Map<Long, Integer[]> knowCountMap) {
         List<LearnTeacherService.TreeNode> treeNodeList = Lists.newArrayList();
         Map<Long, LearnTeacherService.TreeNode> teMap = Maps.newHashMap();
+        Integer[] counts;
         for(LearnKnowledgeTree kt : ktList) {
-            LearnTeacherService.TreeNode tn = new LearnTeacherService.TreeNode(kt.getId(), kt.getName(), null != knowCountMap ? knowCountMap.get(kt.getId()) : null);
+            LearnTeacherService.TreeNode tn;
+            if(null != knowCountMap && null != (counts = knowCountMap.get(kt.getId()))) {
+                Double rate = counts[2] > 0 ? Math.max(Math.round(counts[2] * 1000.0 / counts[1]) / 10.0, 0.1) : 0.0;
+                tn = new LearnTeacherService.TreeNode(kt.getId(), kt.getName(),  counts, rate);
+            } else {
+                tn = new LearnTeacherService.TreeNode(kt.getId(), kt.getName(),  null, null);
+            }
             teMap.put(kt.getId(), tn);
         }
         for(LearnKnowledgeTree kt : ktList) {

+ 4 - 2
ie-admin/src/main/java/com/ruoyi/web/service/LearnTeacherService.java

@@ -309,7 +309,7 @@ public class LearnTeacherService {
             cond.put("types", Lists.newArrayList("单选题", "判断题"));
             knowCountMap = Maps.newHashMap();
             for(LearnQuestions qs : learnQuestionsMapper.statByKnowledge(cond)) {
-                knowCountMap.put(qs.getKnowledgeId(), new Integer[] { qs.getNumber().intValue(), qs.getId().intValue()} );
+                knowCountMap.put(qs.getKnowledgeId(), new Integer[] { qs.getNumber().intValue(), qs.getId().intValue(), qs.getYear().intValue()} );
             }
         }
         return commService.buildTree(ktList, knowledgeIdSet, knowCountMap);
@@ -420,14 +420,16 @@ public class LearnTeacherService {
         private Integer status;
         private Integer questionCount;
         private Integer finishedCount;
+        private Double finishedRatio;
 
         List<TreeNode> children = Lists.newArrayList();
-        public TreeNode(Long id, String name, Integer[] counts) {
+        public TreeNode(Long id, String name, Integer[] counts, Double finishedRatio) {
             this.id = id;
             this.name = name;
             this.status = 0;
             this.questionCount = null != counts ? counts[0] : 0;
             this.finishedCount = null != counts ? counts[1] : 0;
+            this.finishedRatio = finishedRatio;
         }
 
         public boolean setChecked(Set<Long> idSet) {

+ 2 - 1
ie-common/src/main/java/com/ruoyi/common/utils/CommonUtils.java

@@ -22,8 +22,9 @@ public class CommonUtils {
 
 
     public static void normalRate(JSONObject o) {
+        Integer val = o.getInteger("value");
         Double rate = o.getDouble("rate");
-        if(null != rate && rate < 0.01) {
+        if(null != val && null != rate && val > 0 && rate < 0.01) {
             o.put("rate", 0.1);
         }
     }

+ 2 - 1
ie-system/src/main/java/com/ruoyi/learn/service/ILearnWrongBookService.java

@@ -1,5 +1,6 @@
 package com.ruoyi.learn.service;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -68,7 +69,7 @@ public interface ILearnWrongBookService
 
     public List<DzSubject> findSubject();
 
-    public List<LearnWrongBook> findWrongQuestions(Long subjectId);
+    public List<LearnWrongBook> findWrongQuestions(Long subjectId, Date start, Date end);
 
     public List<LearnWrongBook> findWrongExaminees(Long wrongId);
 

+ 4 - 1
ie-system/src/main/java/com/ruoyi/learn/service/impl/LearnWrongBookServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ruoyi.learn.service.impl;
 
 import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -116,10 +117,12 @@ public class LearnWrongBookServiceImpl implements ILearnWrongBookService
         return subjectMapper.selectWrongSubjectList(SecurityUtils.getUserId());
     }
 
-    public List<LearnWrongBook> findWrongQuestions(Long subjectId) {
+    public List<LearnWrongBook> findWrongQuestions(Long subjectId, Date start, Date end) {
         Map cond = Maps.newHashMap();
         cond.put("subjectId", subjectId);
         cond.put("studentId", SecurityUtils.getUserId());
+        cond.put("start", start);
+        cond.put("end", end);
         List<LearnWrongBook> wrongBookList = learnWrongBookMapper.findWrongQuestions(cond);
         if(wrongBookList.size() > 0) {
             Map<Long, LearnQuestions> qMap = questionsMapper.selectLearnQuestionsByIds(wrongBookList.stream().map(LearnWrongBook::getQuestionId).toArray(Long[]::new)).stream().collect(Collectors.toMap(LearnQuestions::getId, t -> t));

+ 1 - 1
ie-system/src/main/resources/mapper/learn/LearnAnswerMapper.xml

@@ -67,7 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="selectClassQuestionStats" parameterType="Map" resultType="com.alibaba.fastjson2.JSONObject">
-        SELECT ls.`student_id` id, u.`nick_name` `name`, COUNT(*) total , COUNT(DISTINCT DATE(a.create_time)) `time`, ROUND(SUM(IF(a.`state` = 1, 1, 0)) * 100 / COUNT(*), 1) rate
+        SELECT ls.`student_id` id, u.`nick_name` `name`, COUNT(*) total , COUNT(DISTINCT DATE(a.create_time)) `time`, SUM(IF(a.`state` = 1, 1, 0)) `value`, ROUND(SUM(IF(a.`state` = 1, 1, 0)) * 100 / COUNT(*), 1) rate
           FROM `learn_answer` a
           JOIN `learn_student` ls ON ls.`student_id` = a.`student_id`
           JOIN `sys_user` u ON ls.`student_id` = u.`user_id`

+ 1 - 1
ie-system/src/main/resources/mapper/learn/LearnQuestionsMapper.xml

@@ -281,7 +281,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="statByKnowledge" parameterType="map" resultMap="LearnQuestionsResult">
-        SELECT kq.knowledge_id `knowledgeId`, COUNT(DISTINCT kq.`question_id`) number, COUNT(DISTINCT IF(a.`student_id` IS NOT NULL, kq.`question_id`, NULL)) id
+        SELECT kq.knowledge_id `knowledgeId`, COUNT(DISTINCT kq.`question_id`) number, COUNT(DISTINCT IF(a.`student_id` IS NOT NULL, kq.`question_id`, NULL)) id, COUNT(DISTINCT IF(a.`student_id` IS NOT NULL AND a.`state` = 1, kq.`question_id`, NULL)) year
         FROM `learn_knowledge_question` kq
         LEFT JOIN `learn_answer` a ON kq.`question_id` = a.`question_id` AND a.`student_id` = #{studentId}
         JOIN `learn_questions` q ON q.`id` = kq.`question_id`

+ 3 - 1
ie-system/src/main/resources/mapper/learn/LearnWrongBookMapper.xml

@@ -171,7 +171,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <where>
             wb.`student_id` = #{studentId} AND q.`qtpye` IN ('判断题', '单选题', '选择题','单项选择','单项选择题','多选题')
             <if test="subjectId != null "> and wb.`subject_id` = #{subjectId}</if>
+            <if test="start != null "> and date(wb.`created_time`) &gt;= date(#{start})</if>
+            <if test="end != null "> and date(wb.`created_time` &lt;= date(#{end})</if>
         </where>
-
+        order by wb.`created_time` desc
     </select>
 </mapper>