he2802 2 yıl önce
ebeveyn
işleme
76bf6f213f

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/ExamSimulateQueryBo.java

@@ -69,6 +69,8 @@ public class ExamSimulateQueryBo extends BaseEntity {
 	private Integer qnum;
 	@ApiModelProperty("知识点题目ID数组")
 	private List<Long> knowledQuestionIds;
+	@ApiModelProperty("过滤错题ID数组")
+	private List<Long> wrongQuestionIds;
 
 	@ApiModelProperty("抽题顺序 1顺序 0随机")
 	private Integer randomNum;

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/mapper/ExamSimulateMapper.java

@@ -21,4 +21,6 @@ public interface ExamSimulateMapper extends BaseMapper<ExamSimulate> {
     List<Long> getQuestionList(ExamSimulateQueryBo bo);
 
     List<QuestionVo> queryBatchList(ExamSimulateQueryBo bo);
+
+    List<Long> getWrongQuestionList(ExamSimulateQueryBo bo);
 }

+ 40 - 6
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/ExamSimulateServiceImpl.java

@@ -134,18 +134,23 @@ public class ExamSimulateServiceImpl extends ServiceImpl<ExamSimulateMapper, Exa
 
         ExamSimulateQueryBo qk4Bo = new ExamSimulateQueryBo(); //判断题选知识点
         qk4Bo.setExamId(exam.getExamId());
-        qk4Bo.setKnowledIds(simulateConfig.getCaseQuestion().getKnowledIds());
-        qk4Bo.setKnum(simulateConfig.getCaseQuestion().getKnum());
+        qk4Bo.setKnowledIds(simulateConfig.getTrueFalseQuestion().getKnowledIds());
+        qk4Bo.setKnum(simulateConfig.getTrueFalseQuestion().getKnum());
         qk4Bo.setType(3);
         qk4Bo.setOrderGoodsId(bo.getOrderGoodsId());
         qk4Bo.setFromType(bo.getFrom());
         List<Long> qk4 = baseMapper.getKnowledQuestionList(qk4Bo);
 
+        List<Long> w1 = getWrongQuestion(bo.getOrderGoodsId(),bo.getExamId(),bo.getFrom(),simulateConfig.getType(),(simulateConfig.getSingleChoice().getQnum()-qk1.size()),qk1,1);//单选错题
+        List<Long> w2 = getWrongQuestion(bo.getOrderGoodsId(),bo.getExamId(),bo.getFrom(),simulateConfig.getType(),(simulateConfig.getMultipleChoice().getQnum()-qk2.size()),qk2,2);//多选错题
+        List<Long> w3 = getWrongQuestion(bo.getOrderGoodsId(),bo.getExamId(),bo.getFrom(),simulateConfig.getType(),(simulateConfig.getCaseQuestion().getQnum()-qk3.size()),qk3,4);//案例错题
+        List<Long> w4 = getWrongQuestion(bo.getOrderGoodsId(),bo.getExamId(),bo.getFrom(),simulateConfig.getType(),(simulateConfig.getTrueFalseQuestion().getQnum()-qk4.size()),qk4,3);//判断错题
 
         ExamSimulateQueryBo q1Bo = new ExamSimulateQueryBo();  //单选
         q1Bo.setExamId(exam.getExamId());
         q1Bo.setKnowledQuestionIds(qk1);
-        q1Bo.setQnum(simulateConfig.getSingleChoice().getQnum()-qk1.size());
+        q1Bo.setWrongQuestionIds(w1);
+        q1Bo.setQnum(simulateConfig.getSingleChoice().getQnum()-qk1.size()-w1.size());
         q1Bo.setRandomNum(simulateConfig.getType());
         q1Bo.setType(1);
         q1Bo.setOrderGoodsId(bo.getOrderGoodsId());
@@ -155,7 +160,8 @@ public class ExamSimulateServiceImpl extends ServiceImpl<ExamSimulateMapper, Exa
         ExamSimulateQueryBo q2Bo = new ExamSimulateQueryBo();  //多选
         q2Bo.setExamId(exam.getExamId());
         q2Bo.setKnowledQuestionIds(qk2);
-        q2Bo.setQnum(simulateConfig.getMultipleChoice().getQnum()-qk2.size());
+        q2Bo.setWrongQuestionIds(w2);
+        q2Bo.setQnum(simulateConfig.getMultipleChoice().getQnum()-qk2.size()- w2.size());
         q2Bo.setRandomNum(simulateConfig.getType());
         q2Bo.setType(2);
         q2Bo.setOrderGoodsId(bo.getOrderGoodsId());
@@ -165,7 +171,8 @@ public class ExamSimulateServiceImpl extends ServiceImpl<ExamSimulateMapper, Exa
         ExamSimulateQueryBo q3Bo = new ExamSimulateQueryBo();  //案例选
         q3Bo.setExamId(exam.getExamId());
         q3Bo.setKnowledQuestionIds(qk3);
-        q3Bo.setQnum(simulateConfig.getCaseQuestion().getQnum()-qk3.size());
+        q3Bo.setWrongQuestionIds(w3);
+        q3Bo.setQnum(simulateConfig.getCaseQuestion().getQnum()-qk3.size()- w3.size());
         q3Bo.setType(4);
         q3Bo.setOrderGoodsId(bo.getOrderGoodsId());
         q3Bo.setFromType(bo.getFrom());
@@ -174,15 +181,23 @@ public class ExamSimulateServiceImpl extends ServiceImpl<ExamSimulateMapper, Exa
         ExamSimulateQueryBo q4Bo = new ExamSimulateQueryBo();  //判断题
         q4Bo.setExamId(exam.getExamId());
         q4Bo.setKnowledQuestionIds(qk4);
-        q4Bo.setQnum(simulateConfig.getCaseQuestion().getQnum()-qk4.size());
+        q4Bo.setWrongQuestionIds(w4);
+        q4Bo.setQnum(simulateConfig.getTrueFalseQuestion().getQnum()-qk4.size()- w4.size());
         q4Bo.setType(3);
         q4Bo.setOrderGoodsId(bo.getOrderGoodsId());
         q4Bo.setFromType(bo.getFrom());
         List<Long> q4 = baseMapper.getQuestionList(q4Bo);
 
+        qk1.addAll(w1);
         qk1.addAll(q1);
+
+        qk2.addAll(w2);
         qk2.addAll(q2);
+
+        qk3.addAll(w3);
         qk3.addAll(q3);
+
+        qk4.addAll(w4);
         qk4.addAll(q4);
         List<Long> allQ = new ArrayList<>();
         if(simulateConfig.getSingleChoice().getRandomNum()==1){ //题型顺序
@@ -297,4 +312,23 @@ public class ExamSimulateServiceImpl extends ServiceImpl<ExamSimulateMapper, Exa
     public List<QuestionVo> queryBatchList(ExamSimulateQueryBo bo) {
         return this.baseMapper.queryBatchList(bo);
     }
+
+
+    private List<Long> getWrongQuestion(Long orderGoodsId,Long examId,Integer fromType,Integer orderType,Integer maxQnum,List<Long> knowledQuestionIds,Integer qType){
+        if(orderType==2){
+            int num = (int)(maxQnum*Math.random()) + 1;
+            ExamSimulateQueryBo queryBo = new ExamSimulateQueryBo();
+            queryBo.setOrderGoodsId(orderGoodsId);
+            queryBo.setExamId(examId);
+            queryBo.setFromType(fromType);
+            queryBo.setKnowledQuestionIds(knowledQuestionIds);
+            queryBo.setType(qType);
+            queryBo.setQnum(num);
+            queryBo.setRandomNum(2);
+            List<Long> questionlist = baseMapper.getWrongQuestionList(queryBo);
+            return questionlist;
+        }else {
+            return new ArrayList<>();
+        }
+    }
 }

+ 37 - 60
zhongzheng-system/src/main/resources/mapper/modules/bank/ExamSimulateMapper.xml

@@ -43,39 +43,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 LEFT JOIN question q ON eq.question_id = q.question_id
         WHERE
             eq.exam_id = #{examId}
-        <if test="fromType != null and fromType == 1">
-            AND NOT FIND_IN_SET(
-            q.question_id,(
-            SELECT
-            IFNULL(GROUP_CONCAT( right_question_ids ),'')
-            FROM
-            user_exam_record uer
-            WHERE
-            order_goods_id = #{orderGoodsId} and exam_id = #{examId} and do_mode = 3
-            ))
-        </if>
-        <if test="fromType != null and fromType == 2">
-            AND NOT FIND_IN_SET(
-            q.question_id,(
-            SELECT
-            IFNULL(GROUP_CONCAT( right_question_ids ),'')
-            FROM
-            user_bank_record uer
-            WHERE
-            order_goods_id = #{orderGoodsId} and exam_id = #{examId} and do_mode = 3
-            ))
-        </if>
-        <if test="fromType != null and fromType == 3">
-            AND NOT FIND_IN_SET(
-            q.question_id,(
-            SELECT
-            IFNULL(GROUP_CONCAT( right_question_ids ),'')
-            FROM
-            user_mock_record uer
-            WHERE
-            order_goods_id = #{orderGoodsId} and exam_id = #{examId} and do_mode = 3
-            ))
-        </if>
         <if test="type != null and type != ''">
           AND q.`type` = #{type}
         </if>
@@ -103,38 +70,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         LEFT JOIN question q ON eq.question_id = q.question_id
         WHERE
         eq.exam_id = #{examId}
+        <if test="type != null and type != ''">
+            AND q.`type` = #{type}
+        </if>
+        <if test="knowledQuestionIds != null and knowledQuestionIds.size()!=0 ">
+            AND q.question_id not in
+            <foreach collection="knowledQuestionIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="wrongQuestionIds != null and wrongQuestionIds.size()!=0 ">
+            AND q.question_id not in
+            <foreach collection="wrongQuestionIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="randomNum == 1">
+            ORDER BY eq.sort,eq.id DESC
+        </if>
+        <if test=" randomNum == 2">
+            ORDER BY RAND()
+        </if>
+        LIMIT  #{qnum}
+    </select>
+
+    <select id="getWrongQuestionList" parameterType="com.zhongzheng.modules.bank.bo.ExamSimulateQueryBo" resultType="Long">
+        SELECT
+        q.question_id
+        FROM
+        user_exam_wrong_record uwr
+        LEFT JOIN question q ON uwr.question_id = q.question_id
+        WHERE
+        uwr.exam_id = #{examId}
+        AND uwr.order_goods_id = #{orderGoodsId}
+        AND uwr.do_mode = 3
         <if test="fromType != null and fromType == 1">
-            AND NOT FIND_IN_SET(
-            q.question_id,(
-            SELECT
-            IFNULL(GROUP_CONCAT( right_question_ids ),'')
-            FROM
-            user_exam_record uer
-            WHERE
-            order_goods_id = #{orderGoodsId} and exam_id = #{examId} and do_mode = 3
-            ))
+            AND uwr.course_type = 2
         </if>
         <if test="fromType != null and fromType == 2">
-            AND NOT FIND_IN_SET(
-            q.question_id,(
-            SELECT
-            IFNULL(GROUP_CONCAT( right_question_ids ),'')
-            FROM
-            user_bank_record uer
-            WHERE
-            order_goods_id = #{orderGoodsId} and exam_id = #{examId} and do_mode = 3
-            ))
+            AND uwr.course_type = 1
         </if>
         <if test="fromType != null and fromType == 3">
-            AND NOT FIND_IN_SET(
-            q.question_id,(
-            SELECT
-            IFNULL(GROUP_CONCAT( right_question_ids ),'')
-            FROM
-            user_mock_record uer
-            WHERE
-            order_goods_id = #{orderGoodsId} and exam_id = #{examId} and do_mode = 3
-            ))
+            AND uwr.course_type = 3
         </if>
         <if test="type != null and type != ''">
             AND q.`type` = #{type}