yangdamao 2 дней назад
Родитель
Сommit
1fdb4204dc

+ 24 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java

@@ -4726,6 +4726,30 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                 end = i;
             }
         }
+
+        if (start == 0 ){
+            //没有匹配到 100题
+            for (int i = 0; i < questions.size(); i++) {
+                String s = questions.get(i);
+                String pattern = "(\\d+)[、.]?(.*?题)"; // 匹配数字和题型
+                Pattern p = Pattern.compile(pattern);
+                Matcher m = p.matcher(s);
+                if (m.find()){
+                    start = i -1;
+                }
+            }
+        }
+
+        if (end == 0 ){
+            //没有匹配到 考生答案
+            for (int i = 0; i < questions.size(); i++) {
+                String s = questions.get(i);
+                if (s.contains("正确答案")){
+                    end = i - 1;
+                }
+            }
+        }
+
         List<String> content = questions.subList(start + 1, end);
         //获取第一个判断题型
         String bt = content.get(0);