|
@@ -1,12 +1,11 @@
|
|
|
package edu.math.diagnosis.word;
|
|
|
|
|
|
-import edu.math.diagnosis.entity.PaperTemplate;
|
|
|
-import edu.math.diagnosis.entity.Question;
|
|
|
-import edu.math.diagnosis.entity.QuestionOption;
|
|
|
+import edu.math.diagnosis.entity.*;
|
|
|
import edu.math.diagnosis.service.FileService;
|
|
|
import edu.math.diagnosis.service.LocalFileService;
|
|
|
import edu.math.diagnosis.util.CommonUtil;
|
|
|
import edu.math.diagnosis.model.Constants;
|
|
|
+import edu.math.diagnosis.util.ObjectUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.xwpf.usermodel.*;
|
|
|
import org.apache.xmlbeans.XmlCursor;
|
|
@@ -61,24 +60,25 @@ public class WordService {
|
|
|
return question;
|
|
|
}
|
|
|
|
|
|
- public Question parseQuestion(Question q, List<XWPFParagraph> ps, Map<String, String> topic, PaperTemplate template) {
|
|
|
+ public Question parseQuestion(Question q, List<XWPFParagraph> ps, Map<String, String> topic, PaperTemplate template, List<String> abilities) {
|
|
|
logger.info("parsing question,pid={},section={},number={}", q.getPid(), q.getSection(), q.getNumber());
|
|
|
Map<String, List<XWPFParagraph>> group = initGroup(ps, topic, template);
|
|
|
|
|
|
parseQuestion(q, group.get(topic.get(Constants.TOPIC_QUESTION)), template.getOptionPattern());
|
|
|
parseAnswer(q, group.get(topic.get(Constants.TOPIC_ANSWER)));
|
|
|
parseTag(q, group.get(topic.get(Constants.TOPIC_TAG)));
|
|
|
- parseAbility(q, group.get(topic.get(Constants.TOPIC_ABILITY)));
|
|
|
+ parseAbility(q, group.get(topic.get(Constants.TOPIC_ABILITY)),abilities);
|
|
|
logger.info("parse question finish,pid={},section={},number={}", q.getPid(), q.getSection(), q.getNumber());
|
|
|
return q;
|
|
|
}
|
|
|
|
|
|
private void parseQuestion(Question q, Map<String, List<XWPFParagraph>> group) {
|
|
|
logger.info("parsing question,pid={},section={},number={}", q.getPid(), q.getSection(), q.getNumber());
|
|
|
+ String[] a = {"A1","A2","A3","A4","A5"};
|
|
|
parseQuestion(q, group.get(Constants.TOPIC_QUESTION), "^[A-Z]\\.(.*)");
|
|
|
parseAnswer(q, group.get(Constants.TOPIC_ANSWER));
|
|
|
parseTag(q, group.get(Constants.TOPIC_TAG));
|
|
|
- parseAbility(q, group.get(Constants.TOPIC_ABILITY));
|
|
|
+ parseAbility(q, group.get(Constants.TOPIC_ABILITY),Arrays.asList(a));
|
|
|
parseCollect(q, group.get(Constants.TOPIC_EVALUATE_CORRECT));
|
|
|
parseWrong(q, group.get(Constants.TOPIC_EVALUATE_WRONG));
|
|
|
logger.info("parse question finish,pid={},section={},number={}", q.getPid(), q.getSection(), q.getNumber());
|
|
@@ -132,7 +132,7 @@ public class WordService {
|
|
|
o.setCorrect(true);
|
|
|
}
|
|
|
});
|
|
|
- question.setAns(text);
|
|
|
+ question.setAnswer(text);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -140,24 +140,39 @@ public class WordService {
|
|
|
ps.stream().filter(p -> StringUtils.isNotBlank(p.getText())).forEach(p -> question.setTag(p.getText()));
|
|
|
}
|
|
|
|
|
|
- private void parseAbility(Question question, List<XWPFParagraph> ps) {
|
|
|
+ private void parseAbility(Question question, List<XWPFParagraph> ps,List<String> abilities) {
|
|
|
+ List<AbilityScore> list = new ArrayList<>();
|
|
|
+ Map<String,Double> json = new HashMap<>();
|
|
|
+
|
|
|
+ json.put("A0",1d);
|
|
|
+ AbilityScore a0 = new AbilityScore("A0","","",question.getPid(),0L,0d);
|
|
|
+ list.add(a0);
|
|
|
for (XWPFParagraph p : ps) {
|
|
|
String text = p.getText();
|
|
|
- double score = Integer.parseInt(text.substring(text.indexOf("=") + 1));
|
|
|
- if (text.contains(Constants.TOPIC_ABILITY_CALC)) {
|
|
|
- question.setCalculation(score);
|
|
|
- } else if (text.contains(Constants.TOPIC_ABILITY_INTRO)) {
|
|
|
- question.setInduction(score);
|
|
|
- } else if (text.contains(Constants.TOPIC_ABILITY_LOGIC)) {
|
|
|
- question.setLogic(score);
|
|
|
- } else if (text.contains(Constants.TOPIC_ABILITY_SPACE)) {
|
|
|
- question.setSpace(score);
|
|
|
- } else if (text.contains(Constants.TOPIC_ABILITY_LANGUAGE)) {
|
|
|
- question.setLanguage(score);
|
|
|
- } else if (text.contains(Constants.TOPIC_ABILITY_CONVERSION)) {
|
|
|
- question.setConversion(score);
|
|
|
- }
|
|
|
+ String[] ss = text.split("=");
|
|
|
+ String abilityCode = ss[0];
|
|
|
+ double score = Double.parseDouble(ss[1]);
|
|
|
+ AbilityScore s = new AbilityScore(abilityCode,"","",question.getPid(),0L,score);
|
|
|
+ list.add(s);
|
|
|
+ json.put(abilityCode,score);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
+ question.setJsonScore(ObjectUtil.object2Json(json));
|
|
|
+ question.setScores(list);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void parseCollect(Question question, List<XWPFParagraph> ps) {
|