Переглянути джерело

Merge branch 'dev0410' of https://git.oschina.net/songyue123456/comm-ques-bank into dev0410

chenken 8 роки тому
батько
коміт
a3ef303ebb

+ 4 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/model/ImportPaperMsg.java

@@ -134,6 +134,10 @@ public class ImportPaperMsg {
      * 题干不能包含有序列
      */
     public static final String errMsg_10 = "题干不能包含有序列";
+    /**
+     * 选项不能包含有序列
+     */
+    public static final String errMsg_11 = "选项不能包含有序列";
     
     
 }

+ 22 - 6
cqb-paper/src/main/java/com/qmth/cqb/paper/service/ImportPaperService.java

@@ -206,7 +206,7 @@ public class ImportPaperService {
             if (StringUtils.isEmpty(pText)) {
                 // 跳过空白段落
                 continue;
-            } else if (isQuesHeader(pText)) {
+            } else if (isMainQuesHeader(pText)) {
                 // 处理大题头信息
                 processMainQuesHeader(pList, importPaperCheck.index, importPaperCheck);
                 // 校验大题头信息
@@ -288,13 +288,24 @@ public class ImportPaperService {
         return paper;
     }
 
-    public boolean isQuesHeader(String pText){
+    public boolean isMainQuesHeader(String pText){
         return pText.startsWith(ImportPaperMsg.left_bracket)
                 && !pText.startsWith(ImportPaperMsg.answer_word)
                 && !pText.startsWith(ImportPaperMsg.score_word)
                 && !pText.startsWith(ImportPaperMsg.subQuestionType_word);
     }
 
+    public boolean isHeader(String pText){
+        return pText.startsWith(ImportPaperMsg.questionClassify_word)
+                || pText.startsWith(ImportPaperMsg.questionType_word)
+                || pText.startsWith(ImportPaperMsg.questionName_word)
+                || pText.startsWith(ImportPaperMsg.questionNum_word)
+                || pText.startsWith(ImportPaperMsg.score_word)
+                || pText.startsWith(ImportPaperMsg.answer_word)
+                || pText.startsWith(ImportPaperMsg.subQuestionType_word)
+                || pText.startsWith(ImportPaperMsg.subQuesScore_word);
+    }
+
     /**
      * 初始化试卷信息
      *
@@ -477,7 +488,7 @@ public class ImportPaperService {
                 tmpWordMl = DocxProcessUtil.formatPWordMl(tmpWordMl);
                 quesBodyWordMl.append(tmpWordMl);
                 quesBodyHtml.append(DocxProcessUtil.docx2Html(tmpWordMl, wordMLPackage));
-            } else if (tmpText.matches("^[a-zA-Z]\\.[\\s\\S]*") || tmpText.startsWith(ImportPaperMsg.left_bracket)) {
+            } else if (tmpText.matches("^[a-zA-Z]\\.[\\s\\S]*") || isHeader(tmpText)) {
                 // 检测到选项或其他特殊段落直接退出
                 break;
             } else{
@@ -534,6 +545,11 @@ public class ImportPaperService {
             if (StringUtils.isEmpty(tmpText) && DocxProcessUtil.isText(pOption)) {
                 // 跳过空白段落
                 continue;
+            } else if (DocxProcessUtil.isNumPr(pOption)) {
+                // 检测到序列
+                importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck.quesName, subQuesNum)+ImportPaperMsg.errMsg_11);
+                throw new PaperException(importPaperCheck.errorInfo);
+
             } else if (tmpText.matches("^[a-zA-Z]\\.[\\s\\S]*")) {
                 // 检测到选项开始段落
                 // 创建试题选项
@@ -549,7 +565,7 @@ public class ImportPaperService {
                 String tmpWordMl = DocxProcessUtil.getPWordMl(pOption);
                 current.setOptionBody(current.getOptionBody() + DocxProcessUtil.docx2Html(tmpWordMl, wordMLPackage));
                 current.setOptionBodyWord(current.getOptionBodyWord() + DocxProcessUtil.formatPWordMl(tmpWordMl));
-            } else if (tmpText.startsWith(ImportPaperMsg.left_bracket)) {
+            } else if (isHeader(tmpText)) {
                 // 非选项的其他内容直接退出
                 break;
             } else if (current != null) {
@@ -621,7 +637,7 @@ public class ImportPaperService {
                 // 检测到分数开始段落
                 quesScore = getContent(tmpText, ImportPaperMsg.subQuesScore_word);
                 answerStart = false;
-            } else if (tmpText.startsWith(ImportPaperMsg.left_bracket) || tmpText.matches("^\\d{1,}\\.[\\s\\S]*")) {
+            } else if (isHeader(tmpText) || tmpText.matches("^\\d{1,}\\.[\\s\\S]*")) {
                 // 检测到其他特殊段落或下一题直接退出
                 break;
             } else if (answerStart) {
@@ -738,7 +754,7 @@ public class ImportPaperService {
                     importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck.quesName, quesTypeNum) + ImportPaperMsg.errMsg_03);
                 }
                 throw new PaperException(importPaperCheck.errorInfo);
-            }else if(tmpText.startsWith(ImportPaperMsg.left_bracket)){
+            }else if(isHeader(tmpText)){
                 break;
             }
             if (!StringUtils.isEmpty(importPaperCheck.errorInfo)) {