Kaynağa Gözat

问题修正

mingfu 4 hafta önce
ebeveyn
işleme
efbc39690b

+ 5 - 0
ie-admin/src/main/java/com/ruoyi/web/controller/front/FrontStudentController.java

@@ -241,8 +241,12 @@ public class FrontStudentController extends BaseController {
         Long questionCnt = 0L;
         List<Dict> monthStudyList = Lists.newArrayList();
         Date firstDate = null;
+        JSONObject today = null;
         for(LearnPlanStudy study : studyList) {
             JSONObject planStudy = toStudyStats(study);
+            if(DateUtils.isSameDay(cond.getReportDate(), study.getReportDate())) {
+                today = planStudy;
+            }
             boolean videoCompleted;
             if(null != study.getVideoCount()) {
                 videoCompleted = study.getVideoCount() >= study.getVideoPlan();
@@ -283,6 +287,7 @@ public class FrontStudentController extends BaseController {
         stats.put("videoTimes", videoTimes);
         stats.put("questionCnt", questionCnt);
         stats.put("studyList", monthStudyList);
+        stats.put("today", today);
         return AjaxResult.success(stats);
     }
 

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

@@ -185,6 +185,7 @@ public class ExamService {
         if (CollectionUtils.isEmpty(answersList)){
             return;
         }
+        LearnPaper learnPaper = paperMapper.selectLearnPaperById(examinee.getPaperId());
         answersList.forEach(t -> {
             if (invalidStatusSet.contains(t.getState())) {
                 LearnWrongBook wrongBookCond = new LearnWrongBook();
@@ -209,7 +210,7 @@ public class ExamService {
                 } else {
                     wrongBookCond.setAnswer1(stdAnswer.getAnswer1());
                     wrongBookCond.setAnswer2(stdAnswer.getAnswer2());
-                    // wrongBookCond.setSubjectId(stdAnswer.getSubjectId());
+                    wrongBookCond.setSubjectId(learnPaper.getSubjectId());
                     wrongBookCond.setRightCount(0L);
                     wrongBookCond.setWrongCount(1L);
                     wrongBookCond.setTotalCount(1L);
@@ -219,7 +220,7 @@ public class ExamService {
                 wrongBookCond.setPaperId(examinee.getPaperId());
                 wrongBookCond.setScore(t.getScore());
                 wrongBookCond.setSource(source);
-                wrongBookCond.setAnswers(t.getAnswer());
+                wrongBookCond.setAnswer(t.getAnswer());
                 wrongBookCond.setState(MxjbContants.QuestionScoreWrong);
                 if(null == wrongBookCond.getWrongId()) {
                     wrongBookMapper.insertLearnWrongBook(wrongBookCond);

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

@@ -5,7 +5,7 @@ import com.alibaba.fastjson2.JSONObject;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
-import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.bean.BeanUtils;
 import com.ruoyi.enums.PaperStatus;
 import com.ruoyi.enums.PaperType;
@@ -13,11 +13,8 @@ import com.ruoyi.enums.QuestionType;
 import com.ruoyi.learn.domain.*;
 import com.ruoyi.learn.mapper.*;
 import com.ruoyi.learn.service.ILearnQuestionsService;
-import com.ruoyi.learn.service.impl.LearnQuestionsServiceImpl;
-import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.tuple.Pair;
 import org.springframework.stereotype.Service;
 
@@ -78,7 +75,7 @@ public class PaperService {
             QuestionType qt = QuestionType.of(lqs.getQtpye());
             qs.setTypeId(qt.getVal());
             qs.setType(qt.getTitle());
-            qs.setOptions(getOptions(lqs.getOptionA(), lqs.getOptionB(), lqs.getOptionC(), lqs.getOptionD(), lqs.getOptionE(), lqs.getOptionF(), lqs.getOptionG()));
+            qs.setOptions(StringUtils.getOptions(lqs.getOptionA(), lqs.getOptionB(), lqs.getOptionC(), lqs.getOptionD(), lqs.getOptionE(), lqs.getOptionF(), lqs.getOptionG()));
             if(StringUtils.isNotBlank(lqs.getTitle0())) { // 大题
                 PaperVO.QuestionSeq qg = gropuMap.get(lqs.getTitle0());
                 if(qg == null) {
@@ -138,16 +135,6 @@ public class PaperService {
         return paperQuestionList;
     }
 
-    public List<String> getOptions(String... options) {
-        List<String> optionList = Lists.newArrayList();
-        for (String option : options) {
-            if (com.ruoyi.common.utils.StringUtils.isNotBlank(option)) {
-                optionList.add(option);
-            }
-        }
-        return optionList;
-    }
-
     /**
      * 根据院校专业要求生成模拟试卷
      * @return

+ 12 - 0
ie-common/src/main/java/com/ruoyi/common/utils/StringUtils.java

@@ -3,6 +3,7 @@ package com.ruoyi.common.utils;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import com.google.common.collect.Lists;
 import com.ruoyi.common.core.text.Convert;
 import org.springframework.util.AntPathMatcher;
 import com.ruoyi.common.constant.Constants;
@@ -803,6 +804,17 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
             return false;
         }
     }
+
+    public static List<String> getOptions(String... options) {
+        List<String> optionList = Lists.newArrayList();
+        for (String option : options) {
+            if (StringUtils.isNotBlank(option)) {
+                optionList.add(option);
+            }
+        }
+        return optionList;
+    }
+
     public static void main(String[] args) {
         System.out.println(reverseCourse("物理,化学,生物"));
     }

+ 1 - 0
ie-system/src/main/java/com/ruoyi/dz/mapper/DzSubjectMapper.java

@@ -26,6 +26,7 @@ public interface DzSubjectMapper
      * @return 科目集合
      */
     public List<DzSubject> selectDzSubjectList(DzSubject dzSubject);
+    public List<DzSubject> selectWrongSubjectList(Long studentId);
 
     /**
      * 新增科目

+ 83 - 41
ie-system/src/main/java/com/ruoyi/learn/domain/LearnWrongBook.java

@@ -4,6 +4,7 @@ import java.util.Date;
 import java.util.List;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
@@ -52,7 +53,7 @@ public class LearnWrongBook extends BaseEntity
 
     /** 最后参考答案 */
     @Excel(name = "最后参考答案")
-    private String answers;
+    private String answer;
 
     /** 答案1 */
     @Excel(name = "答案1")
@@ -103,42 +104,19 @@ public class LearnWrongBook extends BaseEntity
     /** 是否收藏 */
     @Excel(name = "是否收藏")
     private Long collect;
-    String answer;
-    List<String> attachments;
-    String typeId;
-    private String qtpye;
 
-    public String getQtpye() {
-        return qtpye;
-    }
-
-    public void setQtpye(String qtpye) {
-        this.qtpye = qtpye;
-    }
-
-    public String getTypeId() {
-        return typeId;
-    }
-
-    public void setTypeId(String typeId) {
-        this.typeId = typeId;
-    }
-
-    public String getAnswer() {
-        return answer;
-    }
-
-    public void setAnswer(String answer) {
-        this.answer = answer;
-    }
-
-    public List<String> getAttachments() {
-        return attachments;
-    }
-
-    public void setAttachments(List<String> attachments) {
-        this.attachments = attachments;
-    }
+    private String knownledgeName;
+    private String title;
+    private String knowledge;
+    private String parse;
+    @ApiModelProperty("考题类型 question_type")
+    Integer typeId;
+    @ApiModelProperty("考题类型名称")
+    String type;
+    @ApiModelProperty("选项数组")
+    List<String> options;
+    @ApiModelProperty("答案数组")
+    List<String> answers;
 
     public void setWrongId(Long wrongId)
     {
@@ -220,14 +198,14 @@ public class LearnWrongBook extends BaseEntity
         return paperId;
     }
 
-    public void setAnswers(String answers)
+    public void setAnswer(String answers)
     {
-        this.answers = answers;
+        this.answer = answer;
     }
 
-    public String getAnswers()
+    public String getAnswer()
     {
-        return answers;
+        return answer;
     }
 
     public void setAnswer1(String answer1)
@@ -350,6 +328,70 @@ public class LearnWrongBook extends BaseEntity
         return collect;
     }
 
+    public String getKnownledgeName() {
+        return knownledgeName;
+    }
+
+    public void setKnownledgeName(String knownledgeName) {
+        this.knownledgeName = knownledgeName;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getKnowledge() {
+        return knowledge;
+    }
+
+    public void setKnowledge(String knowledge) {
+        this.knowledge = knowledge;
+    }
+
+    public String getParse() {
+        return parse;
+    }
+
+    public void setParse(String parse) {
+        this.parse = parse;
+    }
+
+    public Integer getTypeId() {
+        return typeId;
+    }
+
+    public void setTypeId(Integer typeId) {
+        this.typeId = typeId;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public List<String> getOptions() {
+        return options;
+    }
+
+    public void setOptions(List<String> options) {
+        this.options = options;
+    }
+
+    public List<String> getAnswers() {
+        return answers;
+    }
+
+    public void setAnswers(List<String> answers) {
+        this.answers = answers;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@@ -361,7 +403,7 @@ public class LearnWrongBook extends BaseEntity
             .append("knownledgeId", getKnownledgeId())
             .append("subjectId", getSubjectId())
             .append("paperId", getPaperId())
-            .append("answers", getAnswers())
+            .append("answer", getAnswer())
             .append("answer1", getAnswer1())
             .append("answer2", getAnswer2())
             .append("scoreTotal", getScoreTotal())

+ 1 - 0
ie-system/src/main/java/com/ruoyi/learn/mapper/LearnQuestionsMapper.java

@@ -20,6 +20,7 @@ public interface LearnQuestionsMapper
      * @return 试题
      */
     public LearnQuestions selectLearnQuestionsById(Long id);
+    public List<LearnQuestions> selectLearnQuestionsByIds(Long[] ids);
 
     /**
      * 查询试题列表

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

@@ -1,7 +1,9 @@
 package com.ruoyi.learn.service.impl;
 
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
@@ -9,6 +11,11 @@ import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.dz.domain.DzSubject;
 import com.ruoyi.dz.mapper.DzSubjectMapper;
+import com.ruoyi.enums.QuestionType;
+import com.ruoyi.learn.domain.LearnQuestions;
+import com.ruoyi.learn.mapper.LearnKnowledgeTreeMapper;
+import com.ruoyi.learn.mapper.LearnQuestionsMapper;
+import io.swagger.annotations.ApiModelProperty;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.learn.mapper.LearnWrongBookMapper;
@@ -28,6 +35,10 @@ public class LearnWrongBookServiceImpl implements ILearnWrongBookService
     private LearnWrongBookMapper learnWrongBookMapper;
     @Autowired
     private DzSubjectMapper subjectMapper;
+    @Autowired
+    private LearnKnowledgeTreeMapper knowledgeTreeMapper;
+    @Autowired
+    private LearnQuestionsMapper questionsMapper;
 
     /**
      * 查询学生错题本
@@ -102,7 +113,7 @@ public class LearnWrongBookServiceImpl implements ILearnWrongBookService
     }
 
     public List<DzSubject> findSubject() {
-        return subjectMapper.selectDzSubjectList(new DzSubject());
+        return subjectMapper.selectWrongSubjectList(SecurityUtils.getUserId());
     }
 
     public List<LearnWrongBook> findWrongQuestions(Long subjectId) {
@@ -110,11 +121,18 @@ public class LearnWrongBookServiceImpl implements ILearnWrongBookService
         cond.put("subjectId", subjectId);
         cond.put("studentId", SecurityUtils.getUserId());
         List<LearnWrongBook> wrongBookList = learnWrongBookMapper.findWrongQuestions(cond);
-        wrongBookList.stream().forEach(t -> {
-            setAnswerAttachemnts(t, t.getAnswers());
-//            t.setTypeId(cacheService.getQuestionType(t.getQtpye()));
-            t.setTypeId(null);
-        });
+        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));
+            wrongBookList.stream().forEach(t -> {
+                LearnQuestions q = qMap.get(t.getQuestionId());
+                t.setTitle(q.getTitle());
+                t.setParse(q.getParse());
+                t.setType(q.getQtpye());
+                t.setTypeId(QuestionType.of(q.getQtpye()).getVal());
+                t.setAnswers(StringUtils.isNotBlank(t.getAnswer()) ? Arrays.asList(t.getAnswer().split(",")) : Lists.newArrayList());
+                t.setOptions(StringUtils.getOptions(q.getOptionA(), q.getOptionB(), q.getOptionC(), q.getOptionD(), q.getOptionE(), q.getOptionF(), q.getOptionG()));
+            });
+        }
         return wrongBookList;
     }
 
@@ -128,22 +146,4 @@ public class LearnWrongBookServiceImpl implements ILearnWrongBookService
         b.setQuestionId(questionId);
         return learnWrongBookMapper.deleteByQuestion(b);
     }
-
-    private void setAnswerAttachemnts(LearnWrongBook dto, String answer) {
-        if (StringUtils.isNotBlank(answer)) {
-            String[] answerArray = StringUtils.splitByWholeSeparatorPreserveAllTokens(answer, "$@");
-            if (answerArray.length > 0) {
-                dto.setAnswer(answerArray[0]);
-                if (answerArray.length > 1) {
-                    List<String> attacheList = Lists.newArrayList();
-                    for (int i = 1; i < answerArray.length; i++) {
-                        if (StringUtils.isNotBlank(answerArray[i]) && !"null".equals(answerArray[i])) {
-                            attacheList.add(answerArray[i]);
-                        }
-                    }
-                    dto.setAttachments(attacheList);
-                }
-            }
-        }
-    }
 }

+ 5 - 0
ie-system/src/main/resources/mapper/dz/DzSubjectMapper.xml

@@ -17,6 +17,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select subject_id, subject_name, pinyin, sort, locations, exam_types from dz_subject
     </sql>
 
+    <select id="selectWrongSubjectList" parameterType="Long" resultMap="DzSubjectResult">
+        SELECT s.subject_id, s.subject_name FROM `learn_wrong_book` wb JOIN dz_subject s ON wb.`subject_id` = s.`subject_id`
+        WHERE wb.`student_id` = #{studentId}
+    </select>
+
     <select id="selectDzSubjectList" parameterType="DzSubject" resultMap="DzSubjectResult">
         <include refid="selectDzSubjectVo"/>
         <where>

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

@@ -110,6 +110,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where id = #{id}
     </select>
 
+    <select id="selectLearnQuestionsByIds" resultMap="LearnQuestionsResult">
+        <include refid="selectLearnQuestionsVo"/>
+        where id in <foreach item="id" collection="array" open="(" separator="," close=")">#{id}</foreach>
+    </select>
+
     <insert id="insertLearnQuestions" parameterType="LearnQuestions" useGeneratedKeys="true" keyProperty="id">
         insert into learn_questions
         <trim prefix="(" suffix=")" suffixOverrides=",">

+ 9 - 10
ie-system/src/main/resources/mapper/learn/LearnWrongBookMapper.xml

@@ -13,7 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="knownledgeId"    column="knownledge_id"    />
         <result property="subjectId"    column="subject_id"    />
         <result property="paperId"    column="paper_id"    />
-        <result property="answers"    column="answers"    />
+        <result property="answer"    column="answer"    />
         <result property="answer1"    column="answer1"    />
         <result property="answer2"    column="answer2"    />
         <result property="scoreTotal"    column="score_total"    />
@@ -30,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectLearnWrongBookVo">
-        select wrong_id, student_id, question_id, source, state, knownledge_id, subject_id, paper_id, answers, answer1, answer2, score_total, score, score_level, score_rate, wrong_count, right_count, total_count, created_time, updated_time, collect from learn_wrong_book
+        select wrong_id, student_id, question_id, source, state, knownledge_id, subject_id, paper_id, answer, answer1, answer2, score_total, score, score_level, score_rate, wrong_count, right_count, total_count, created_time, updated_time, collect from learn_wrong_book
     </sql>
 
     <select id="selectLearnWrongBookList" parameterType="LearnWrongBook" resultMap="LearnWrongBookResult">
@@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="knownledgeId != null "> and knownledge_id = #{knownledgeId}</if>
             <if test="subjectId != null "> and subject_id = #{subjectId}</if>
             <if test="paperId != null "> and paper_id = #{paperId}</if>
-            <if test="answers != null  and answers != ''"> and answers = #{answers}</if>
+            <if test="answer != null  and answer != ''"> and answer = #{answer}</if>
             <if test="answer1 != null  and answer1 != ''"> and answer1 = #{answer1}</if>
             <if test="answer2 != null  and answer2 != ''"> and answer2 = #{answer2}</if>
             <if test="scoreTotal != null "> and score_total = #{scoreTotal}</if>
@@ -74,7 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="knownledgeId != null">knownledge_id,</if>
             <if test="subjectId != null">subject_id,</if>
             <if test="paperId != null">paper_id,</if>
-            <if test="answers != null">answers,</if>
+            <if test="answer != null">answer,</if>
             <if test="answer1 != null">answer1,</if>
             <if test="answer2 != null">answer2,</if>
             <if test="scoreTotal != null">score_total,</if>
@@ -96,7 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="knownledgeId != null">#{knownledgeId},</if>
             <if test="subjectId != null">#{subjectId},</if>
             <if test="paperId != null">#{paperId},</if>
-            <if test="answers != null">#{answers},</if>
+            <if test="answer != null">#{answer},</if>
             <if test="answer1 != null">#{answer1},</if>
             <if test="answer2 != null">#{answer2},</if>
             <if test="scoreTotal != null">#{scoreTotal},</if>
@@ -122,7 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="knownledgeId != null">knownledge_id = #{knownledgeId},</if>
             <if test="subjectId != null">subject_id = #{subjectId},</if>
             <if test="paperId != null">paper_id = #{paperId},</if>
-            <if test="answers != null">answers = #{answers},</if>
+            <if test="answer != null">answer = #{answer},</if>
             <if test="answer1 != null">answer1 = #{answer1},</if>
             <if test="answer2 != null">answer2 = #{answer2},</if>
             <if test="scoreTotal != null">score_total = #{scoreTotal},</if>
@@ -163,14 +163,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="findWrongQuestions" parameterType="map" resultMap="LearnWrongBookResult">
-        SELECT wb.`wrong_id`, wb.`question_id`, q.`title`, q.parse, wb.`knownledge_id`, k.`name` knownledge_name, wb.`wrong_count`, q.qtpye
-        ,q.option_a,q.option_b,q.option_c,q.option_d,q.option_e,q.option_f,q.option_g,q.answer1,q.answer2,q.title0,wb.answers, qc.question_id>0 collect
+        SELECT wb.`wrong_id`, wb.`question_id`, wb.`knownledge_id`, k.`name` knowledge, wb.`wrong_count`, wb.`answer`, qc.question_id>0 collect
         FROM `learn_wrong_book` wb
         JOIN `learn_questions` q ON wb.`question_id` = q.`id`
         LEFT JOIN `learn_knowledge_tree` k ON wb.`knownledge_id` = k.`id`
-        LEFT JOIN mxjb_question_collection qc on qc.question_id = q.id and qc.user_id = 11
+        LEFT JOIN mxjb_question_collection qc on qc.question_id = q.id and qc.user_id = wb.`student_id`
         <where>
-            wb.`student_id` = #{creatorId} AND q.`qtpye` IN ('判断题', '单选题', '选择题','单项选择','单项选择题','多选题')
+            wb.`student_id` = #{studentId} AND q.`qtpye` IN ('判断题', '单选题', '选择题','单项选择','单项选择题','多选题')
             <if test="subjectId != null "> and wb.`subject_id` = #{subjectId}</if>
         </where>