|
@@ -344,8 +344,7 @@ public class CqdxService {
|
|
|
}
|
|
|
|
|
|
// 初始化小题集合
|
|
|
- private List<PaperDetailUnit> initpaperDetailUnits(Paper paper,
|
|
|
- List<PaperDetail> paperDetails, Map<Question, QuestionPkgPath> map,
|
|
|
+ private List<PaperDetailUnit> initpaperDetailUnits(Paper paper, List<PaperDetail> paperDetails, Map<Question, QuestionPkgPath> map,
|
|
|
Map<Object, Object> paperInfoMap, Course course) throws Exception {
|
|
|
List<PaperDetailUnit> paperDetailUnits = new ArrayList<PaperDetailUnit>();
|
|
|
int detailCount = paperDetails.size();
|
|
@@ -371,7 +370,9 @@ public class CqdxService {
|
|
|
question.setDifficultyDegree(0.5);
|
|
|
question.setPublicity(true);
|
|
|
question.setQuestionType(quesTemp.getType());
|
|
|
- question.setQuesBody(imgList(quesTemp.getBody()));
|
|
|
+
|
|
|
+ String body = imgList(quesTemp.getBody());
|
|
|
+ question.setQuesBody(replaceBlank(body));
|
|
|
try {
|
|
|
question.setQuesBodyWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(question.getQuesBody())));
|
|
|
} catch (Exception e) {
|
|
@@ -386,8 +387,8 @@ public class CqdxService {
|
|
|
try {
|
|
|
question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(question.getQuesAnswer())));
|
|
|
} catch (Exception e) {
|
|
|
- System.out.println("错误题干信息:" + question.getQuesAnswer());
|
|
|
- throw new IllegalArgumentException("题干信息错误!");
|
|
|
+ System.out.println("错误答案信息:" + question.getQuesAnswer());
|
|
|
+ throw new IllegalArgumentException("答案信息错误!");
|
|
|
}
|
|
|
}
|
|
|
// 存在选项
|
|
@@ -399,11 +400,19 @@ public class CqdxService {
|
|
|
for (int k = 0; k < optionCount; k++) {
|
|
|
QuesOption quesOption = new QuesOption();
|
|
|
quesOption.setNumber(String.valueOf(k + 1));
|
|
|
- quesOption.setOptionBody(imgList((String) optionMap.get(String.valueOf(k + 1))));
|
|
|
+
|
|
|
+ String optionBody = imgList((String) optionMap.get(String.valueOf(k + 1)));
|
|
|
+ if (optionBody.startsWith("<p><p") || optionBody.startsWith("<P><P")) {
|
|
|
+ quesOption.setOptionBody(replaceFirstP(optionBody));
|
|
|
+ } else {
|
|
|
+ quesOption.setOptionBody(optionBody);
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
quesOption.setOptionBodyWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(quesOption.getOptionBody())));
|
|
|
} catch (Exception e) {
|
|
|
System.out.println("错误的选项:" + quesOption.getOptionBody());
|
|
|
+ throw new IllegalArgumentException("选项信息错误!");
|
|
|
}
|
|
|
if (question.getQuesAnswer().contains(String.valueOf(k + 1))) {
|
|
|
quesOption.setIsCorrect((short) 1);
|
|
@@ -445,7 +454,11 @@ public class CqdxService {
|
|
|
subQuestion.setDifficultyDegree(0.5);
|
|
|
subQuestion.setPublicity(true);
|
|
|
subQuestion.setScore(score);
|
|
|
- subQuestion.setQuesBody(imgList(subQuesTmp.getBody()));
|
|
|
+
|
|
|
+ String subBody = imgList(subQuesTmp.getBody());
|
|
|
+ question.setQuesBody(replaceBlank(body));
|
|
|
+ subQuestion.setQuesBody(subBody);
|
|
|
+
|
|
|
subQuestion.setQuesBodyWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(subQuestion.getQuesBody())));
|
|
|
subQuestion.setQuesAnswer(imgList(subQuesTmp.getAnswer()));
|
|
|
subQuestion.setQuesBodyWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(subQuestion.getQuesAnswer())));
|
|
@@ -458,7 +471,14 @@ public class CqdxService {
|
|
|
for (int k = 0; k < subOptionCount; k++) {
|
|
|
QuesOption subQuesOption = new QuesOption();
|
|
|
subQuesOption.setNumber(String.valueOf(k));
|
|
|
- subQuesOption.setOptionBody(imgList((String) subOptionMap.get(String.valueOf(k + 1))));
|
|
|
+
|
|
|
+ String optionBody = imgList((String) subOptionMap.get(String.valueOf(k + 1)));
|
|
|
+ if (optionBody.startsWith("<p><p") || optionBody.startsWith("<P><P")) {
|
|
|
+ subQuesOption.setOptionBody(replaceFirstP(optionBody));
|
|
|
+ } else {
|
|
|
+ subQuesOption.setOptionBody(optionBody);
|
|
|
+ }
|
|
|
+
|
|
|
subQuesOption.setOptionBodyWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(subQuesOption.getOptionBody())));
|
|
|
if (subQuestion.getQuesAnswer().contains(String.valueOf(k + 1))) {
|
|
|
subQuesOption.setIsCorrect((short) 1);
|
|
@@ -628,4 +648,33 @@ public class CqdxService {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+ /**
|
|
|
+ * 将[BLANK] 替换为 ###
|
|
|
+ */
|
|
|
+ public static String replaceBlank(String str) {
|
|
|
+ if (str == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return str.replace("[BLANK]", "###");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 替换首个P标签
|
|
|
+ */
|
|
|
+ public static String replaceFirstP(String str) {
|
|
|
+ if (str == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (str.startsWith("<p>") && str.endsWith("</p>")) {
|
|
|
+ //去掉头<p >
|
|
|
+ str = str.replaceFirst("<p>", "");
|
|
|
+ //去掉尾</p>
|
|
|
+ int index = str.lastIndexOf("</p>");
|
|
|
+ if (index > 0) {
|
|
|
+ str = str.substring(0, index);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return str;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|