|
@@ -101,17 +101,14 @@ public class ImportPaperService {
|
|
String errorInfo = paperService.checkPaperName(paperName, user.getRootOrgId().toString());
|
|
String errorInfo = paperService.checkPaperName(paperName, user.getRootOrgId().toString());
|
|
if (errorInfo == null) {
|
|
if (errorInfo == null) {
|
|
msgMap = processImportPaper(paperName, courseNo, courseName, user, file);
|
|
msgMap = processImportPaper(paperName, courseNo, courseName, user, file);
|
|
- if (StringUtils.isEmpty((String) msgMap.get("msg"))) {
|
|
|
|
- msgMap.put("msg", "success");
|
|
|
|
- return msgMap;
|
|
|
|
- } else {
|
|
|
|
- log.error("导入异常:" + (String) msgMap.get("msg"));
|
|
|
|
- return msgMap;
|
|
|
|
|
|
+ String errorMsg = (String)msgMap.get("msg");
|
|
|
|
+ if(StringUtils.isNotEmpty(errorMsg)){
|
|
|
|
+ throw new PaperException(errorMsg);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- msgMap.put("msg", errorInfo);
|
|
|
|
- return msgMap;
|
|
|
|
|
|
+ throw new PaperException(errorInfo);
|
|
}
|
|
}
|
|
|
|
+ return msgMap;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -283,12 +280,14 @@ public class ImportPaperService {
|
|
i = importPaperCheck.index - 1;
|
|
i = importPaperCheck.index - 1;
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(importPaperCheck.errorInfo)) {
|
|
if (!StringUtils.isEmpty(importPaperCheck.errorInfo)) {
|
|
- throw new PaperException(importPaperCheck.errorInfo);
|
|
|
|
|
|
+ msgMap.put("msg", importPaperCheck.errorInfo);
|
|
|
|
+ return msgMap;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (paperDetails.size() == 0) {
|
|
if (paperDetails.size() == 0) {
|
|
importPaperCheck.setErrorInfo("导入文件格式有误!");
|
|
importPaperCheck.setErrorInfo("导入文件格式有误!");
|
|
- throw new PaperException("导入文件格式有误!");
|
|
|
|
|
|
+ msgMap.put("msg", importPaperCheck.errorInfo);
|
|
|
|
+ return msgMap;
|
|
}
|
|
}
|
|
paper.setPaperDetailCount(mainQuesNum);
|
|
paper.setPaperDetailCount(mainQuesNum);
|
|
// 保存导入试卷信息
|
|
// 保存导入试卷信息
|
|
@@ -684,6 +683,8 @@ public class ImportPaperService {
|
|
|
|
|
|
int beginNum = importPaperCheck.index;
|
|
int beginNum = importPaperCheck.index;
|
|
|
|
|
|
|
|
+ int tempNum = 0;
|
|
|
|
+
|
|
int subQuesNum = 0;
|
|
int subQuesNum = 0;
|
|
for (int i = beginNum; i < pList.size(); i++) {
|
|
for (int i = beginNum; i < pList.size(); i++) {
|
|
P pSubQues = (P) pList.get(i);
|
|
P pSubQues = (P) pList.get(i);
|
|
@@ -696,14 +697,15 @@ public class ImportPaperService {
|
|
|
|
|
|
nestedQuesType = tmpText.replaceAll("\\[小题型\\]", "").replaceAll("[:|:]", "").trim();
|
|
nestedQuesType = tmpText.replaceAll("\\[小题型\\]", "").replaceAll("[:|:]", "").trim();
|
|
importPaperCheck.index++;
|
|
importPaperCheck.index++;
|
|
|
|
+ tempNum = i;
|
|
|
|
|
|
} else if (tmpText.matches("^\\d\\.[\\s\\S]*")) {
|
|
} else if (tmpText.matches("^\\d\\.[\\s\\S]*")) {
|
|
|
|
|
|
++subQuesNum;
|
|
++subQuesNum;
|
|
|
|
|
|
if (StringUtils.isEmpty(nestedQuesType)) {
|
|
if (StringUtils.isEmpty(nestedQuesType)) {
|
|
- importPaperCheck
|
|
|
|
- .setErrorInfo(getQuesNumInfo(importPaperCheck.quesName, subQuesNum) + "小题型为空或格式不正确\n");
|
|
|
|
|
|
+ importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck.quesName, subQuesNum)
|
|
|
|
+ + "小题型为空或格式不正确\n");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -740,8 +742,18 @@ public class ImportPaperService {
|
|
subQuesList.add(subQues);
|
|
subQuesList.add(subQues);
|
|
i = importPaperCheck.index - 1;
|
|
i = importPaperCheck.index - 1;
|
|
nestedQuesType = "";
|
|
nestedQuesType = "";
|
|
- } else {
|
|
|
|
|
|
+ }else if(tmpText.startsWith("[")){
|
|
break;
|
|
break;
|
|
|
|
+ }else{
|
|
|
|
+ if(i == tempNum + 1){
|
|
|
|
+ importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck.quesName, subQuesNum + 1)
|
|
|
|
+ +"小题型后面只能为小题题干,且必须以数字开头,不能以其他格式开头\n");
|
|
|
|
+ return;
|
|
|
|
+ }else if (StringUtils.isEmpty(nestedQuesType)) {
|
|
|
|
+ importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck.quesName, subQuesNum + 1)
|
|
|
|
+ + "小题型为空或格式不正确\n");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(importPaperCheck.errorInfo)) {
|
|
if (!StringUtils.isEmpty(importPaperCheck.errorInfo)) {
|
|
return;
|
|
return;
|