|
@@ -14,12 +14,13 @@ import org.apache.commons.io.IOUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
|
|
import org.docx4j.wml.P;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
-import com.qmth.cqb.base.dao.CourseRepo;
|
|
|
import com.qmth.cqb.paper.dao.PaperDetailRepo;
|
|
|
import com.qmth.cqb.paper.dao.PaperDetailUnitRepo;
|
|
|
import com.qmth.cqb.paper.dao.PaperRepo;
|
|
@@ -27,10 +28,10 @@ import com.qmth.cqb.paper.model.ImportPaperCheck;
|
|
|
import com.qmth.cqb.paper.model.Paper;
|
|
|
import com.qmth.cqb.paper.model.PaperDetail;
|
|
|
import com.qmth.cqb.paper.model.PaperDetailUnit;
|
|
|
-import com.qmth.cqb.question.dao.QuesRepo;
|
|
|
import com.qmth.cqb.question.model.QuesOption;
|
|
|
import com.qmth.cqb.question.model.Question;
|
|
|
import com.qmth.cqb.question.model.QuestionType;
|
|
|
+import com.qmth.cqb.question.service.QuesService;
|
|
|
import com.qmth.cqb.utils.CommonUtils;
|
|
|
import com.qmth.cqb.utils.enums.PaperStatus;
|
|
|
import com.qmth.cqb.utils.enums.PaperType;
|
|
@@ -38,10 +39,13 @@ import com.qmth.cqb.utils.enums.QuesUnit;
|
|
|
import com.qmth.cqb.utils.word.DocxProcessUtil;
|
|
|
|
|
|
import cn.com.qmth.examcloud.common.dto.question.enums.QuesStructType;
|
|
|
+import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
|
|
|
|
|
|
@Service
|
|
|
public class ImportPaperService {
|
|
|
|
|
|
+ protected static final Logger log = LoggerFactory.getLogger(ImportPaperService.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
PaperRepo paperRepo;
|
|
|
|
|
@@ -52,7 +56,7 @@ public class ImportPaperService {
|
|
|
PaperDetailUnitRepo paperDetailUnitRepo;
|
|
|
|
|
|
@Autowired
|
|
|
- QuesRepo quesRepo;
|
|
|
+ QuesService quesService;
|
|
|
|
|
|
@Autowired
|
|
|
Gson gson;
|
|
@@ -63,12 +67,9 @@ public class ImportPaperService {
|
|
|
@Autowired
|
|
|
PaperService paperService;
|
|
|
|
|
|
- @Autowired
|
|
|
- CourseRepo courseRepo;
|
|
|
-
|
|
|
/**
|
|
|
* 获取上传文件
|
|
|
- *
|
|
|
+ *
|
|
|
* @param file
|
|
|
* @return
|
|
|
*/
|
|
@@ -81,6 +82,7 @@ public class ImportPaperService {
|
|
|
IOUtils.copyLarge(file.getInputStream(), os);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
+ log.error("上传文件异常:" + e.getMessage());
|
|
|
} finally {
|
|
|
IOUtils.closeQuietly(os);
|
|
|
}
|
|
@@ -89,15 +91,23 @@ public class ImportPaperService {
|
|
|
|
|
|
/**
|
|
|
* 导入试卷
|
|
|
- *
|
|
|
+ *
|
|
|
+ * @param paperName
|
|
|
* @param courseNo
|
|
|
+ * @param file
|
|
|
* @return
|
|
|
*/
|
|
|
- public String ImportPaper(String paperName, String courseNo, File file) {
|
|
|
- String errorInfo = paperService.checkPaperName(paperName);
|
|
|
- errorInfo += processImportPaper(paperName, courseNo, file);
|
|
|
- if (StringUtils.isEmpty(errorInfo)) {
|
|
|
- return "success";
|
|
|
+ public String ImportPaper(String paperName, String courseNo, String courseName, AccessUser user, File file) {
|
|
|
+ String errorInfo = paperService.checkPaperName(paperName, user.getOrgId().toString());
|
|
|
+ if (errorInfo == null) {
|
|
|
+ errorInfo = "";
|
|
|
+ errorInfo += processImportPaper(paperName, courseNo, courseName, user, file);
|
|
|
+ if (StringUtils.isEmpty(errorInfo)) {
|
|
|
+ return "success";
|
|
|
+ } else {
|
|
|
+ log.error("导入异常:" + errorInfo);
|
|
|
+ return errorInfo;
|
|
|
+ }
|
|
|
} else {
|
|
|
return errorInfo;
|
|
|
}
|
|
@@ -105,7 +115,7 @@ public class ImportPaperService {
|
|
|
|
|
|
/**
|
|
|
* 保存导入试卷信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param paper
|
|
|
* @param paperDetails
|
|
|
* @param paperDetailUnits
|
|
@@ -128,7 +138,7 @@ public class ImportPaperService {
|
|
|
}
|
|
|
|
|
|
if (questions.size() > 0) {
|
|
|
- quesRepo.save(questions);
|
|
|
+ quesService.saveImportQuesList(questions);
|
|
|
}
|
|
|
|
|
|
if (paperDetailUnits.size() > 0) {
|
|
@@ -140,10 +150,10 @@ public class ImportPaperService {
|
|
|
|
|
|
/**
|
|
|
* 处理导入试卷
|
|
|
- *
|
|
|
+ *
|
|
|
* @param file
|
|
|
*/
|
|
|
- public String processImportPaper(String paperName, String courseNo, File file) {
|
|
|
+ public String processImportPaper(String paperName, String courseNo, String courseName, AccessUser user, File file) {
|
|
|
|
|
|
WordprocessingMLPackage wordMLPackage;
|
|
|
WordprocessingMLPackage tmpWordMlPackage;
|
|
@@ -166,6 +176,12 @@ public class ImportPaperService {
|
|
|
|
|
|
paper.setCourseNo(courseNo);
|
|
|
|
|
|
+ paper.setCourseName(courseName);
|
|
|
+
|
|
|
+ paper.setOrgId(user.getOrgId().toString());
|
|
|
+
|
|
|
+ paper.setCreator(user.getLoginName());
|
|
|
+
|
|
|
// 设置试卷
|
|
|
initPaper(paper, paperName);
|
|
|
|
|
@@ -245,8 +261,10 @@ public class ImportPaperService {
|
|
|
}
|
|
|
// 设置WordMlPackage二进制数据
|
|
|
setPkgByte(question, writePkg);
|
|
|
-
|
|
|
// 设置question与Unit集合数据
|
|
|
+ question.setCourseNo(paper.getCourseNo());
|
|
|
+ question.setCourseName(paper.getCourseName());
|
|
|
+ question.setOrgId(user.getOrgId().toString());
|
|
|
questions.add(question);
|
|
|
paperDetailUnits.add(paperDetailUnit);
|
|
|
|
|
@@ -264,6 +282,7 @@ public class ImportPaperService {
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
importPaperCheck.setErrorInfo(e.getMessage());
|
|
|
+ log.error("导入处理异常:" + e.getMessage());
|
|
|
} finally {
|
|
|
wordMLPackage = null;
|
|
|
tmpWordMlPackage = null;
|
|
@@ -275,7 +294,7 @@ public class ImportPaperService {
|
|
|
|
|
|
/**
|
|
|
* 初始化试卷信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param paper
|
|
|
* @param paperName
|
|
|
*/
|
|
@@ -288,7 +307,7 @@ public class ImportPaperService {
|
|
|
|
|
|
/**
|
|
|
* 初始化大题头信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param paper
|
|
|
* @param paperDetail
|
|
|
* @param paperDetails
|
|
@@ -299,24 +318,18 @@ public class ImportPaperService {
|
|
|
ImportPaperCheck importPaperCheck) {
|
|
|
|
|
|
paperDetail.setPaper(paper);
|
|
|
-
|
|
|
- // 设置课程
|
|
|
- if (StringUtils.isEmpty(paper.getCourseNo()) || StringUtils.isEmpty(paper.getCourseName())) {
|
|
|
- paper.setCourseNo(getCourseNo(importPaperCheck));
|
|
|
- paper.setCourseName(getCourseName(importPaperCheck));
|
|
|
- }
|
|
|
// 设置大题信息
|
|
|
paperDetail.setName(importPaperCheck.quesName);
|
|
|
paperDetail.setUnitCount(Integer.parseInt(importPaperCheck.quesCount));
|
|
|
paperDetail.setNumber(mainQuesNum);
|
|
|
-
|
|
|
+ paperDetail.setCreator(paper.getCreator());
|
|
|
paperDetails.add(paperDetail);
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 初始化试卷明细和试题
|
|
|
- *
|
|
|
+ *
|
|
|
* @param paperDetail
|
|
|
* @param paperDetailUnit
|
|
|
* @param question
|
|
@@ -333,12 +346,13 @@ public class ImportPaperService {
|
|
|
paperDetailUnit.setPaperDetail(paperDetail);
|
|
|
paperDetailUnit.setQuestionType(getQuesStructType(importPaperCheck.quesType));
|
|
|
paperDetailUnit.setScore(Double.parseDouble(importPaperCheck.quesScore));
|
|
|
+ paperDetailUnit.setCreator(paper.getCreator());
|
|
|
paperDetailUnit.setPaper(paper);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 校验试题头标识
|
|
|
- *
|
|
|
+ *
|
|
|
* @param importPaperCheck
|
|
|
* @return
|
|
|
*/
|
|
@@ -377,7 +391,7 @@ public class ImportPaperService {
|
|
|
|
|
|
/**
|
|
|
* 处理大题头信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param pList
|
|
|
* @param index
|
|
|
* @param importPaperCheck
|
|
@@ -420,7 +434,7 @@ public class ImportPaperService {
|
|
|
|
|
|
/**
|
|
|
* 处理题干信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param pList
|
|
|
* @param index
|
|
|
* @param question
|
|
@@ -431,38 +445,42 @@ public class ImportPaperService {
|
|
|
public void processQuesBody(List pList, int index, Question question, ImportPaperCheck importPaperCheck,
|
|
|
WordprocessingMLPackage wordMLPackage) throws Exception {
|
|
|
// 定义题干wordml和html
|
|
|
- String quesBodyWordMl = "";
|
|
|
- String quesBodyHtml = "";
|
|
|
+ StringBuilder quesBodyWordMl = new StringBuilder();
|
|
|
+ StringBuilder quesBodyHtml = new StringBuilder();
|
|
|
int i = 0;
|
|
|
|
|
|
for (i = index; i < pList.size(); i++) {
|
|
|
P pBody = (P) pList.get(i);
|
|
|
String tmpText = DocxProcessUtil.getPText(pBody);
|
|
|
|
|
|
- // 判断是否为题干
|
|
|
if (StringUtils.isEmpty(tmpText)) {
|
|
|
+ // 跳过空白段落
|
|
|
continue;
|
|
|
- } else if (tmpText.matches("^\\d{1,}\\.[\\s\\S]*")
|
|
|
- || (!tmpText.matches("^[a-zA-Z]\\.[\\s\\S]*") && !tmpText.startsWith("["))) {
|
|
|
+ } else if (tmpText.matches("^\\d{1,}\\.[\\s\\S]*")) {
|
|
|
+ // 题干第一段
|
|
|
// 过滤题干标题
|
|
|
pBody = DocxProcessUtil.formatP(pBody, QuesUnit.QUES_BODY);
|
|
|
-
|
|
|
String tmpWordMl = DocxProcessUtil.getPWordMl(pBody);
|
|
|
- String tmpHtml = DocxProcessUtil.docx2Html(tmpWordMl, wordMLPackage);
|
|
|
- quesBodyWordMl += DocxProcessUtil.formatPWordMl(tmpWordMl);
|
|
|
- quesBodyHtml += tmpHtml;
|
|
|
- } else {
|
|
|
+ quesBodyWordMl.append(DocxProcessUtil.formatPWordMl(tmpWordMl));
|
|
|
+ quesBodyHtml.append(DocxProcessUtil.docx2Html(tmpWordMl, wordMLPackage));
|
|
|
+ } else if (tmpText.matches("^[a-zA-Z]\\.[\\s\\S]*") || tmpText.startsWith("[")) {
|
|
|
+ // 检测到选项或其他特殊段落直接退出
|
|
|
break;
|
|
|
+ } else {
|
|
|
+ // 题干普通段落
|
|
|
+ String tmpWordMl = DocxProcessUtil.getPWordMl(pBody);
|
|
|
+ quesBodyWordMl.append(DocxProcessUtil.formatPWordMl(tmpWordMl));
|
|
|
+ quesBodyHtml.append(DocxProcessUtil.docx2Html(tmpWordMl, wordMLPackage));
|
|
|
}
|
|
|
}
|
|
|
importPaperCheck.setIndex(i);
|
|
|
- question.setQuesBody(quesBodyHtml);
|
|
|
- question.setQuesBodyWord(quesBodyWordMl);
|
|
|
+ question.setQuesBody(quesBodyHtml.toString());
|
|
|
+ question.setQuesBodyWord(quesBodyWordMl.toString());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 处理题目选项
|
|
|
- *
|
|
|
+ *
|
|
|
* @param pList
|
|
|
* @param index
|
|
|
* @param subQuesNum
|
|
@@ -476,12 +494,14 @@ public class ImportPaperService {
|
|
|
ImportPaperCheck importPaperCheck, WordprocessingMLPackage wordMLPackage) throws Exception {
|
|
|
|
|
|
// 定义试题选项wordml和html
|
|
|
- String quesOptionWordMl = "";
|
|
|
- String quesOptionHtml = "";
|
|
|
+ // String quesOptionWordMl = "";
|
|
|
+ // String quesOptionHtml = "";
|
|
|
// 定义选项集合
|
|
|
List<QuesOption> quesOptions = new ArrayList<QuesOption>();
|
|
|
// 定义选项数量
|
|
|
int optionCount = 0;
|
|
|
+ // 当前所处的选项
|
|
|
+ QuesOption current = null;
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
@@ -490,21 +510,30 @@ public class ImportPaperService {
|
|
|
String tmpText = DocxProcessUtil.getPText(pOption);
|
|
|
|
|
|
if (StringUtils.isEmpty(tmpText)) {
|
|
|
+ // 跳过空白段落
|
|
|
continue;
|
|
|
- } else if (tmpText.matches("^[a-zA-Z]\\.[\\s\\S]*")) {// 判断是否为选项
|
|
|
- // 过滤选项标题
|
|
|
- pOption = DocxProcessUtil.formatP(pOption, QuesUnit.QUES_OPTION);
|
|
|
- quesOptionWordMl = DocxProcessUtil.getPWordMl(pOption);
|
|
|
- quesOptionHtml = DocxProcessUtil.docx2Html(quesOptionWordMl, wordMLPackage);
|
|
|
+ } else if (tmpText.matches("^[a-zA-Z]\\.[\\s\\S]*")) {
|
|
|
+ // 检测到选项开始段落
|
|
|
// 创建试题选项
|
|
|
- QuesOption quesOption = new QuesOption();
|
|
|
- quesOption.setOptionBody(quesOptionHtml);
|
|
|
- quesOption.setOptionBodyWord(DocxProcessUtil.formatPWordMl(quesOptionWordMl));
|
|
|
- quesOption.setNumber(tmpText.substring(0, 1));
|
|
|
- quesOptions.add(quesOption);
|
|
|
+ current = new QuesOption();
|
|
|
+ current.setNumber(tmpText.substring(0, 1));
|
|
|
+ current.setOptionBody("");
|
|
|
+ current.setOptionBodyWord("");
|
|
|
+ quesOptions.add(current);
|
|
|
optionCount++;
|
|
|
- } else {
|
|
|
+ // 过滤选项标题
|
|
|
+ pOption = DocxProcessUtil.formatP(pOption, QuesUnit.QUES_OPTION);
|
|
|
+ String tmpWordMl = DocxProcessUtil.getPWordMl(pOption);
|
|
|
+ current.setOptionBody(current.getOptionBody() + DocxProcessUtil.docx2Html(tmpWordMl, wordMLPackage));
|
|
|
+ current.setOptionBodyWord(current.getOptionBodyWord() + DocxProcessUtil.formatPWordMl(tmpWordMl));
|
|
|
+ } else if (tmpText.startsWith("[")) {
|
|
|
+ // 非选项的其他内容直接退出
|
|
|
break;
|
|
|
+ } else if (current != null) {
|
|
|
+ // 选项的其他段落
|
|
|
+ String tmpWordMl = DocxProcessUtil.getPWordMl(pOption);
|
|
|
+ current.setOptionBody(current.getOptionBody() + DocxProcessUtil.docx2Html(tmpWordMl, wordMLPackage));
|
|
|
+ current.setOptionBodyWord(current.getOptionBodyWord() + DocxProcessUtil.formatPWordMl(tmpWordMl));
|
|
|
}
|
|
|
}
|
|
|
importPaperCheck.setIndex(i);
|
|
@@ -519,7 +548,7 @@ public class ImportPaperService {
|
|
|
|
|
|
/**
|
|
|
* 处理小题尾信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param pList
|
|
|
* @param index
|
|
|
* @param subQuesNum
|
|
@@ -531,33 +560,45 @@ public class ImportPaperService {
|
|
|
PaperDetailUnit paperDetailUnit, ImportPaperCheck importPaperCheck, WordprocessingMLPackage wordMLPackage,
|
|
|
boolean isNested) throws Exception {
|
|
|
|
|
|
- String quesAnwserWordMl = "";
|
|
|
- String quesAnwserHtml = "";
|
|
|
+ StringBuilder answerWordML = new StringBuilder("");
|
|
|
+ StringBuilder answerHTML = new StringBuilder("");
|
|
|
String quesScore = "";
|
|
|
- Map<String, String> quesParams = new HashMap<String, String>();
|
|
|
+ // Map<String, String> quesParams = new HashMap<String, String>();
|
|
|
int i = 0;
|
|
|
+ // 是否刚刚检测到答案内容
|
|
|
+ boolean answerStart = false;
|
|
|
|
|
|
for (i = index; i < pList.size(); i++) {
|
|
|
P pAnswer = (P) pList.get(i);
|
|
|
String tmpText = DocxProcessUtil.getPText(pAnswer);
|
|
|
if (StringUtils.isEmpty(tmpText)) {
|
|
|
+ // 跳过空白段落
|
|
|
continue;
|
|
|
} else if (tmpText.startsWith("[答案]")) {
|
|
|
+ // 检测到答案开始段落
|
|
|
pAnswer = DocxProcessUtil.formatP(pAnswer, QuesUnit.QUES_ANSWER);
|
|
|
- quesAnwserWordMl = DocxProcessUtil.getPWordMl(pAnswer);
|
|
|
- quesAnwserHtml = DocxProcessUtil.docx2Html(quesAnwserWordMl, wordMLPackage);
|
|
|
-
|
|
|
+ String tmpWordMl = DocxProcessUtil.getPWordMl(pAnswer);
|
|
|
+ answerWordML.append(DocxProcessUtil.formatPWordMl(tmpWordMl));
|
|
|
+ answerHTML.append(DocxProcessUtil.docx2Html(tmpWordMl, wordMLPackage));
|
|
|
+ answerStart = true;
|
|
|
} else if (tmpText.startsWith("[小题分数]")) {
|
|
|
+ // 检测到分数开始段落
|
|
|
quesScore = tmpText.replaceAll("\\[小题分数\\]", "").replaceAll("[:|:]", "").trim();
|
|
|
- } else {
|
|
|
+ answerStart = false;
|
|
|
+ } else if (tmpText.startsWith("[") || tmpText.matches("^\\d{1,}\\.[\\s\\S]*")) {
|
|
|
+ // 检测到其他特殊段落或下一题直接退出
|
|
|
break;
|
|
|
+ } else if (answerStart) {
|
|
|
+ String tmpWordMl = DocxProcessUtil.getPWordMl(pAnswer);
|
|
|
+ answerWordML.append(DocxProcessUtil.formatPWordMl(tmpWordMl));
|
|
|
+ answerHTML.append(DocxProcessUtil.docx2Html(tmpWordMl, wordMLPackage));
|
|
|
}
|
|
|
}
|
|
|
importPaperCheck.setIndex(i);
|
|
|
// 校验答案
|
|
|
- if (!StringUtils.isEmpty(quesAnwserHtml)) {
|
|
|
- question.setQuesAnswer(quesAnwserHtml);
|
|
|
- question.setQuesAnswerWord(DocxProcessUtil.formatPWordMl(quesAnwserWordMl));
|
|
|
+ if (answerHTML.length() > 0) {
|
|
|
+ question.setQuesAnswer(answerHTML.toString());
|
|
|
+ question.setQuesAnswerWord(answerWordML.toString());
|
|
|
} else {
|
|
|
importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck.quesName, subQuesNum) + "答案为空或格式不正确\n");
|
|
|
}
|
|
@@ -574,7 +615,7 @@ public class ImportPaperService {
|
|
|
|
|
|
/**
|
|
|
* 处理套题
|
|
|
- *
|
|
|
+ *
|
|
|
* @param pList
|
|
|
* @param index
|
|
|
* @param question
|
|
@@ -655,11 +696,25 @@ public class ImportPaperService {
|
|
|
}
|
|
|
}
|
|
|
question.setSubQuestions(subQuesList);
|
|
|
+ // 计算套题总分
|
|
|
+ double totalScore = 0;
|
|
|
+ List<Double> scoreList = new ArrayList<>();
|
|
|
+ for (Question child : subQuesList) {
|
|
|
+ Double score = child.getScore();
|
|
|
+ if (score != null) {
|
|
|
+ totalScore += score;
|
|
|
+ scoreList.add(score);
|
|
|
+ } else {
|
|
|
+ scoreList.add(0d);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ question.setScore(totalScore);
|
|
|
+ paperDetailUnit.setSubScoreList(scoreList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取试题类型
|
|
|
- *
|
|
|
+ *
|
|
|
* @param quesType
|
|
|
* @return
|
|
|
*/
|
|
@@ -669,7 +724,7 @@ public class ImportPaperService {
|
|
|
|
|
|
/**
|
|
|
* 获取试题类型
|
|
|
- *
|
|
|
+ *
|
|
|
* @param quesType
|
|
|
* @param quesName
|
|
|
* @return
|
|
@@ -681,7 +736,7 @@ public class ImportPaperService {
|
|
|
|
|
|
/**
|
|
|
* 获取试题结构类型
|
|
|
- *
|
|
|
+ *
|
|
|
* @param quesType
|
|
|
* @return
|
|
|
*/
|
|
@@ -691,7 +746,7 @@ public class ImportPaperService {
|
|
|
|
|
|
/**
|
|
|
* 获取当前试题大题小题号
|
|
|
- *
|
|
|
+ *
|
|
|
* @param quesType
|
|
|
* @param subQuesNum
|
|
|
* @return
|
|
@@ -702,7 +757,7 @@ public class ImportPaperService {
|
|
|
|
|
|
/**
|
|
|
* 判断是否为套题
|
|
|
- *
|
|
|
+ *
|
|
|
* @param importPaperCheck
|
|
|
* @return
|
|
|
*/
|
|
@@ -716,7 +771,7 @@ public class ImportPaperService {
|
|
|
|
|
|
/**
|
|
|
* 获取课程代码
|
|
|
- *
|
|
|
+ *
|
|
|
* @param importPaperCheck
|
|
|
* @return
|
|
|
*/
|
|
@@ -731,7 +786,7 @@ public class ImportPaperService {
|
|
|
|
|
|
/**
|
|
|
* 获取课程名称
|
|
|
- *
|
|
|
+ *
|
|
|
* @param importPaperCheck
|
|
|
* @return
|
|
|
*/
|
|
@@ -746,7 +801,7 @@ public class ImportPaperService {
|
|
|
|
|
|
/**
|
|
|
* 设置wordMLPackage对象二进制数据
|
|
|
- *
|
|
|
+ *
|
|
|
* @param question
|
|
|
* @param wordMLPackage
|
|
|
* @throws Exception
|
|
@@ -757,29 +812,35 @@ public class ImportPaperService {
|
|
|
|
|
|
/**
|
|
|
* 构造一张空白的导入类型试卷
|
|
|
- *
|
|
|
+ *
|
|
|
* @param courseNo
|
|
|
- * @param courseName
|
|
|
* @param paperName
|
|
|
* @return
|
|
|
*/
|
|
|
- public String saveBlankPaper(String courseNo, String paperName) {
|
|
|
+ public Map<String, Object> saveBlankPaper(String courseNo, String courseName, String paperName, AccessUser user) {
|
|
|
+ Map<String, Object> returnMap = new HashMap<String, Object>();
|
|
|
Paper paper = new Paper();
|
|
|
- String courseName = courseRepo.findByCourseNo(courseNo).getCourseName();
|
|
|
- String msg = paperService.checkPaperName(paperName);
|
|
|
+ String msg = paperService.checkPaperName(paperName, user.getOrgId().toString());
|
|
|
if (msg != null) {
|
|
|
- return msg;
|
|
|
+ returnMap.put("msg", msg);
|
|
|
+ return returnMap;
|
|
|
}
|
|
|
initPaper(paper, paperName);
|
|
|
paper.setCourseNo(courseNo);
|
|
|
paper.setCourseName(courseName);
|
|
|
+ paper.setOrgId(user.getOrgId().toString());
|
|
|
+ paper.setCreator(user.getLoginName());
|
|
|
+ paper.setCreateTime(CommonUtils.getCurDateTime());
|
|
|
PaperDetail pd = new PaperDetail();
|
|
|
pd.setId(UUID.randomUUID().toString());
|
|
|
pd.setNumber(1);
|
|
|
pd.setPaper(paper);
|
|
|
- paperRepo.save(paper);
|
|
|
+ pd.setCreator(user.getLoginName());
|
|
|
+ pd.setCreateTime(CommonUtils.getCurDateTime());
|
|
|
+ paper = paperRepo.save(paper);
|
|
|
paperDetailRepo.save(pd);
|
|
|
- msg = "success";
|
|
|
- return msg;
|
|
|
+ returnMap.put("paper", paper);
|
|
|
+ returnMap.put("msg", "success");
|
|
|
+ return returnMap;
|
|
|
}
|
|
|
}
|