Parcourir la source

组卷增加filterType按类型过滤已经用过的题

mingfu il y a 2 semaines
Parent
commit
d2207d35c7

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

@@ -319,7 +319,7 @@ public class LearnTeacherService {
                         info.setTime(directedKnowledge.getTime() * 60);
                         info.setTypes(paperDef.getTypes().stream().map(t -> new AnswerSheet.PaperCondType(t.getType().getTitle(), t.getCount(), t.getScore())).collect(Collectors.toList()));
                         paper.setPaperInfo(JSONObject.toJSONString(info));
-                        Pair<LearnPaper, List<LearnPaperQuestion>> paperResult = paperService.buildPaper2(null, paper, paperDef);
+                        Pair<LearnPaper, List<LearnPaperQuestion>> paperResult = paperService.buildPaper2(null, null, paper, paperDef);
                         paperService.savePaper(paperResult.getKey(), paperResult.getValue());
                     } else if(!"技能展示/实践操作".equals(directedKnowledge.getModules())) {
                         throw new ValidationException("未配置定向题型" + directedKnowledge.getId());

+ 46 - 72
ie-admin/src/main/java/com/ruoyi/web/service/PaperService.java

@@ -61,11 +61,11 @@ public class PaperService {
         this.learnKnowledgeTreeMapper = learnKnowledgeTreeMapper;
         this.learnCultureKnowledgeMapper = learnCultureKnowledgeMapper;
         this.dzSubjectMapper = dzSubjectMapper;
-        // buildAllPapers(2026, 901);
+        // buildAllPapers(2026, 909);
         // buildSimulatedPaperForUniversity(20950L, 11L, 78L, 2);
         // buildSimulatedPaperForUniversity(20962L, 11L, 156L, 2);
         // test2();
-        // testCulture(2026, 901);
+        // testCulture(2026, 910);
         // corrQuestions();
     }
 
@@ -174,14 +174,15 @@ public class PaperService {
 
     public void buildAllPapers(Integer year, Integer seq) {
         LearnDirectedKnowledge dkCond = new LearnDirectedKnowledge();
-        dkCond.setMatchYear(year);
+        // dkCond.setMatchYear(year);
+        dkCond.setYear(year);
         Map<Long, List<LearnDirectedKnowledge>> universityDirectedMap = learnDirectedKnowledgeMapper.selectLearnDirectedKnowledgeList(dkCond).stream().collect(Collectors.groupingBy(LearnDirectedKnowledge::getUniversityId));
 
         Map uCond = new HashMap();
         uCond.put("ids", universityDirectedMap.keySet());
         Map<Long, BBusiWishUniversities> universityMap = bBusiWishUniversitiesMapper.selectBBusiWishUniversitiesListSimpleByIds(uCond).stream().collect(Collectors.toMap(BBusiWishUniversities::getId, Function.identity()));
         List<Long> dkIdList = Lists.newArrayList();
-        Set<Long> validIdSet = Sets.newHashSet(426L,427L,428L,429L,430L,431L,432L,433L,434L,435L,436L,437L,438L,439L,440L,441L,442L,443L,444L,445L,446L,447L,448L,449L,450L,451L,452L,453L,454L,455L,456L,457L,458L,459L,460L,461L,462L,463L,464L,465L,466L,467L,468L,469L,470L,471L,472L,473L,474L,475L,476L,477L,478L,479L,480L,481L,482L,483L,484L,485L,486L,487L,488L,489L,490L,491L,492L,493L,494L,495L,496L,497L,498L,499L,500L,501L,502L,503L,504L,505L,506L,507L,508L,509L,510L,511L,512L,513L,514L,515L,516L,517L,518L,519L,520L,521L,522L,523L,524L,525L,526L,527L,528L,529L,530L,531L,532L,533L,534L,535L,536L,537L,538L,539L,540L,541L,542L,543L,544L,545L,546L,547L,548L,549L,550L,551L,552L,553L,554L,555L,556L,557L,558L,559L,560L,561L,562L,563L,564L,565L,566L,567L,568L,569L,570L,571L,572L,573L,574L,575L,576L,577L,578L,579L,580L,581L,582L,583L,584L,585L,586L,587L,588L,589L,590L,591L,592L);
+        Set<Long> validIdSet = Sets.newHashSet(593L); // 693L
         for(Long universityId : universityDirectedMap.keySet()) {
             BBusiWishUniversities universities = universityMap.get(universityId);
             if(null == universities) {
@@ -192,7 +193,7 @@ public class PaperService {
                     continue;
                 }
                 try {
-                    buildSimulatedPaperForKnowledge(11L, seq, universities, dk);
+                    buildSimulatedPaperForKnowledge("DK" + universityId,11L, seq, universities, dk);
                 } catch(Exception e) {
                     dkIdList.add(dk.getId());
                     log.error(e.getMessage());
@@ -206,23 +207,26 @@ public class PaperService {
 
     public void testCulture(Integer year, Integer seq) {
         LearnCultureKnowledge ckCond = new LearnCultureKnowledge();
-        ckCond.setMatchYear(year);
+        ckCond.setYear(year);
         // ckCond.setUniversityId(20154L);
         List<LearnCultureKnowledge> cultureKnowledgeList = learnCultureKnowledgeMapper.selectLearnCultureKnowledgeList(ckCond).stream().filter(t -> t.getId() >= 215).collect(Collectors.toList());
 
         List<Long> errorIdList = Lists.newArrayList();
         Map uCond = new HashMap();
-        Set<Long> validIdSet = Sets.newHashSet(218L,224L,239L,269L);
+        Set<Long> validIdSet = Sets.newHashSet();
         uCond.put("ids", cultureKnowledgeList.stream().map(LearnCultureKnowledge::getUniversityId).collect(Collectors.toSet()));
         Map<Long, BBusiWishUniversities> universityMap = bBusiWishUniversitiesMapper.selectBBusiWishUniversitiesListSimpleByIds(uCond).stream().collect(Collectors.toMap(BBusiWishUniversities::getId, Function.identity()));
         Map<Long, String> subjectMap = dzSubjectMapper.selectDzSubjectList(new DzSubject()).stream().collect(Collectors.toMap(DzSubject::getSubjectId, DzSubject::getSubjectName));
+        List<LearnCultureKnowledge> errList = Lists.newArrayList();
         for(LearnCultureKnowledge ck : cultureKnowledgeList) {
             if(!validIdSet.isEmpty() && !validIdSet.contains(ck.getId())) {
                 continue;
             }
             TestPaperVO.PaperDef2 paperDef = new TestPaperVO.PaperDef2(ck.getConditions());
             if(ck.getScore() != (int) Math.round(paperDef.getScore())) {
-                throw new RuntimeException("分值不对称: " + ck.getId());
+                log.error("分值不对称: " + ck.getId());
+                errList.add(ck);
+                continue;
             }
             paperDef.setFillExclude(false);
 
@@ -249,7 +253,7 @@ public class PaperService {
             info.setTypes(paperDef.getTypes().stream().map(t -> new AnswerSheet.PaperCondType(t.getType().getTitle(), t.getCount(), t.getScore())).collect(Collectors.toList()));
             paper.setPaperInfo(JSONObject.toJSONString(info));
             try {
-                Pair<LearnPaper, List<LearnPaperQuestion>> paperResult = buildPaper2(null, paper, paperDef);
+                Pair<LearnPaper, List<LearnPaperQuestion>> paperResult = buildPaper2("CK" + ck.getUniversityId(),null, paper, paperDef);
                 // savePaper(paperResult.getKey(), paperResult.getValue());
                 continue;
             } catch(Exception e) {
@@ -261,48 +265,6 @@ public class PaperService {
             System.out.println(StringUtils.join(errorIdList, ","));
         }
     }
-    public void testCultureOld() {
-        LearnPaper paper = new LearnPaper();
-
-//        TestPaperVO.PaperDef2 paperDef = new TestPaperVO.PaperDef2("", "[{\"score\":40,\"knowledges\":[2001,2002,2003,2004,2005,2006,2007,2010,2013],\"types\":{\"judgment\":\"0\",\"single\":\"10/4\",\"multiple\":\"0\",\"subjective\":\"0\",\"fill\":\"0\",\"essay\":\"0\",\"short\":\"0\"}},{\"score\":20,\"knowledges\":[2012],\"types\":{\"judgment\":\"0\",\"single\":\"5/4\",\"multiple\":\"0\",\"subjective\":\"0\",\"fill\":\"0\",\"essay\":\"0\",\"short\":\"0\"}},{\"score\":40,\"knowledges\":[2011],\"types\":{\"judgment\":\"0\",\"single\":\"8/5\",\"multiple\":\"0\",\"subjective\":\"0\",\"fill\":\"0\",\"essay\":\"0\",\"short\":\"0\"}}]");
-//        paperDef.setFillExclude(false);
-//        paper.setSubjectId(1010L);
-//        paper.setRelateId(1010L); // 定向ID
-//        paper.setPaperName("语文");
-
-//        TestPaperVO.PaperDef2 paperDef = new TestPaperVO.PaperDef2("", "[{\"score\":80,\"knowledges\":[1005,1006,1007,1008,1009,1010,1011,1013,1015,2044,2043],\"types\":{\"judgment\":\"10/2\",\"single\":\"15/4\",\"multiple\":\"0\",\"subjective\":\"0\",\"fill\":\"0\",\"essay\":\"0\",\"short\":\"0\"}},{\"score\":10,\"knowledges\":[2043],\"types\":{\"judgment\":\"0\",\"single\":\"1/10\",\"multiple\":\"0\",\"subjective\":\"0\",\"fill\":\"0\",\"essay\":\"0\",\"short\":\"0\"}},{\"score\":10,\"knowledges\":[2043],\"types\":{\"judgment\":\"0\",\"single\":\"1/10\",\"multiple\":\"0\",\"subjective\":\"0\",\"fill\":\"0\",\"essay\":\"0\",\"short\":\"0\"}}]");
-//        paperDef.setFillExclude(false);
-//        paper.setSubjectId(1011L);
-//        paper.setRelateId(1011L);
-//        paper.setPaperName("数学");
-
-        TestPaperVO.PaperDef2 paperDef = new TestPaperVO.PaperDef2("", "[{\"score\":60,\"knowledges\":[1022,1193,1023],\"types\":{\"judgment\":\"0\",\"single\":\"15/4\",\"multiple\":\"0\",\"subjective\":\"0\",\"fill\":\"0\",\"essay\":\"0\",\"short\":\"0\"}},{\"score\":20,\"knowledges\":[1022,1193,1023],\"types\":{\"judgment\":\"0\",\"single\":\"5/4\",\"multiple\":\"0\",\"subjective\":\"0\",\"fill\":\"0\",\"essay\":\"0\",\"short\":\"0\"}},{\"score\":20,\"knowledges\":[1022,1193,1023],\"types\":{\"judgment\":\"0\",\"single\":\"10/2\",\"multiple\":\"0\",\"subjective\":\"0\",\"fill\":\"0\",\"essay\":\"0\",\"short\":\"0\"}}]");
-        paperDef.setFillExclude(false);
-        paper.setSubjectId(1012L);
-        paper.setRelateId(1012L);
-        paper.setPaperName("英语");
-
-        paper.setPaperType(PaperType.Simulated.name());
-        paper.setYear(2025);
-        paper.setPaperSource(1);
-        paper.setDirectKey("");
-        paper.setStatus(PaperStatus.Valid.getVal());
-        paper.setNumber(paperDef.getTotal());
-        paper.setFenshu(paperDef.getScore().intValue());
-        AnswerSheet.PaperCond info = new AnswerSheet.PaperCond();
-        info.setScore(paper.getFenshu());
-        info.setTime(60 * 60);
-        info.setTypes(paperDef.getTypes().stream().map(t -> new AnswerSheet.PaperCondType(t.getType().getTitle(), t.getCount(), t.getScore())).collect(Collectors.toList()));
-        paper.setPaperInfo(JSONObject.toJSONString(info));
-        try {
-            Pair<LearnPaper, List<LearnPaperQuestion>> paperResult = buildPaper2(null, paper, paperDef);
-            savePaper(paperResult.getKey(), paperResult.getValue());
-            return;
-        } catch(Exception e) {
-            log.error(e.getMessage());
-        }
-
-    }
 
     public void test2() {
         TestPaperVO.PaperDef paperDef = new TestPaperVO.PaperDef();
@@ -425,14 +387,14 @@ public class PaperService {
         return paperQuestionList;
     }
 
-    public int buildSimulatedPaperForUniversity(Long universityId, Long subjectId, Long directedId, Integer seq) {
+    public int buildSimulatedPaperForUniversity(String filterType, Long universityId, Long subjectId, Long directedId, Integer seq) {
         LearnDirectedKnowledge dkCond = new LearnDirectedKnowledge();
         dkCond.setUniversityId(universityId);
         List<LearnDirectedKnowledge> directedKnowledgeList = learnDirectedKnowledgeMapper.selectLearnDirectedKnowledgeList(dkCond);
         BBusiWishUniversities universities = wishUniversitiesService.selectBBusiWishUniversitiesById(universityId);
         for(LearnDirectedKnowledge dk : directedKnowledgeList) {
             if(null == directedId || directedId.equals(dk.getId())) {
-                buildSimulatedPaperForKnowledge(subjectId, seq, universities, dk);
+                buildSimulatedPaperForKnowledge(filterType, subjectId, seq, universities, dk);
             }
         }
         return 0;
@@ -442,7 +404,7 @@ public class PaperService {
      * 根据院校专业要求生成模拟试卷
      * @return
      */
-    public int buildSimulatedPaperForKnowledge(Long subjectId, Integer seq, BBusiWishUniversities universities, LearnDirectedKnowledge dk) {
+    public int buildSimulatedPaperForKnowledge(String filterType, Long subjectId, Integer seq, BBusiWishUniversities universities, LearnDirectedKnowledge dk) {
         if(StringUtils.isBlank(dk.getConditions())) {
             return 0;
         }
@@ -470,14 +432,14 @@ public class PaperService {
         info.setTime(dk.getTime() * 60);
         info.setTypes(paperDef.getTypes().stream().map(t -> new AnswerSheet.PaperCondType(t.getType().getTitle(), t.getCount(), t.getScore())).collect(Collectors.toList()));
         paper.setPaperInfo(JSONObject.toJSONString(info));
-        Pair<LearnPaper, List<LearnPaperQuestion>> paperResult = buildPaper2(null, paper, paperDef);
-        // savePaper(paperResult.getKey(), paperResult.getValue());
+        Pair<LearnPaper, List<LearnPaperQuestion>> paperResult = buildPaper2(filterType, null, paper, paperDef);
+        savePaper(paperResult.getKey(), paperResult.getValue());
         return 0;
     }
 
-    public Pair<LearnPaper, List<LearnPaperQuestion>> buildPaper2(Long studentId, LearnPaper paper, TestPaperVO.PaperDef2 paperDef) {
+    public Pair<LearnPaper, List<LearnPaperQuestion>> buildPaper2(String filterType, Long studentId, LearnPaper paper, TestPaperVO.PaperDef2 paperDef) {
         paperDef.setFillExclude(null != studentId);
-        List<LearnPaperQuestion> pqList = getQuestions2(studentId, paperDef);
+        List<LearnPaperQuestion> pqList = getQuestions2(filterType, studentId, paperDef);
         return Pair.of(paper, pqList);
     }
 
@@ -520,12 +482,12 @@ public class PaperService {
      */
     public List<LearnPaperQuestion> getQuestionsByType(Long studentId, TestPaperVO.PaperDef paperDef) {
         // 统计知识点+类型的有效数量 TODO 总量可以缓存
-        Map<String, KnowTypeAssign> knowTypeAssignMap = buildKnowTypeAssignMap(studentId, paperDef);
+        Map<String, KnowTypeAssign> knowTypeAssignMap = buildKnowTypeAssignMap(null, studentId, paperDef);
         assignTypeFirstWithCount(paperDef, knowTypeAssignMap); // 知识优先,类型可变
         return getQuestions(studentId, paperDef, knowTypeAssignMap);
     }
 
-    public List<LearnPaperQuestion> getQuestions2(Long studentId, TestPaperVO.PaperDef2 paperDef) {
+    public List<LearnPaperQuestion> getQuestions2(String filterType, Long studentId, TestPaperVO.PaperDef2 paperDef) {
         List<LearnPaperQuestion> pqList = Lists.newArrayList();
         Set<String> existQuestionSet = Sets.newHashSet();
         for(TestPaperVO.KnowledgeTypeDef2 ktd : paperDef.getKnowTypes()) {
@@ -553,16 +515,16 @@ public class PaperService {
             newKnownList.addAll(tailKnownList);
             ktd.setKnowledges(newKnownList);
             String isSubType = null == ktd.getSubType() ? "0" : ktd.getSubType().toString();
-            Map<String, KnowTypeAssign> knowTypeAssignMap = buildKnowTypeAssignMap(studentId, isSubType, ktd.getTypes().get(0).getCount(), ktd.getTypes().stream().map(t -> t.getType().getTitle()).collect(Collectors.toList()), newKnownList, paperDef.getFillExclude(), 0);
+            Map<String, KnowTypeAssign> knowTypeAssignMap = buildKnowTypeAssignMap(filterType, studentId, isSubType, ktd.getTypes().get(0).getCount(), ktd.getTypes().stream().map(t -> t.getType().getTitle()).collect(Collectors.toList()), newKnownList, paperDef.getFillExclude(), 0);
             assignTypeFirst(paperDef.getFillExclude(), ktd, knowTypeAssignMap);
-            pqList.addAll(getQuestions2(studentId, ktd.getCount(), pqList.size(), newKnownList, isSubType, ktd.getTypes(), knowTypeAssignMap, existQuestionSet));
+            pqList.addAll(getQuestions2(filterType, studentId, ktd.getCount(), pqList.size(), newKnownList, isSubType, ktd.getTypes(), knowTypeAssignMap, existQuestionSet));
         }
         reSort(pqList);
         return pqList;
     }
 
     public List<LearnPaperQuestion> getQuestionsByRandom(Long studentId, Integer total, Collection<Long> knowledgeIds, List<String> types, Integer questionType) {
-        Map<String, KnowTypeAssign> knowTypeAssignMap = buildKnowTypeAssignMap(studentId, "2", null, types, knowledgeIds, true, questionType);
+        Map<String, KnowTypeAssign> knowTypeAssignMap = buildKnowTypeAssignMap(null, studentId, "2", null, types, knowledgeIds, true, questionType);
         List<KnowTypeAssign> knowTypeAssignList = Lists.newArrayList(knowTypeAssignMap.values());
         List<LearnPaperQuestion> pqList = Lists.newArrayList();
         Set<String> existQuestionSet = Sets.newHashSet();
@@ -651,7 +613,7 @@ public class PaperService {
             @Override
             public int compare(LearnPaperQuestion o1, LearnPaperQuestion o2) {
                 int iRet;
-                if(0 != (iRet = o1.getDiff().compareTo(o2.getDiff()))) {
+                if(0 != (iRet = o1.getDiff().compareTo(o2.getDiff())) || o1.getPaperId().equals(0L)) {
                     return iRet;
                 }
                 if(0 != (iRet = o1.getPaperId().compareTo(o2.getPaperId()))) {
@@ -680,7 +642,7 @@ public class PaperService {
     public List<LearnPaperQuestion> getQuestions(Long studentId, TestPaperVO.PaperDef paperDef) {
         // 题型分布定义, 知识点列表, 分值定义
         // 统计知识点+类型的有效数量 TODO 总量可以缓存
-        Map<String, KnowTypeAssign> knowTypeAssignMap = buildKnowTypeAssignMap(studentId, paperDef);
+        Map<String, KnowTypeAssign> knowTypeAssignMap = buildKnowTypeAssignMap(null, studentId, paperDef);
         assignKnowFirst(paperDef, knowTypeAssignMap); // 知识优先,类型可变
         return getQuestions(studentId, paperDef, knowTypeAssignMap);
     }
@@ -1001,7 +963,7 @@ public class PaperService {
         return pqList;
     }
 
-    public List<LearnPaperQuestion> getQuestions2(Long studentId, Integer total, Integer seqId, Collection<Long> knownIds, String isSubType, List<TestPaperVO.TypeDef2> types, Map<String, KnowTypeAssign> knowTypeAssignMap, Set<String> existQuestionSet) {
+    public List<LearnPaperQuestion> getQuestions2(String filterType, Long studentId, Integer total, Integer seqId, Collection<Long> knownIds, String isSubType, List<TestPaperVO.TypeDef2> types, Map<String, KnowTypeAssign> knowTypeAssignMap, Set<String> existQuestionSet) {
         // 知识点已经分配,准备题型分配
         LearnQuestions qCond = new LearnQuestions();
         Random random = ThreadLocalRandom.current();
@@ -1021,7 +983,11 @@ public class PaperService {
                     qCond.setSubCnt(typeDef.getCount());
                 }
                 if(ktc.exclAssign > 0){
-                    qCond.setId(studentId);
+                    if(null != studentId) {
+                        qCond.setId(studentId);
+                    } else {
+                        qCond.setArea(filterType);
+                    }
                     qCond.setNumber(ktc.exclAssign > 500 ? (long) random.nextInt(ktc.exclAssign.intValue() - 500) :  0L);
                     List<LearnQuestions> questions = questionsService.selectQuestionsForPaper(qCond);
                     ktc.exclAssign = addRandomList(knowId, typeDef.getType(), questions, random, total.longValue(), ktc.exclAssign, typeDef.getScore(), existQuestionSet, seqId, pqList);
@@ -1031,6 +997,7 @@ public class PaperService {
                 }
                 if(ktc.assign > 0L) {
                     qCond.setId(null);
+                    qCond.setArea(null);
                     qCond.setNumber(ktc.assign > 1000 ? (long) random.nextInt(ktc.assign.intValue() - 1000) :  0L);
                     List<LearnQuestions> questions = questionsService.selectQuestionsForPaper(qCond);
                     ktc.assign = addRandomList(knowId, typeDef.getType(), questions, random, total.longValue(), ktc.assign, typeDef.getScore(), existQuestionSet, seqId, pqList);
@@ -1056,8 +1023,8 @@ public class PaperService {
      * @param paperDef
      * @return
      */
-    private Map<String, KnowTypeAssign> buildKnowTypeAssignMap(Long studentId, TestPaperVO.PaperDef paperDef) {
-        return buildKnowTypeAssignMap(studentId, "0", null, paperDef.getTypes().stream().map(TestPaperVO.TypeDef::getType).collect(Collectors.toList()), paperDef.getKnowIds(), paperDef.getFillExclude(), 0);
+    private Map<String, KnowTypeAssign> buildKnowTypeAssignMap(String filterType, Long studentId, TestPaperVO.PaperDef paperDef) {
+        return buildKnowTypeAssignMap(filterType, studentId, "0", null, paperDef.getTypes().stream().map(TestPaperVO.TypeDef::getType).collect(Collectors.toList()), paperDef.getKnowIds(), paperDef.getFillExclude(), 0);
     }
 
     /**
@@ -1068,7 +1035,7 @@ public class PaperService {
      * @param fillExclude
      * @return
      */
-    private Map<String, KnowTypeAssign> buildKnowTypeAssignMap(Long studentId, String isSubType, Integer subCnt, List<String> types, Collection<Long> knownIds, Boolean fillExclude, Integer questionType) {
+    private Map<String, KnowTypeAssign> buildKnowTypeAssignMap(String filterType, Long studentId, String isSubType, Integer subCnt, List<String> types, Collection<Long> knownIds, Boolean fillExclude, Integer questionType) {
         Map<String, KnowTypeAssign> knowTypeAssignMap = Maps.newHashMap();
         Map cond = Maps.newHashMap();
         cond.put("typeId", questionType);
@@ -1079,9 +1046,16 @@ public class PaperService {
         if("1".equals(isSubType)) {
             cond.put("subCnt", subCnt);
         }
+        if(null == studentId) {
+            cond.put("filterType", filterType);
+        }
         setValue(knowTypeAssignMap, cond, 1); // 填充排除后总量
-        if (null != studentId && fillExclude) {
-            cond.remove("studentId");
+        if (fillExclude) {
+            if(null != studentId) {
+                cond.remove("studentId");
+            } else {
+                cond.remove("filterType");
+            }
             setValue(knowTypeAssignMap, cond, 2); // 按需填充已做总量
         }
         return knowTypeAssignMap;

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

@@ -316,14 +316,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
              LEFT JOIN `learn_answer` a ON kq.`question_id` = a.`question_id` AND a.`student_id` = #{studentId}
              LEFT JOIN `learn_examinee` e ON a.`examinee_id` = e.`examinee_id` AND e.`state` >= 4
          </if>
-         JOIN `learn_questions` q ON q.`id` = kq.`question_id`
+        <if test="filterType != null">
+            LEFT JOIN learn_question_used e on kq.`question_id` = e.`question_id` AND e.`type` = #{filterType}
+        </if>
+        JOIN `learn_questions` q ON q.`id` = kq.`question_id`
         <where>
             <if test="isSubType != null  and isSubType == 1"> and (q.knowId = q.id <if test="subCnt != null"> and kq.sub = #{subCnt}</if>)</if>
             <if test="isSubType != null  and isSubType == 2"> and (kq.sub = 0 or q.knowId = q.id <if test="subCnt != null"> and kq.sub = #{subCnt}</if>)</if>
             <if test="isSubType != null  and isSubType == 0"> and (kq.sub = 0)</if>
             <if test="knowIds != null"> and kq.`knowledge_id` in <foreach item="id" collection="knowIds" open="(" separator="," close=")">#{id}</foreach></if>
             <if test="types != null"> and q.`qtpye` in <foreach item="id" collection="types" open="(" separator="," close=")">#{id}</foreach></if>
-            <if test="studentId != null"> AND e.`examinee_id` IS NULL</if>
+            <if test="studentId != null or filterType != null"> AND e.`examinee_id` IS NULL</if>
             <if test="typeId != null"> AND kq.`type` = #{typeId}</if>
         </where>
         GROUP BY kq.knowledge_id, q.`qtpye`
@@ -336,6 +339,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             LEFT JOIN `learn_answer` a ON kq.`question_id` = a.`question_id` AND a.`student_id` = #{id}
             LEFT JOIN `learn_examinee` e ON a.`examinee_id` = e.`examinee_id` AND e.`state` >= 4
         </if>
+        <if test="area != null">
+            LEFT JOIN learn_question_used e on kq.`question_id` = e.`question_id` AND e.`type` = #{area}
+        </if>
         JOIN `learn_questions` q ON q.`id` = kq.`question_id`
         <where>
             <if test="isSubType != null  and isSubType == 1"> and (q.knowId = q.id <if test="subCnt != null"> and kq.sub = #{subCnt}</if>)</if>
@@ -343,7 +349,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isSubType != null  and isSubType == 0"> and (kq.sub = 0)</if>
             <if test="qtpye != null  and qtpye != ''"> and qtpye = #{qtpye}</if>
             <if test="typeId != null"> and kq.type = #{typeId}</if>
-            <if test="id != null ">  AND e.`examinee_id` IS NULL</if>
+            <if test="id != null or area != null ">  AND e.`examinee_id` IS NULL</if>
             <if test="knowledgeId != null "> and kq.knowledge_id  = #{knowledgeId}</if>
         </where>
         limit #{number}, 500