|
@@ -162,13 +162,12 @@ public class ImportPaperService {
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
|
|
|
|
- public Paper importPaper(Paper paper, User user, File file,UserDataRule ud) throws Exception {
|
|
|
|
|
|
+ public Paper importPaper(Paper paper, User user, File file, UserDataRule ud) throws Exception {
|
|
paperService.checkPaperNameNew(paper.getName(), user.getRootOrgId().toString());
|
|
paperService.checkPaperNameNew(paper.getName(), user.getRootOrgId().toString());
|
|
if (file.getName().endsWith(DOC_SUFFIX)) {
|
|
if (file.getName().endsWith(DOC_SUFFIX)) {
|
|
- return processImportPaper(paper, user, file,ud);
|
|
|
|
|
|
+ return processImportPaper(paper, user, file, ud);
|
|
} else if (file.getName().endsWith(JSON_SUFFIX)) {
|
|
} else if (file.getName().endsWith(JSON_SUFFIX)) {
|
|
- return importPaperFromJsonService.processImportPaper(paper, user,
|
|
|
|
- file);
|
|
|
|
|
|
+ return importPaperFromJsonService.processImportPaper(paper, user, file);
|
|
} else {
|
|
} else {
|
|
throw new PaperException("导入文件只支持.docx和.json类型");
|
|
throw new PaperException("导入文件只支持.docx和.json类型");
|
|
}
|
|
}
|
|
@@ -265,169 +264,171 @@ public class ImportPaperService {
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
|
|
|
|
- public Paper processImportPaper(Paper paper, User user, File file,UserDataRule ud) throws Exception {
|
|
|
|
|
|
+ public Paper processImportPaper(Paper paper, User user, File file, UserDataRule ud) throws Exception {
|
|
try {
|
|
try {
|
|
- if (ud.assertEmptyQueryResult()) {
|
|
|
|
- throw new StatusException("没有数据权限");
|
|
|
|
- }
|
|
|
|
|
|
+ if (ud.assertEmptyQueryResult()) {
|
|
|
|
+ throw new StatusException("没有数据权限");
|
|
|
|
+ }
|
|
|
|
|
|
// 得到前台的课程代码
|
|
// 得到前台的课程代码
|
|
String courseNo = paper.getCourseNo();
|
|
String courseNo = paper.getCourseNo();
|
|
|
|
|
|
- Course course = courseService.getCourse(user.getRootOrgId(), courseNo);
|
|
|
|
- if(ud.assertNeedQueryRefIds()&&!ud.stringRefIds().contains(course.getId())) {
|
|
|
|
- throw new StatusException("没有数据权限");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- WordprocessingMLPackage wordMLPackage;
|
|
|
|
- WordprocessingMLPackage tmpWordMlPackage;
|
|
|
|
- // WordprocessingMLPackage writePkg;
|
|
|
|
- ImportPaperCheck importPaperCheck = new ImportPaperCheck();
|
|
|
|
- wordMLPackage = WordprocessingMLPackage.load(file);
|
|
|
|
- // 初始化图片路径
|
|
|
|
- DocxProcessUtil.initPkgImage(wordMLPackage);
|
|
|
|
- // 深拷贝临时pkg与最终写入数据库pkg
|
|
|
|
- tmpWordMlPackage = DocxProcessUtil.getTmpPackage(wordMLPackage);
|
|
|
|
- // 获取word文档中所有段落
|
|
|
|
- List<Object> pList = DocxProcessUtil.getAllElementFromObject(wordMLPackage.getMainDocumentPart(), P.class);
|
|
|
|
- // 设置试卷
|
|
|
|
- initPaper(paper, paper.getName(), user);
|
|
|
|
- // 创建空大题类
|
|
|
|
- PaperDetail paperDetail = null;
|
|
|
|
- // 创建大题集合
|
|
|
|
- List<PaperDetail> paperDetails = new ArrayList<>();
|
|
|
|
- // 创建小题集合
|
|
|
|
- List<PaperDetailUnit> paperDetailUnits = new ArrayList<>();
|
|
|
|
- // 创建试题集合
|
|
|
|
- List<Question> questions = new ArrayList<>();
|
|
|
|
- // 大题号
|
|
|
|
- int mainQuesNum = 0;
|
|
|
|
- // 小题号
|
|
|
|
- int subQuesNum = 0;
|
|
|
|
- // 大题下的小题序号
|
|
|
|
- int errorQuesNum = 0;
|
|
|
|
- for (int i = 0; i < pList.size(); i++) {
|
|
|
|
- P p = (P) pList.get(i);
|
|
|
|
- String pText = DocxProcessUtil.getPText(p);
|
|
|
|
- if (StringUtils.isEmpty(pText)) {
|
|
|
|
- // 跳过空白段落
|
|
|
|
- continue;
|
|
|
|
- } else if (isMainQuesHeader(pText)) {
|
|
|
|
- // 处理大题头信息
|
|
|
|
- processMainQuesHeader(pList, importPaperCheck.getIndex(), importPaperCheck, courseNo);
|
|
|
|
- // 校验大题头信息
|
|
|
|
- if (!checkQuesHeader(importPaperCheck)) {
|
|
|
|
- throw new PaperException(importPaperCheck.getErrorInfo());
|
|
|
|
- }
|
|
|
|
- // 创建大题类
|
|
|
|
- paperDetail = new PaperDetail();
|
|
|
|
- // 设置大题类
|
|
|
|
- initQuesHeader(paper, paperDetail, paperDetails, ++mainQuesNum, importPaperCheck);
|
|
|
|
- // 设置当前索引,防止多余循环
|
|
|
|
- i = importPaperCheck.getIndex() - 1;
|
|
|
|
- errorQuesNum = 0;
|
|
|
|
- } else if (DocxProcessUtil.isNumPr(p)) {
|
|
|
|
- // 检测到序列
|
|
|
|
- importPaperCheck.setErrorInfo(importPaperCheck.getQuesName() + ImportPaperMsg.errMsg_10);
|
|
|
|
- throw new PaperException(importPaperCheck.getErrorInfo());
|
|
|
|
-
|
|
|
|
- } else if ((pText.matches("^\\d{1,}\\.[\\s\\S]*") && !pText.startsWith(ImportPaperMsg.left_bracket))
|
|
|
|
- || (isNested(importPaperCheck) && pText.startsWith(ImportPaperMsg.nestedQuestion_start))) {
|
|
|
|
- if (paperDetail == null) {
|
|
|
|
- throw new PaperException("导入文件格式有误,必须有大题头信息,且以 [ 开头!");
|
|
|
|
- }
|
|
|
|
- ++errorQuesNum;
|
|
|
|
- ++subQuesNum;
|
|
|
|
- // 处理试题
|
|
|
|
- // 创建小题类和试题类
|
|
|
|
- PaperDetailUnit paperDetailUnit = new PaperDetailUnit();
|
|
|
|
- Question question = new Question();
|
|
|
|
- // 初始化小题类和试题类
|
|
|
|
- initPaperDetail(paper, paperDetail, paperDetailUnit, question, subQuesNum, importPaperCheck);
|
|
|
|
- // 处理客观题
|
|
|
|
- if (importPaperCheck.getQuesType().equals(ImportPaperMsg.singleSelection)
|
|
|
|
- || importPaperCheck.getQuesType().equals(ImportPaperMsg.multipleSelection)) {
|
|
|
|
- // 处理题干
|
|
|
|
- processQuesBody(pList, importPaperCheck.getIndex(), subQuesNum, question, importPaperCheck,
|
|
|
|
- tmpWordMlPackage, errorQuesNum);
|
|
|
|
- // 处理选项
|
|
|
|
- processQuesOption(pList, importPaperCheck.getIndex(), subQuesNum, question, importPaperCheck,
|
|
|
|
- tmpWordMlPackage, errorQuesNum);
|
|
|
|
- // 处理尾信息
|
|
|
|
- processQuesTail(pList, importPaperCheck.getIndex(), subQuesNum, question, paperDetailUnit,
|
|
|
|
- importPaperCheck, tmpWordMlPackage, false, paper, errorQuesNum);
|
|
|
|
- // 处理选择题的option--chenken 20170425
|
|
|
|
- processSelectOption(question);
|
|
|
|
- } else if (importPaperCheck.getQuesType().equals(ImportPaperMsg.nestedQuestion_word)) {
|
|
|
|
- // 处理套题
|
|
|
|
- processNestedQues(pList, importPaperCheck.getIndex(), question, paperDetailUnit,
|
|
|
|
- importPaperCheck, tmpWordMlPackage, paper);
|
|
|
|
- } else {
|
|
|
|
- // 处理其他题型
|
|
|
|
- processQuesBody(pList, importPaperCheck.getIndex(), subQuesNum, question, importPaperCheck,
|
|
|
|
- tmpWordMlPackage, errorQuesNum);
|
|
|
|
- processQuesTail(pList, importPaperCheck.getIndex(), subQuesNum, question, paperDetailUnit,
|
|
|
|
- importPaperCheck, tmpWordMlPackage, false, paper, errorQuesNum);
|
|
|
|
- // 填空题空格校验
|
|
|
|
- if (question.getQuestionType().getName().equals(QuesStructType.FILL_BLANK_QUESTION.getName())) {
|
|
|
|
- if (!StringUtils.isBlank(question.getQuesAnswer())) {
|
|
|
|
- processFill(question, paperDetailUnit, importPaperCheck, subQuesNum, errorQuesNum);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // 设置WordMlPackage二进制数据
|
|
|
|
- // byte[] pkgByte = getZipResource(wordMLPackage, question);
|
|
|
|
- // QuestionPkgPath quesPkgPath = quesPkgPathRepo.save(new QuestionPkgPath(pkgByte));
|
|
|
|
- // question.setQuesPkgPathId(quesPkgPath.getId());
|
|
|
|
- // pkgByte = null;
|
|
|
|
- // quesPkgPath.setQuesPkg(null);
|
|
|
|
- // 设置question与Unit集合数据
|
|
|
|
- question.setCourse(paper.getCourse());
|
|
|
|
- question.setOrgId(user.getRootOrgId().toString());
|
|
|
|
- questions.add(question);
|
|
|
|
- paperDetailUnits.add(paperDetailUnit);
|
|
|
|
- // 设置当前索引,防止多余循环
|
|
|
|
- i = importPaperCheck.getIndex() - 1;
|
|
|
|
- } else if (paperDetail == null) {
|
|
|
|
- throw new PaperException("导入文件格式有误,必须有大题头信息,且以[试题分类]开头!");
|
|
|
|
- } else {
|
|
|
|
- String errorMsg = pText.length() > 10 ? pText.substring(0, 10) : pText;
|
|
|
|
- if (pText.startsWith(ImportPaperMsg.left_bracket)) {
|
|
|
|
- throw new PaperException(
|
|
|
|
- errorMsg + ",标签格式不正确!正确标签格式:[套题]、[套题数量]、[小题分数]、[答案]、[难度]、[一级属性]、[二级属性]、[公开度]、[小题型]");
|
|
|
|
- }
|
|
|
|
- throw new PaperException(
|
|
|
|
- importPaperCheck.getQuesName() + ":“" + errorMsg + "”" + ImportPaperMsg.errMsg_12);
|
|
|
|
- }
|
|
|
|
- if (!StringUtils.isEmpty(importPaperCheck.getErrorInfo())) {
|
|
|
|
- throw new PaperException(importPaperCheck.getErrorInfo());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (paperDetails.size() == 0 || paperDetailUnits.size() == 0) {
|
|
|
|
- throw new PaperException("导入文件格式有误!");
|
|
|
|
- }
|
|
|
|
- paper.setPaperDetailCount(mainQuesNum);
|
|
|
|
- // 保存导入试卷信息
|
|
|
|
- paper = savePaper(paper, paperDetails, paperDetailUnits, questions, importPaperCheck);
|
|
|
|
- clearPaper(paperDetails, paperDetailUnits, questions);
|
|
|
|
- wordMLPackage = null;
|
|
|
|
- tmpWordMlPackage = null;
|
|
|
|
- } finally {
|
|
|
|
- FileUtils.deleteQuietly(file);
|
|
|
|
- }
|
|
|
|
|
|
+ Course course = courseService.getCourse(user.getRootOrgId(), courseNo);
|
|
|
|
+ if (ud.assertNeedQueryRefIds() && !ud.stringRefIds().contains(course.getId())) {
|
|
|
|
+ throw new StatusException("没有数据权限");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ WordprocessingMLPackage wordMLPackage;
|
|
|
|
+ WordprocessingMLPackage tmpWordMlPackage;
|
|
|
|
+ // WordprocessingMLPackage writePkg;
|
|
|
|
+ ImportPaperCheck importPaperCheck = new ImportPaperCheck();
|
|
|
|
+ wordMLPackage = WordprocessingMLPackage.load(file);
|
|
|
|
+ // 初始化图片路径
|
|
|
|
+ DocxProcessUtil.initPkgImage(wordMLPackage);
|
|
|
|
+ // 深拷贝临时pkg与最终写入数据库pkg
|
|
|
|
+ tmpWordMlPackage = DocxProcessUtil.getTmpPackage(wordMLPackage);
|
|
|
|
+ // 获取word文档中所有段落
|
|
|
|
+ List<Object> pList = DocxProcessUtil.getAllElementFromObject(wordMLPackage.getMainDocumentPart(), P.class);
|
|
|
|
+ // 设置试卷
|
|
|
|
+ initPaper(paper, paper.getName(), user);
|
|
|
|
+ // 创建空大题类
|
|
|
|
+ PaperDetail paperDetail = null;
|
|
|
|
+ // 创建大题集合
|
|
|
|
+ List<PaperDetail> paperDetails = new ArrayList<>();
|
|
|
|
+ // 创建小题集合
|
|
|
|
+ List<PaperDetailUnit> paperDetailUnits = new ArrayList<>();
|
|
|
|
+ // 创建试题集合
|
|
|
|
+ List<Question> questions = new ArrayList<>();
|
|
|
|
+ // 大题号
|
|
|
|
+ int mainQuesNum = 0;
|
|
|
|
+ // 小题号
|
|
|
|
+ int subQuesNum = 0;
|
|
|
|
+ // 大题下的小题序号
|
|
|
|
+ int errorQuesNum = 0;
|
|
|
|
+ for (int i = 0; i < pList.size(); i++) {
|
|
|
|
+ P p = (P) pList.get(i);
|
|
|
|
+ String pText = DocxProcessUtil.getPText(p);
|
|
|
|
+ if (StringUtils.isEmpty(pText)) {
|
|
|
|
+ // 跳过空白段落
|
|
|
|
+ continue;
|
|
|
|
+ } else if (isMainQuesHeader(pText)) {
|
|
|
|
+ // 处理大题头信息
|
|
|
|
+ processMainQuesHeader(pList, importPaperCheck.getIndex(), importPaperCheck, courseNo);
|
|
|
|
+ // 校验大题头信息
|
|
|
|
+ if (!checkQuesHeader(importPaperCheck)) {
|
|
|
|
+ throw new PaperException(importPaperCheck.getErrorInfo());
|
|
|
|
+ }
|
|
|
|
+ // 创建大题类
|
|
|
|
+ paperDetail = new PaperDetail();
|
|
|
|
+ // 设置大题类
|
|
|
|
+ initQuesHeader(paper, paperDetail, paperDetails, ++mainQuesNum, importPaperCheck);
|
|
|
|
+ // 设置当前索引,防止多余循环
|
|
|
|
+ i = importPaperCheck.getIndex() - 1;
|
|
|
|
+ errorQuesNum = 0;
|
|
|
|
+ } else if (DocxProcessUtil.isNumPr(p)) {
|
|
|
|
+ // 检测到序列
|
|
|
|
+ importPaperCheck.setErrorInfo(importPaperCheck.getQuesName() + ImportPaperMsg.errMsg_10);
|
|
|
|
+ throw new PaperException(importPaperCheck.getErrorInfo());
|
|
|
|
+
|
|
|
|
+ } else if ((pText.matches("^\\d{1,}\\.[\\s\\S]*") && !pText.startsWith(ImportPaperMsg.left_bracket))
|
|
|
|
+ || (isNested(importPaperCheck) && pText.startsWith(ImportPaperMsg.nestedQuestion_start))) {
|
|
|
|
+ if (paperDetail == null) {
|
|
|
|
+ throw new PaperException("导入文件格式有误,必须有大题头信息,且以 [ 开头!");
|
|
|
|
+ }
|
|
|
|
+ ++errorQuesNum;
|
|
|
|
+ ++subQuesNum;
|
|
|
|
+ // 处理试题
|
|
|
|
+ // 创建小题类和试题类
|
|
|
|
+ PaperDetailUnit paperDetailUnit = new PaperDetailUnit();
|
|
|
|
+ Question question = new Question();
|
|
|
|
+ // 初始化小题类和试题类
|
|
|
|
+ initPaperDetail(paper, paperDetail, paperDetailUnit, question, subQuesNum, importPaperCheck);
|
|
|
|
+ // 处理客观题
|
|
|
|
+ if (importPaperCheck.getQuesType().equals(ImportPaperMsg.singleSelection)
|
|
|
|
+ || importPaperCheck.getQuesType().equals(ImportPaperMsg.multipleSelection)) {
|
|
|
|
+ // 处理题干
|
|
|
|
+ processQuesBody(pList, importPaperCheck.getIndex(), subQuesNum, question, importPaperCheck,
|
|
|
|
+ tmpWordMlPackage, errorQuesNum);
|
|
|
|
+ // 处理选项
|
|
|
|
+ processQuesOption(pList, importPaperCheck.getIndex(), subQuesNum, question, importPaperCheck,
|
|
|
|
+ tmpWordMlPackage, errorQuesNum);
|
|
|
|
+ // 处理尾信息
|
|
|
|
+ processQuesTail(pList, importPaperCheck.getIndex(), subQuesNum, question, paperDetailUnit,
|
|
|
|
+ importPaperCheck, tmpWordMlPackage, false, paper, errorQuesNum);
|
|
|
|
+ // 处理选择题的option--chenken 20170425
|
|
|
|
+ processSelectOption(question);
|
|
|
|
+ } else if (importPaperCheck.getQuesType().equals(ImportPaperMsg.nestedQuestion_word)) {
|
|
|
|
+ // 处理套题
|
|
|
|
+ processNestedQues(pList, importPaperCheck.getIndex(), question, paperDetailUnit,
|
|
|
|
+ importPaperCheck, tmpWordMlPackage, paper);
|
|
|
|
+ } else {
|
|
|
|
+ // 处理其他题型
|
|
|
|
+ processQuesBody(pList, importPaperCheck.getIndex(), subQuesNum, question, importPaperCheck,
|
|
|
|
+ tmpWordMlPackage, errorQuesNum);
|
|
|
|
+ processQuesTail(pList, importPaperCheck.getIndex(), subQuesNum, question, paperDetailUnit,
|
|
|
|
+ importPaperCheck, tmpWordMlPackage, false, paper, errorQuesNum);
|
|
|
|
+ // 填空题空格校验
|
|
|
|
+ if (question.getQuestionType().getName().equals(QuesStructType.FILL_BLANK_QUESTION.getName())) {
|
|
|
|
+ if (!StringUtils.isBlank(question.getQuesAnswer())) {
|
|
|
|
+ processFill(question, paperDetailUnit, importPaperCheck, subQuesNum, errorQuesNum);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 设置WordMlPackage二进制数据
|
|
|
|
+ // byte[] pkgByte = getZipResource(wordMLPackage, question);
|
|
|
|
+ // QuestionPkgPath quesPkgPath = quesPkgPathRepo.save(new
|
|
|
|
+ // QuestionPkgPath(pkgByte));
|
|
|
|
+ // question.setQuesPkgPathId(quesPkgPath.getId());
|
|
|
|
+ // pkgByte = null;
|
|
|
|
+ // quesPkgPath.setQuesPkg(null);
|
|
|
|
+ // 设置question与Unit集合数据
|
|
|
|
+ question.setCourse(paper.getCourse());
|
|
|
|
+ question.setOrgId(user.getRootOrgId().toString());
|
|
|
|
+ questions.add(question);
|
|
|
|
+ paperDetailUnits.add(paperDetailUnit);
|
|
|
|
+ // 设置当前索引,防止多余循环
|
|
|
|
+ i = importPaperCheck.getIndex() - 1;
|
|
|
|
+ } else if (paperDetail == null) {
|
|
|
|
+ throw new PaperException("导入文件格式有误,必须有大题头信息,且以[试题分类]开头!");
|
|
|
|
+ } else {
|
|
|
|
+ String errorMsg = pText.length() > 10 ? pText.substring(0, 10) : pText;
|
|
|
|
+ if (pText.startsWith(ImportPaperMsg.left_bracket)) {
|
|
|
|
+ throw new PaperException(
|
|
|
|
+ errorMsg + ",标签格式不正确!正确标签格式:[套题]、[套题数量]、[小题分数]、[答案]、[难度]、[一级属性]、[二级属性]、[公开度]、[小题型]");
|
|
|
|
+ }
|
|
|
|
+ throw new PaperException(
|
|
|
|
+ importPaperCheck.getQuesName() + ":“" + errorMsg + "”" + ImportPaperMsg.errMsg_12);
|
|
|
|
+ }
|
|
|
|
+ if (!StringUtils.isEmpty(importPaperCheck.getErrorInfo())) {
|
|
|
|
+ throw new PaperException(importPaperCheck.getErrorInfo());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (paperDetails.size() == 0 || paperDetailUnits.size() == 0) {
|
|
|
|
+ throw new PaperException("导入文件格式有误!");
|
|
|
|
+ }
|
|
|
|
+ paper.setPaperDetailCount(mainQuesNum);
|
|
|
|
+ // 保存导入试卷信息
|
|
|
|
+ paper = savePaper(paper, paperDetails, paperDetailUnits, questions, importPaperCheck);
|
|
|
|
+ clearPaper(paperDetails, paperDetailUnits, questions);
|
|
|
|
+ wordMLPackage = null;
|
|
|
|
+ tmpWordMlPackage = null;
|
|
|
|
+ } finally {
|
|
|
|
+ FileUtils.deleteQuietly(file);
|
|
|
|
+ }
|
|
return paper;
|
|
return paper;
|
|
}
|
|
}
|
|
|
|
|
|
-// private byte[] getZipResource(WordprocessingMLPackage wordMLPackage, Question question) throws Exception {
|
|
|
|
-// List<String> wordXmls = getWordXmlByQuestion(question);
|
|
|
|
-// List<Question> subQuestions = question.getSubQuestions();
|
|
|
|
-// if (subQuestions != null && subQuestions.size() > 0) {
|
|
|
|
-// for (Question subQuestion : subQuestions) {
|
|
|
|
-// wordXmls.addAll(getWordXmlByQuestion(subQuestion));
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// return DocxProcessUtil.getWordBytesByQuestion(wordMLPackage, wordXmls);
|
|
|
|
-// }
|
|
|
|
|
|
+ // private byte[] getZipResource(WordprocessingMLPackage wordMLPackage,
|
|
|
|
+ // Question question) throws Exception {
|
|
|
|
+ // List<String> wordXmls = getWordXmlByQuestion(question);
|
|
|
|
+ // List<Question> subQuestions = question.getSubQuestions();
|
|
|
|
+ // if (subQuestions != null && subQuestions.size() > 0) {
|
|
|
|
+ // for (Question subQuestion : subQuestions) {
|
|
|
|
+ // wordXmls.addAll(getWordXmlByQuestion(subQuestion));
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // return DocxProcessUtil.getWordBytesByQuestion(wordMLPackage, wordXmls);
|
|
|
|
+ // }
|
|
|
|
|
|
public List<String> getWordXmlByQuestion(Question question) {
|
|
public List<String> getWordXmlByQuestion(Question question) {
|
|
List<String> wordXmls = new ArrayList<>();
|
|
List<String> wordXmls = new ArrayList<>();
|
|
@@ -742,7 +743,7 @@ public class ImportPaperService {
|
|
// 定义题干wordml和html
|
|
// 定义题干wordml和html
|
|
StringBuilder quesBodyWordMl = new StringBuilder();
|
|
StringBuilder quesBodyWordMl = new StringBuilder();
|
|
StringBuilder quesBodyHtml = new StringBuilder();
|
|
StringBuilder quesBodyHtml = new StringBuilder();
|
|
- boolean hasSeq=false;
|
|
|
|
|
|
+ boolean hasSeq = false;
|
|
int i = 0;
|
|
int i = 0;
|
|
for (i = index; i < pList.size(); i++) {
|
|
for (i = index; i < pList.size(); i++) {
|
|
P pBody = (P) pList.get(i);
|
|
P pBody = (P) pList.get(i);
|
|
@@ -756,9 +757,9 @@ public class ImportPaperService {
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
|
|
|
|
} else if (tmpText.matches("^\\d{1,}\\.[\\s\\S]*")) {
|
|
} else if (tmpText.matches("^\\d{1,}\\.[\\s\\S]*")) {
|
|
- if(hasSeq) {
|
|
|
|
- // 检测到序列
|
|
|
|
- if (subQuesNum == 0) {
|
|
|
|
|
|
+ if (hasSeq) {
|
|
|
|
+ // 检测到序列
|
|
|
|
+ if (subQuesNum == 0) {
|
|
if (importPaperCheck.getNestedHeadNumber() != 0) {
|
|
if (importPaperCheck.getNestedHeadNumber() != 0) {
|
|
importPaperCheck.setErrorInfo(importPaperCheck.getQuesName() + "第"
|
|
importPaperCheck.setErrorInfo(importPaperCheck.getQuesName() + "第"
|
|
+ importPaperCheck.getNestedHeadNumber() + "个题" + ImportPaperMsg.errMsg_14);
|
|
+ importPaperCheck.getNestedHeadNumber() + "个题" + ImportPaperMsg.errMsg_14);
|
|
@@ -768,17 +769,18 @@ public class ImportPaperService {
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if (importPaperCheck.getNestedHeadNumber() != 0) {
|
|
if (importPaperCheck.getNestedHeadNumber() != 0) {
|
|
- importPaperCheck.setErrorInfo(importPaperCheck.getQuesName() + "第"
|
|
|
|
- + importPaperCheck.getNestedHeadNumber() + "个题" + errorQuesNum + ImportPaperMsg.errMsg_14);
|
|
|
|
|
|
+ importPaperCheck.setErrorInfo(
|
|
|
|
+ importPaperCheck.getQuesName() + "第" + importPaperCheck.getNestedHeadNumber() + "个题"
|
|
|
|
+ + errorQuesNum + ImportPaperMsg.errMsg_14);
|
|
} else {
|
|
} else {
|
|
importPaperCheck.setErrorInfo(
|
|
importPaperCheck.setErrorInfo(
|
|
getQuesNumInfo(importPaperCheck, errorQuesNum) + ImportPaperMsg.errMsg_14);
|
|
getQuesNumInfo(importPaperCheck, errorQuesNum) + ImportPaperMsg.errMsg_14);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
- }else {
|
|
|
|
- hasSeq=true;
|
|
|
|
- }
|
|
|
|
|
|
+ } else {
|
|
|
|
+ hasSeq = true;
|
|
|
|
+ }
|
|
// 题干第一段
|
|
// 题干第一段
|
|
// 过滤题干标题
|
|
// 过滤题干标题
|
|
pBody = DocxProcessUtil.formatP(pBody, QuesUnit.QUES_BODY);
|
|
pBody = DocxProcessUtil.formatP(pBody, QuesUnit.QUES_BODY);
|
|
@@ -803,16 +805,16 @@ public class ImportPaperService {
|
|
importPaperCheck.setErrorInfo(importPaperCheck.getQuesName() + "第"
|
|
importPaperCheck.setErrorInfo(importPaperCheck.getQuesName() + "第"
|
|
+ importPaperCheck.getNestedHeadNumber() + "个题" + ImportPaperMsg.errMsg_01);
|
|
+ importPaperCheck.getNestedHeadNumber() + "个题" + ImportPaperMsg.errMsg_01);
|
|
} else {
|
|
} else {
|
|
- importPaperCheck.setErrorInfo(
|
|
|
|
- getQuesNumInfo(importPaperCheck, errorQuesNum) + ImportPaperMsg.errMsg_01);
|
|
|
|
|
|
+ importPaperCheck
|
|
|
|
+ .setErrorInfo(getQuesNumInfo(importPaperCheck, errorQuesNum) + ImportPaperMsg.errMsg_01);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if (importPaperCheck.getNestedHeadNumber() != 0) {
|
|
if (importPaperCheck.getNestedHeadNumber() != 0) {
|
|
importPaperCheck.setErrorInfo(importPaperCheck.getQuesName() + "第"
|
|
importPaperCheck.setErrorInfo(importPaperCheck.getQuesName() + "第"
|
|
+ importPaperCheck.getNestedHeadNumber() + "个题" + errorQuesNum + ImportPaperMsg.errMsg_01);
|
|
+ importPaperCheck.getNestedHeadNumber() + "个题" + errorQuesNum + ImportPaperMsg.errMsg_01);
|
|
} else {
|
|
} else {
|
|
- importPaperCheck.setErrorInfo(
|
|
|
|
- getQuesNumInfo(importPaperCheck, errorQuesNum) + ImportPaperMsg.errMsg_01);
|
|
|
|
|
|
+ importPaperCheck
|
|
|
|
+ .setErrorInfo(getQuesNumInfo(importPaperCheck, errorQuesNum) + ImportPaperMsg.errMsg_01);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
@@ -858,8 +860,8 @@ public class ImportPaperService {
|
|
importPaperCheck.setErrorInfo(importPaperCheck.getQuesName() + "第"
|
|
importPaperCheck.setErrorInfo(importPaperCheck.getQuesName() + "第"
|
|
+ importPaperCheck.getNestedHeadNumber() + "个题" + errorQuesNum + ImportPaperMsg.errMsg_11);
|
|
+ importPaperCheck.getNestedHeadNumber() + "个题" + errorQuesNum + ImportPaperMsg.errMsg_11);
|
|
} else {
|
|
} else {
|
|
- importPaperCheck.setErrorInfo(
|
|
|
|
- getQuesNumInfo(importPaperCheck, errorQuesNum) + ImportPaperMsg.errMsg_11);
|
|
|
|
|
|
+ importPaperCheck
|
|
|
|
+ .setErrorInfo(getQuesNumInfo(importPaperCheck, errorQuesNum) + ImportPaperMsg.errMsg_11);
|
|
}
|
|
}
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
} else if (tmpText.matches("^[a-zA-Z]\\.[\\s\\S]*")) {
|
|
} else if (tmpText.matches("^[a-zA-Z]\\.[\\s\\S]*")) {
|
|
@@ -875,8 +877,8 @@ public class ImportPaperService {
|
|
importPaperCheck.getQuesName() + "第" + importPaperCheck.getNestedHeadNumber() + "个题"
|
|
importPaperCheck.getQuesName() + "第" + importPaperCheck.getNestedHeadNumber() + "个题"
|
|
+ errorQuesNum + ":“" + errorMsg + "”" + ImportPaperMsg.errMsg_13);
|
|
+ errorQuesNum + ":“" + errorMsg + "”" + ImportPaperMsg.errMsg_13);
|
|
} else {
|
|
} else {
|
|
- importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck, errorQuesNum)
|
|
|
|
- + ":“" + errorMsg + "”" + ImportPaperMsg.errMsg_13);
|
|
|
|
|
|
+ importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck, errorQuesNum) + ":“" + errorMsg
|
|
|
|
+ + "”" + ImportPaperMsg.errMsg_13);
|
|
}
|
|
}
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
}
|
|
}
|
|
@@ -908,8 +910,7 @@ public class ImportPaperService {
|
|
importPaperCheck.setErrorInfo(importPaperCheck.getQuesName() + "第"
|
|
importPaperCheck.setErrorInfo(importPaperCheck.getQuesName() + "第"
|
|
+ importPaperCheck.getNestedHeadNumber() + "个题" + errorQuesNum + "中选项格式不正确或有缺失\n");
|
|
+ importPaperCheck.getNestedHeadNumber() + "个题" + errorQuesNum + "中选项格式不正确或有缺失\n");
|
|
} else {
|
|
} else {
|
|
- importPaperCheck
|
|
|
|
- .setErrorInfo(getQuesNumInfo(importPaperCheck, errorQuesNum) + "中选项格式不正确或有缺失\n");
|
|
|
|
|
|
+ importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck, errorQuesNum) + "中选项格式不正确或有缺失\n");
|
|
}
|
|
}
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
} else {
|
|
} else {
|
|
@@ -1039,9 +1040,8 @@ public class ImportPaperService {
|
|
importPaperCheck.setErrorInfo(
|
|
importPaperCheck.setErrorInfo(
|
|
getQuesNumInfo(importPaperCheck, subQuesNum) + "中,答案格式不正确,答案为:" + pList.get(i).toString());
|
|
getQuesNumInfo(importPaperCheck, subQuesNum) + "中,答案格式不正确,答案为:" + pList.get(i).toString());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
- }else if(question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION){
|
|
|
|
- importPaperCheck.setErrorInfo(
|
|
|
|
- getQuesNumInfo(importPaperCheck, subQuesNum) + "中,答案格式不正确,应为:正确或错误");
|
|
|
|
|
|
+ } else if (question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION) {
|
|
|
|
+ importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,答案格式不正确,应为:正确或错误");
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
break;
|
|
break;
|
|
@@ -1054,8 +1054,7 @@ public class ImportPaperService {
|
|
importPaperCheck.setErrorInfo(paperDetailUnit.getPaperDetail().getName() + "中,第"
|
|
importPaperCheck.setErrorInfo(paperDetailUnit.getPaperDetail().getName() + "中,第"
|
|
+ paperDetailUnit.getNumber() + "个套题的" + errorQuesNum + "小题中,缺失“[答案]”");
|
|
+ paperDetailUnit.getNumber() + "个套题的" + errorQuesNum + "小题中,缺失“[答案]”");
|
|
} else {
|
|
} else {
|
|
- importPaperCheck
|
|
|
|
- .setErrorInfo(getQuesNumInfo(importPaperCheck, errorQuesNum) + "中,缺失“[答案]”");
|
|
|
|
|
|
+ importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck, errorQuesNum) + "中,缺失“[答案]”");
|
|
}
|
|
}
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
}
|
|
}
|
|
@@ -1063,18 +1062,18 @@ public class ImportPaperService {
|
|
if (StringUtils.isNotEmpty(answerHTML)) {
|
|
if (StringUtils.isNotEmpty(answerHTML)) {
|
|
if (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
|
|
if (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
|
|
|| question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION
|
|
|| question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION
|
|
- ||question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION) {
|
|
|
|
|
|
+ || question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION) {
|
|
question.setQuesAnswer(answerHTML.toString().replaceAll(" ", ""));
|
|
question.setQuesAnswer(answerHTML.toString().replaceAll(" ", ""));
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
question.setQuesAnswer(answerHTML.toString());
|
|
question.setQuesAnswer(answerHTML.toString());
|
|
}
|
|
}
|
|
question.setQuesAnswerWord(answerWordML.toString());
|
|
question.setQuesAnswerWord(answerWordML.toString());
|
|
} else {
|
|
} else {
|
|
if (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
|
|
if (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
|
|
|| question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION
|
|
|| question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION
|
|
- ||question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION) {
|
|
|
|
|
|
+ || question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION) {
|
|
question.setQuesAnswer("");
|
|
question.setQuesAnswer("");
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
question.setQuesAnswer("<p></p>");
|
|
question.setQuesAnswer("<p></p>");
|
|
}
|
|
}
|
|
question.setQuesAnswerWord(answerWordML.toString());
|
|
question.setQuesAnswerWord(answerWordML.toString());
|
|
@@ -1117,8 +1116,7 @@ public class ImportPaperService {
|
|
int subQuesNum, Paper paper, List<QuesProperty> quesProperties) throws Exception {
|
|
int subQuesNum, Paper paper, List<QuesProperty> quesProperties) throws Exception {
|
|
// 一级属性为空,二级属性有值
|
|
// 一级属性为空,二级属性有值
|
|
if (StringUtils.isBlank(firstProperty) && StringUtils.isNotBlank(secondProperty)) {
|
|
if (StringUtils.isBlank(firstProperty) && StringUtils.isNotBlank(secondProperty)) {
|
|
- importPaperCheck
|
|
|
|
- .setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,小题一级属性值为空,请检查");
|
|
|
|
|
|
+ importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,小题一级属性值为空,请检查");
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
}
|
|
}
|
|
// 一级属性,二级属性都有值
|
|
// 一级属性,二级属性都有值
|
|
@@ -1129,15 +1127,14 @@ public class ImportPaperService {
|
|
List<CourseProperty> courseProperties = coursePropertyRepo
|
|
List<CourseProperty> courseProperties = coursePropertyRepo
|
|
.findByCourseCodeAndEnable(paper.getCourse().getCode(), true);
|
|
.findByCourseCodeAndEnable(paper.getCourse().getCode(), true);
|
|
if (courseProperties == null || courseProperties.size() < 1) {
|
|
if (courseProperties == null || courseProperties.size() < 1) {
|
|
- importPaperCheck.setErrorInfo(
|
|
|
|
- getQuesNumInfo(importPaperCheck, subQuesNum) + "中,没有设置课程属性结构,请先设置课程属性结构");
|
|
|
|
|
|
+ importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,没有设置课程属性结构,请先设置课程属性结构");
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
}
|
|
}
|
|
|
|
|
|
for (CourseProperty courseProperty : courseProperties) {
|
|
for (CourseProperty courseProperty : courseProperties) {
|
|
// 查询一级属性是否存在
|
|
// 查询一级属性是否存在
|
|
Property proParent = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdAndCode(
|
|
Property proParent = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdAndCode(
|
|
- Long.valueOf(paper.getOrgId()), courseProperty.getId(), Property.ROOT_PARENT_ID, firstProperty);
|
|
|
|
|
|
+ Long.valueOf(paper.getOrgId()), courseProperty.getId(), Property.ROOT_PARENT_ID, firstProperty);
|
|
|
|
|
|
// 存在一级属性
|
|
// 存在一级属性
|
|
if (proParent != null) {
|
|
if (proParent != null) {
|
|
@@ -1145,7 +1142,7 @@ public class ImportPaperService {
|
|
|
|
|
|
// 查询二级属性
|
|
// 查询二级属性
|
|
Property proSon = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdAndCode(
|
|
Property proSon = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdAndCode(
|
|
- Long.valueOf(paper.getOrgId()), courseProperty.getId(), proParent.getId(), secondProperty);
|
|
|
|
|
|
+ Long.valueOf(paper.getOrgId()), courseProperty.getId(), proParent.getId(), secondProperty);
|
|
|
|
|
|
// 存在二级属性
|
|
// 存在二级属性
|
|
if (proSon != null) {
|
|
if (proSon != null) {
|
|
@@ -1162,14 +1159,14 @@ public class ImportPaperService {
|
|
}
|
|
}
|
|
|
|
|
|
if (isFirstEmpty) {
|
|
if (isFirstEmpty) {
|
|
- importPaperCheck.setErrorInfo(
|
|
|
|
- getQuesNumInfo(importPaperCheck, subQuesNum) + "中,小题一级属性值与课程属性中一级属性不匹配,请检查");
|
|
|
|
|
|
+ importPaperCheck
|
|
|
|
+ .setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,小题一级属性值与课程属性中一级属性不匹配,请检查");
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
}
|
|
}
|
|
|
|
|
|
if (isSecondEmpty) {
|
|
if (isSecondEmpty) {
|
|
- importPaperCheck.setErrorInfo(
|
|
|
|
- getQuesNumInfo(importPaperCheck, subQuesNum) + "中,小题二级属性值与课程属性中二级属性不匹配,请检查");
|
|
|
|
|
|
+ importPaperCheck
|
|
|
|
+ .setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,小题二级属性值与课程属性中二级属性不匹配,请检查");
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
}
|
|
}
|
|
} else if (StringUtils.isNotBlank(firstProperty) && StringUtils.isBlank(secondProperty)) {
|
|
} else if (StringUtils.isNotBlank(firstProperty) && StringUtils.isBlank(secondProperty)) {
|
|
@@ -1182,20 +1179,19 @@ public class ImportPaperService {
|
|
List<CourseProperty> courseProperties = coursePropertyRepo
|
|
List<CourseProperty> courseProperties = coursePropertyRepo
|
|
.findByCourseCodeAndEnable(paper.getCourse().getCode(), true);
|
|
.findByCourseCodeAndEnable(paper.getCourse().getCode(), true);
|
|
if (courseProperties == null || courseProperties.size() < 1) {
|
|
if (courseProperties == null || courseProperties.size() < 1) {
|
|
- importPaperCheck.setErrorInfo(
|
|
|
|
- getQuesNumInfo(importPaperCheck, subQuesNum) + "中,没有设置课程属性结构,请先设置课程属性结构");
|
|
|
|
|
|
+ importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,没有设置课程属性结构,请先设置课程属性结构");
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
}
|
|
}
|
|
|
|
|
|
for (CourseProperty courseProperty : courseProperties) {
|
|
for (CourseProperty courseProperty : courseProperties) {
|
|
// 查询一级属性
|
|
// 查询一级属性
|
|
Property proParent = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdAndCode(
|
|
Property proParent = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdAndCode(
|
|
- Long.valueOf(paper.getOrgId()), courseProperty.getId(), Property.ROOT_PARENT_ID, firstProperty);
|
|
|
|
|
|
+ Long.valueOf(paper.getOrgId()), courseProperty.getId(), Property.ROOT_PARENT_ID, firstProperty);
|
|
|
|
|
|
// 存在一级属性
|
|
// 存在一级属性
|
|
if (proParent != null) {
|
|
if (proParent != null) {
|
|
isFirstEmpty = false;
|
|
isFirstEmpty = false;
|
|
- // 根据一级属性查询二级属性
|
|
|
|
|
|
+ // 根据一级属性查询二级属性
|
|
List<Property> sonProperties = propertyRepo.findByParentIdOrderByNumber(proParent.getId());
|
|
List<Property> sonProperties = propertyRepo.findByParentIdOrderByNumber(proParent.getId());
|
|
|
|
|
|
// 存在二级属性,跳过
|
|
// 存在二级属性,跳过
|
|
@@ -1213,14 +1209,14 @@ public class ImportPaperService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (isFirstEmpty) {
|
|
if (isFirstEmpty) {
|
|
- importPaperCheck.setErrorInfo(
|
|
|
|
- getQuesNumInfo(importPaperCheck, subQuesNum) + "中,小题一级属性值与课程属性中一级属性不匹配,请检查");
|
|
|
|
|
|
+ importPaperCheck
|
|
|
|
+ .setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,小题一级属性值与课程属性中一级属性不匹配,请检查");
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
}
|
|
}
|
|
|
|
|
|
if (isSecondEmpty) {
|
|
if (isSecondEmpty) {
|
|
- importPaperCheck.setErrorInfo(
|
|
|
|
- getQuesNumInfo(importPaperCheck, subQuesNum) + "中,小题二级属性值与课程属性中二级属性不匹配,请检查");
|
|
|
|
|
|
+ importPaperCheck
|
|
|
|
+ .setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,小题二级属性值与课程属性中二级属性不匹配,请检查");
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -1239,26 +1235,22 @@ public class ImportPaperService {
|
|
private void checkAttributeIsFull(String firstProperty, String secondProperty, Double difficulty, Boolean publicity,
|
|
private void checkAttributeIsFull(String firstProperty, String secondProperty, Double difficulty, Boolean publicity,
|
|
ImportPaperCheck importPaperCheck, int subQuesNum) throws Exception {
|
|
ImportPaperCheck importPaperCheck, int subQuesNum) throws Exception {
|
|
if (firstProperty == null) {
|
|
if (firstProperty == null) {
|
|
- importPaperCheck
|
|
|
|
- .setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,小题一级属性缺失,请检查");
|
|
|
|
|
|
+ importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,小题一级属性缺失,请检查");
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
}
|
|
}
|
|
|
|
|
|
if (secondProperty == null) {
|
|
if (secondProperty == null) {
|
|
- importPaperCheck
|
|
|
|
- .setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,小题二级属性缺失,请检查");
|
|
|
|
|
|
+ importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,小题二级属性缺失,请检查");
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
}
|
|
}
|
|
|
|
|
|
if (difficulty == null) {
|
|
if (difficulty == null) {
|
|
- importPaperCheck
|
|
|
|
- .setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,小题难度缺失,请检查");
|
|
|
|
|
|
+ importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,小题难度缺失,请检查");
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
}
|
|
}
|
|
|
|
|
|
if (publicity == null) {
|
|
if (publicity == null) {
|
|
- importPaperCheck
|
|
|
|
- .setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,小题公开性缺失,请检查");
|
|
|
|
|
|
+ importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,小题公开性缺失,请检查");
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1375,11 +1367,11 @@ public class ImportPaperService {
|
|
hasQuesType = false;
|
|
hasQuesType = false;
|
|
} else if (subQuesNum != quesTypeNum) {
|
|
} else if (subQuesNum != quesTypeNum) {
|
|
if (StringUtils.isEmpty(nestedQuesType)) {
|
|
if (StringUtils.isEmpty(nestedQuesType)) {
|
|
- importPaperCheck.setErrorInfo(
|
|
|
|
- getQuesNumInfo(importPaperCheck, quesTypeNum) + ImportPaperMsg.errMsg_02);
|
|
|
|
|
|
+ importPaperCheck
|
|
|
|
+ .setErrorInfo(getQuesNumInfo(importPaperCheck, quesTypeNum) + ImportPaperMsg.errMsg_02);
|
|
} else {
|
|
} else {
|
|
- importPaperCheck.setErrorInfo(
|
|
|
|
- getQuesNumInfo(importPaperCheck, quesTypeNum) + ImportPaperMsg.errMsg_03);
|
|
|
|
|
|
+ importPaperCheck
|
|
|
|
+ .setErrorInfo(getQuesNumInfo(importPaperCheck, quesTypeNum) + ImportPaperMsg.errMsg_03);
|
|
}
|
|
}
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
} else if (isHeader(tmpText)) {
|
|
} else if (isHeader(tmpText)) {
|
|
@@ -1497,11 +1489,10 @@ public class ImportPaperService {
|
|
*/
|
|
*/
|
|
public static String getQuesNumInfo(ImportPaperCheck importPaperCheck, int subQuesNum) {
|
|
public static String getQuesNumInfo(ImportPaperCheck importPaperCheck, int subQuesNum) {
|
|
if (importPaperCheck.getNestedHeadNumber() == 0) {
|
|
if (importPaperCheck.getNestedHeadNumber() == 0) {
|
|
- return "[大题名称]:" + importPaperCheck.getQuesName() + "第" + subQuesNum + "小题";
|
|
|
|
|
|
+ return "[大题名称]:" + importPaperCheck.getQuesName() + "第" + subQuesNum + "小题";
|
|
} else {
|
|
} else {
|
|
- return "[大题名称]:" + importPaperCheck.getQuesName() + "第"
|
|
|
|
- + importPaperCheck.getNestedHeadNumber() + "小题,第" + subQuesNum
|
|
|
|
- + "子题";
|
|
|
|
|
|
+ return "[大题名称]:" + importPaperCheck.getQuesName() + "第" + importPaperCheck.getNestedHeadNumber() + "小题,第"
|
|
|
|
+ + subQuesNum + "子题";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1654,9 +1645,9 @@ public class ImportPaperService {
|
|
private void checkSelectAnswer(Question question, String answerWord, ImportPaperCheck importPaperCheck,
|
|
private void checkSelectAnswer(Question question, String answerWord, ImportPaperCheck importPaperCheck,
|
|
int subQuesNum) throws PaperException {
|
|
int subQuesNum) throws PaperException {
|
|
if (!StringUtils.isBlank(answerWord)) {
|
|
if (!StringUtils.isBlank(answerWord)) {
|
|
- if (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION&&answerWord.contains(",")) {
|
|
|
|
- importPaperCheck.setErrorInfo(
|
|
|
|
- getQuesNumInfo(importPaperCheck, subQuesNum) + "中,答案格式不正确,答案为:" + answerWord);
|
|
|
|
|
|
+ if (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION && answerWord.contains(",")) {
|
|
|
|
+ importPaperCheck
|
|
|
|
+ .setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,答案格式不正确,答案为:" + answerWord);
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
}
|
|
}
|
|
String[] pAnswerArray = answerWord.split(",");
|
|
String[] pAnswerArray = answerWord.split(",");
|
|
@@ -1671,8 +1662,8 @@ public class ImportPaperService {
|
|
answer = answer.trim();
|
|
answer = answer.trim();
|
|
String pattern = "[A-Z]|[a-z]";
|
|
String pattern = "[A-Z]|[a-z]";
|
|
if (!Pattern.matches(pattern, answer)) {
|
|
if (!Pattern.matches(pattern, answer)) {
|
|
- importPaperCheck.setErrorInfo(
|
|
|
|
- getQuesNumInfo(importPaperCheck, subQuesNum) + "中,答案格式不正确,答案为:" + answerWord);
|
|
|
|
|
|
+ importPaperCheck
|
|
|
|
+ .setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,答案格式不正确,答案为:" + answerWord);
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
}
|
|
}
|
|
if (!optionNumList.contains(answer)) {
|
|
if (!optionNumList.contains(answer)) {
|
|
@@ -1698,8 +1689,7 @@ public class ImportPaperService {
|
|
if (tmpText.equals("正确") || tmpText.equals("错误")) {
|
|
if (tmpText.equals("正确") || tmpText.equals("错误")) {
|
|
return;
|
|
return;
|
|
} else {
|
|
} else {
|
|
- importPaperCheck.setErrorInfo(
|
|
|
|
- getQuesNumInfo(importPaperCheck, subQuesNum) + "中,答案格式不正确,应为:正确或错误");
|
|
|
|
|
|
+ importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,答案格式不正确,应为:正确或错误");
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1717,8 +1707,7 @@ public class ImportPaperService {
|
|
question.setDifficulty("中");
|
|
question.setDifficulty("中");
|
|
} else if (!isInteger(tmpText) || (Double.parseDouble(tmpText) < 1) || (Double.parseDouble(tmpText) > 10)) {
|
|
} else if (!isInteger(tmpText) || (Double.parseDouble(tmpText) < 1) || (Double.parseDouble(tmpText) > 10)) {
|
|
// 如果不是整数,或者在1到10之间,就报错
|
|
// 如果不是整数,或者在1到10之间,就报错
|
|
- importPaperCheck
|
|
|
|
- .setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,试题难度只能是1到10之间整数");
|
|
|
|
|
|
+ importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,试题难度只能是1到10之间整数");
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
} else {
|
|
} else {
|
|
tempDifficulty = Double.parseDouble(tmpText) / 10;
|
|
tempDifficulty = Double.parseDouble(tmpText) / 10;
|
|
@@ -1748,8 +1737,7 @@ public class ImportPaperService {
|
|
publicity = true;
|
|
publicity = true;
|
|
} else if (!tmpText.equals("公开") && !tmpText.equals("非公开")) {
|
|
} else if (!tmpText.equals("公开") && !tmpText.equals("非公开")) {
|
|
// 如果不是公开和非公开,就报错
|
|
// 如果不是公开和非公开,就报错
|
|
- importPaperCheck
|
|
|
|
- .setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,试题公开度只能是公开和非公开");
|
|
|
|
|
|
+ importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck, subQuesNum) + "中,试题公开度只能是公开和非公开");
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
} else {
|
|
} else {
|
|
if (tmpText.equals("非公开")) {
|
|
if (tmpText.equals("非公开")) {
|
|
@@ -1835,7 +1823,7 @@ public class ImportPaperService {
|
|
*/
|
|
*/
|
|
private static String getContent(String pText, String replaceContent) {
|
|
private static String getContent(String pText, String replaceContent) {
|
|
String word = replaceContent.replace("[", "").replace("]", "");
|
|
String word = replaceContent.replace("[", "").replace("]", "");
|
|
- return pText.replaceAll("\\[" + word + "\\]", "").replaceAll("[::]", "").trim();
|
|
|
|
|
|
+ return pText.replaceFirst("\\[" + word + "\\]", "").replaceFirst("[::]", "").trim();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1919,11 +1907,13 @@ public class ImportPaperService {
|
|
User user) {
|
|
User user) {
|
|
Question oldQuestion = oldPaperDetailUnit.getQuestion();
|
|
Question oldQuestion = oldPaperDetailUnit.getQuestion();
|
|
Question newQuestion = BeanCopierUtil.copyProperties(oldQuestion, Question.class);
|
|
Question newQuestion = BeanCopierUtil.copyProperties(oldQuestion, Question.class);
|
|
-// QuestionPkgPath oldQuesPkgPath = quesPkgPathRepo.findFirstById(oldQuestion.getQuesPkgPathId());
|
|
|
|
-// QuestionPkgPath newQuestionPkgPath = BeanCopierUtil.copyProperties(oldQuesPkgPath, QuestionPkgPath.class);
|
|
|
|
-// newQuestionPkgPath.setId(null);
|
|
|
|
-// newQuestionPkgPath = quesPkgPathRepo.save(newQuestionPkgPath);
|
|
|
|
-// newQuestion.setQuesPkgPathId(newQuestionPkgPath.getId());
|
|
|
|
|
|
+ // QuestionPkgPath oldQuesPkgPath =
|
|
|
|
+ // quesPkgPathRepo.findFirstById(oldQuestion.getQuesPkgPathId());
|
|
|
|
+ // QuestionPkgPath newQuestionPkgPath =
|
|
|
|
+ // BeanCopierUtil.copyProperties(oldQuesPkgPath, QuestionPkgPath.class);
|
|
|
|
+ // newQuestionPkgPath.setId(null);
|
|
|
|
+ // newQuestionPkgPath = quesPkgPathRepo.save(newQuestionPkgPath);
|
|
|
|
+ // newQuestion.setQuesPkgPathId(newQuestionPkgPath.getId());
|
|
newQuestion.setCourse(course);
|
|
newQuestion.setCourse(course);
|
|
newQuestion.setId(null);
|
|
newQuestion.setId(null);
|
|
newQuestion.setQuesProperties(null);
|
|
newQuestion.setQuesProperties(null);
|
|
@@ -1931,86 +1921,87 @@ public class ImportPaperService {
|
|
newQuestion = quesRepo.save(newQuestion);
|
|
newQuestion = quesRepo.save(newQuestion);
|
|
// 复制音频
|
|
// 复制音频
|
|
if (oldQuestion.getHasAudio() != null && oldQuestion.getHasAudio()) {
|
|
if (oldQuestion.getHasAudio() != null && oldQuestion.getHasAudio()) {
|
|
-// try {
|
|
|
|
- // 查询旧音频
|
|
|
|
- List<QuestionAudio> oldQuestionAudios = questionAudioService
|
|
|
|
- .findQuestionAudiosByQuestionId(oldQuestion.getId());
|
|
|
|
- // 复制文件下载路径
|
|
|
|
- String copyAudioPath = TEMP_FILE_EXP + File.separator + user.getDisplayName() + "_copyAudioPath";
|
|
|
|
- // 新建文件夹
|
|
|
|
- File copyAudioDir = new File(copyAudioPath);
|
|
|
|
- if (!copyAudioDir.exists()) {
|
|
|
|
- copyAudioDir.mkdirs();
|
|
|
|
|
|
+ // try {
|
|
|
|
+ // 查询旧音频
|
|
|
|
+ List<QuestionAudio> oldQuestionAudios = questionAudioService
|
|
|
|
+ .findQuestionAudiosByQuestionId(oldQuestion.getId());
|
|
|
|
+ // 复制文件下载路径
|
|
|
|
+ String copyAudioPath = TEMP_FILE_EXP + File.separator + user.getDisplayName() + "_copyAudioPath";
|
|
|
|
+ // 新建文件夹
|
|
|
|
+ File copyAudioDir = new File(copyAudioPath);
|
|
|
|
+ if (!copyAudioDir.exists()) {
|
|
|
|
+ copyAudioDir.mkdirs();
|
|
|
|
+ }
|
|
|
|
+ for (QuestionAudio oldAudio : oldQuestionAudios) {
|
|
|
|
+ // 生成随机数,防止文件重名
|
|
|
|
+ int randomNumber = random.nextInt(1000);
|
|
|
|
+ // 定义文件下载名称,下载音频文件
|
|
|
|
+ String newAudioFileName = newQuestion.getId() + "_" + randomNumber + "_" + oldAudio.getFileName();
|
|
|
|
+
|
|
|
|
+ // 下载音频
|
|
|
|
+ File audioFile = new File(copyAudioPath + File.separator + newAudioFileName);
|
|
|
|
+ try {
|
|
|
|
+ String filePath = FssHelper.fixFilePath(oldAudio.getFileUrl());
|
|
|
|
+ FssFactory.getInstance().readFile(filePath, audioFile);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
+ throw new RuntimeException("下载音频失败");
|
|
}
|
|
}
|
|
- for (QuestionAudio oldAudio : oldQuestionAudios) {
|
|
|
|
- // 生成随机数,防止文件重名
|
|
|
|
- int randomNumber = random.nextInt(1000);
|
|
|
|
- // 定义文件下载名称,下载音频文件
|
|
|
|
- String newAudioFileName = newQuestion.getId() + "_" + randomNumber + "_" + oldAudio.getFileName();
|
|
|
|
-
|
|
|
|
- // 下载音频
|
|
|
|
- File audioFile = new File(copyAudioPath + File.separator + newAudioFileName);
|
|
|
|
- try {
|
|
|
|
- String filePath = FssHelper.fixFilePath(oldAudio.getFileUrl());
|
|
|
|
- FssFactory.getInstance().readFile(filePath, audioFile);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error(e.getMessage(), e);
|
|
|
|
- throw new RuntimeException("下载音频失败");
|
|
|
|
|
|
+ // 重新上传新的音频文件
|
|
|
|
+ String newPath = String.format(FileConstants.RADIO_UPLOAD_PATH, newAudioFileName);
|
|
|
|
+ FssFileInfo result = FssFactory.getInstance().writeFile(newPath, audioFile, null);
|
|
|
|
+
|
|
|
|
+ IoUtils.removeFile(audioFile);
|
|
|
|
+
|
|
|
|
+ // 拷贝旧对象
|
|
|
|
+ QuestionAudio newAudio = new QuestionAudio(newQuestion.getId(), oldAudio.getFileName(),
|
|
|
|
+ result.getFileUrl());
|
|
|
|
+ newAudio.setCreateTime(new Date());
|
|
|
|
+ newAudio.setCreateUser(user.getDisplayName());
|
|
|
|
+ questionAudioService.saveQuestionAudio(newAudio, user);
|
|
|
|
+ }
|
|
|
|
+ // 删除文件夹
|
|
|
|
+ IoUtils.removeFile(copyAudioDir);
|
|
|
|
+
|
|
|
|
+ // 查询新音频
|
|
|
|
+ List<QuestionAudio> newQuestionAudios = questionAudioService
|
|
|
|
+ .findQuestionAudiosByQuestionId(newQuestion.getId());
|
|
|
|
+ Map<String, String> newMap = new HashMap<>();
|
|
|
|
+ for (QuestionAudio audio : newQuestionAudios) {
|
|
|
|
+ newMap.put(audio.getFileName(), audio.getId());
|
|
|
|
+ }
|
|
|
|
+ // 在题干html片段中替换音频存储id
|
|
|
|
+ String body = newQuestion.getQuesBody();
|
|
|
|
+ List<String> ids = CommonUtils.getTagANames(body);
|
|
|
|
+ List<String> names = CommonUtils.getTagANames2(body);
|
|
|
|
+ Map<String, String> oldBodyMap = new HashMap<>();
|
|
|
|
+ for (int i = 0; i < ids.size(); i++) {
|
|
|
|
+ oldBodyMap.put(names.get(i), ids.get(i));
|
|
|
|
+ }
|
|
|
|
+ for (String key : oldBodyMap.keySet()) {
|
|
|
|
+ body = body.replace(oldBodyMap.get(key), newMap.get(key));
|
|
|
|
+ }
|
|
|
|
+ newQuestion.setQuesBody(body);
|
|
|
|
+ // 替换选项中的音频存储id
|
|
|
|
+ if (newQuestion.getQuesOptions() != null && newQuestion.getQuesOptions().size() > 0) {
|
|
|
|
+ for (QuesOption option : newQuestion.getQuesOptions()) {
|
|
|
|
+ String newOptionBody = option.getOptionBody();
|
|
|
|
+ List<String> optionIds = CommonUtils.getTagANames(newOptionBody);
|
|
|
|
+ List<String> optionNames = CommonUtils.getTagANames2(newOptionBody);
|
|
|
|
+ Map<String, String> oldOptionMap = new HashMap<>();
|
|
|
|
+ for (int i = 0; i < optionIds.size(); i++) {
|
|
|
|
+ oldOptionMap.put(optionNames.get(i), optionIds.get(i));
|
|
}
|
|
}
|
|
- // 重新上传新的音频文件
|
|
|
|
- String newPath = String.format(FileConstants.RADIO_UPLOAD_PATH, newAudioFileName);
|
|
|
|
- FssFileInfo result = FssFactory.getInstance().writeFile(newPath, audioFile, null);
|
|
|
|
-
|
|
|
|
- IoUtils.removeFile(audioFile);
|
|
|
|
-
|
|
|
|
- // 拷贝旧对象
|
|
|
|
- QuestionAudio newAudio = new QuestionAudio(newQuestion.getId(), oldAudio.getFileName(),result.getFileUrl());
|
|
|
|
- newAudio.setCreateTime(new Date());
|
|
|
|
- newAudio.setCreateUser(user.getDisplayName());
|
|
|
|
- questionAudioService.saveQuestionAudio(newAudio, user);
|
|
|
|
- }
|
|
|
|
- // 删除文件夹
|
|
|
|
- IoUtils.removeFile(copyAudioDir);
|
|
|
|
-
|
|
|
|
- // 查询新音频
|
|
|
|
- List<QuestionAudio> newQuestionAudios = questionAudioService
|
|
|
|
- .findQuestionAudiosByQuestionId(newQuestion.getId());
|
|
|
|
- Map<String, String> newMap = new HashMap<>();
|
|
|
|
- for (QuestionAudio audio : newQuestionAudios) {
|
|
|
|
- newMap.put(audio.getFileName(), audio.getId());
|
|
|
|
- }
|
|
|
|
- // 在题干html片段中替换音频存储id
|
|
|
|
- String body = newQuestion.getQuesBody();
|
|
|
|
- List<String> ids = CommonUtils.getTagANames(body);
|
|
|
|
- List<String> names = CommonUtils.getTagANames2(body);
|
|
|
|
- Map<String, String> oldBodyMap = new HashMap<>();
|
|
|
|
- for (int i = 0; i < ids.size(); i++) {
|
|
|
|
- oldBodyMap.put(names.get(i), ids.get(i));
|
|
|
|
- }
|
|
|
|
- for (String key : oldBodyMap.keySet()) {
|
|
|
|
- body = body.replace(oldBodyMap.get(key), newMap.get(key));
|
|
|
|
- }
|
|
|
|
- newQuestion.setQuesBody(body);
|
|
|
|
- // 替换选项中的音频存储id
|
|
|
|
- if (newQuestion.getQuesOptions() != null && newQuestion.getQuesOptions().size() > 0) {
|
|
|
|
- for (QuesOption option : newQuestion.getQuesOptions()) {
|
|
|
|
- String newOptionBody = option.getOptionBody();
|
|
|
|
- List<String> optionIds = CommonUtils.getTagANames(newOptionBody);
|
|
|
|
- List<String> optionNames = CommonUtils.getTagANames2(newOptionBody);
|
|
|
|
- Map<String, String> oldOptionMap = new HashMap<>();
|
|
|
|
- for (int i = 0; i < optionIds.size(); i++) {
|
|
|
|
- oldOptionMap.put(optionNames.get(i), optionIds.get(i));
|
|
|
|
- }
|
|
|
|
- for (String key : oldOptionMap.keySet()) {
|
|
|
|
- newOptionBody = newOptionBody.replace(oldOptionMap.get(key), newMap.get(key));
|
|
|
|
- }
|
|
|
|
- option.setOptionBody(newOptionBody);
|
|
|
|
|
|
+ for (String key : oldOptionMap.keySet()) {
|
|
|
|
+ newOptionBody = newOptionBody.replace(oldOptionMap.get(key), newMap.get(key));
|
|
}
|
|
}
|
|
|
|
+ option.setOptionBody(newOptionBody);
|
|
}
|
|
}
|
|
- newQuestion = quesRepo.save(newQuestion);
|
|
|
|
-// } catch (IOException e) {
|
|
|
|
-// log.error(e.getMessage(), e);
|
|
|
|
-// }
|
|
|
|
|
|
+ }
|
|
|
|
+ newQuestion = quesRepo.save(newQuestion);
|
|
|
|
+ // } catch (IOException e) {
|
|
|
|
+ // log.error(e.getMessage(), e);
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
paperDetailUnit.setQuestion(newQuestion);
|
|
paperDetailUnit.setQuestion(newQuestion);
|
|
}
|
|
}
|
|
@@ -2040,17 +2031,16 @@ public class ImportPaperService {
|
|
*/
|
|
*/
|
|
public void processFill(Question question, PaperDetailUnit paperDetailUnit, ImportPaperCheck importPaperCheck,
|
|
public void processFill(Question question, PaperDetailUnit paperDetailUnit, ImportPaperCheck importPaperCheck,
|
|
int subQuesNum, int errorQuesNum) throws PaperException {
|
|
int subQuesNum, int errorQuesNum) throws PaperException {
|
|
- if(!question.getQuesBody().contains("###")) {
|
|
|
|
- if (importPaperCheck.getNestedHeadNumber() == 0) {
|
|
|
|
- importPaperCheck.setErrorInfo(
|
|
|
|
- "[大题名称]:" + importPaperCheck.getQuesName() + "第" + errorQuesNum + "题中,题干中没有空格");
|
|
|
|
|
|
+ if (!question.getQuesBody().contains("###")) {
|
|
|
|
+ if (importPaperCheck.getNestedHeadNumber() == 0) {
|
|
|
|
+ importPaperCheck
|
|
|
|
+ .setErrorInfo("[大题名称]:" + importPaperCheck.getQuesName() + "第" + errorQuesNum + "题中,题干中没有空格");
|
|
} else {
|
|
} else {
|
|
importPaperCheck.setErrorInfo("[大题名称]:" + importPaperCheck.getQuesName() + "第"
|
|
importPaperCheck.setErrorInfo("[大题名称]:" + importPaperCheck.getQuesName() + "第"
|
|
- + importPaperCheck.getNestedHeadNumber() + "个套题中,第" + errorQuesNum
|
|
|
|
- + "题中,题干中没有空格");
|
|
|
|
|
|
+ + importPaperCheck.getNestedHeadNumber() + "个套题中,第" + errorQuesNum + "题中,题干中没有空格");
|
|
}
|
|
}
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
throw new PaperException(importPaperCheck.getErrorInfo());
|
|
- }
|
|
|
|
|
|
+ }
|
|
// 按3个#号截取题干
|
|
// 按3个#号截取题干
|
|
String[] quesBody = question.getQuesBody().split("###");
|
|
String[] quesBody = question.getQuesBody().split("###");
|
|
String[] quesAnwser = question.getQuesAnswer().split("##");
|
|
String[] quesAnwser = question.getQuesAnswer().split("##");
|