|
@@ -980,31 +980,82 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
|
//5.获取大题下面的小题,并循环
|
|
|
List<PaperDetailUnitDto> paperDetailUnitDtos = paperDetailDto.getPaperDetailUnits();
|
|
|
for(PaperDetailUnitDto paperDetailUnitDto:paperDetailUnitDtos){
|
|
|
- //6.判断是否非套题
|
|
|
+ //定义题干
|
|
|
+ String body = "";
|
|
|
+ //定义选项
|
|
|
+ String option = "";
|
|
|
+ //定义答案
|
|
|
+ String answer = "";
|
|
|
+ //6.如果为单选和多选
|
|
|
+ if(paperDetailUnitDto.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION || paperDetailUnitDto.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION){
|
|
|
+ //获取选项
|
|
|
+ List<QuesOptionDto> quesOptionDtos = paperDetailUnitDto.getQuesOptions();
|
|
|
+ //添加题干
|
|
|
+ body = startWithP(paperDetailUnitDto.getQuesBody(), paperDetailUnitDto.getNumber());
|
|
|
+ answerHtml.append(body);
|
|
|
+ //添加选项
|
|
|
+ for(QuesOptionDto quesOptionDto:quesOptionDtos){
|
|
|
+ option = startWithP(quesOptionDto.getOptionBody(),Integer.parseInt(quesOptionDto.getNumber()));
|
|
|
+ answerHtml.append(option);
|
|
|
+ }
|
|
|
+ answer = startWithP(paperDetailUnitDto.getAnswer(), -1);
|
|
|
+ answerHtml.append(answer);
|
|
|
+ }
|
|
|
+ //7.如果为套题
|
|
|
if(paperDetailUnitDto.getSubQuestions()!=null && paperDetailUnitDto.getSubQuestions().size()>0){
|
|
|
List<SubQuestionDto> subQuestionDtos = paperDetailUnitDto.getSubQuestions();
|
|
|
for(SubQuestionDto subQuestionDto:subQuestionDtos){
|
|
|
- String answer = "";
|
|
|
- //判断答案是否以P标签开头
|
|
|
- if(subQuestionDto.getQuesAnswer().startsWith("<p>")){
|
|
|
- answer = subQuestionDto.getQuesAnswer().replaceAll("<p>","<p style=\"margin-left:40px;\">").replaceFirst("<p style=\"margin-left:40px;\">", "<p style=\"margin-left:20px;\">" + subQuestionDto.getNumber() + ".");
|
|
|
- }else{
|
|
|
- answer = "<p style=\"margin-left:20px;\">" + subQuestionDto.getNumber() + "." + subQuestionDto.getQuesAnswer() + "</p>";
|
|
|
+ //如果子题为单选或者多选
|
|
|
+ if(subQuestionDto.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION || subQuestionDto.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION){
|
|
|
+ //获取选项
|
|
|
+ List<QuesOptionDto> quesOptionDtos = subQuestionDto.getQuesOptions();
|
|
|
+ //添加题干
|
|
|
+ body = startWithP(subQuestionDto.getQuesBody(), subQuestionDto.getNumber());
|
|
|
+ answerHtml.append(body);
|
|
|
+ //添加选项
|
|
|
+ for(QuesOptionDto quesOptionDto:quesOptionDtos){
|
|
|
+ option = startWithP(quesOptionDto.getOptionBody(),Integer.parseInt(quesOptionDto.getNumber()));
|
|
|
+ answerHtml.append(option);
|
|
|
+ }
|
|
|
+ answer = startWithP(subQuestionDto.getQuesAnswer(), -1);
|
|
|
+ answerHtml.append(answer);
|
|
|
+ }else {
|
|
|
+ //添加题干
|
|
|
+ body = startWithP(subQuestionDto.getQuesBody(), subQuestionDto.getNumber());
|
|
|
+ answerHtml.append(body);
|
|
|
+ //添加答案
|
|
|
+ answer = startWithP(subQuestionDto.getQuesAnswer(), -1);
|
|
|
+ answerHtml.append(answer);
|
|
|
}
|
|
|
- answerHtml.append(answer);
|
|
|
}
|
|
|
}else{
|
|
|
- String answer = "";
|
|
|
- if(paperDetailUnitDto.getAnswer().startsWith("<p>")){
|
|
|
- answer = paperDetailUnitDto.getAnswer().replaceAll("<p>","<p style=\"margin-left:40px;\">").replaceFirst("<p style=\"margin-left:40px;\">", "<p style=\"margin-left:20px;\">" + paperDetailUnitDto.getNumber() + ".");
|
|
|
- }else{
|
|
|
- answer = "<p style=\"margin-left:20px;\">" + paperDetailUnitDto.getNumber() + "." + paperDetailUnitDto.getAnswer() + "</p>";
|
|
|
- }
|
|
|
+ //添加题干
|
|
|
+ body = startWithP(paperDetailUnitDto.getQuesBody(), paperDetailUnitDto.getNumber());
|
|
|
+ answerHtml.append(body);
|
|
|
+ //添加答案
|
|
|
+ answer = startWithP(paperDetailUnitDto.getAnswer(), -1);
|
|
|
answerHtml.append(answer);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return answerHtml.toString();
|
|
|
}
|
|
|
+
|
|
|
+ public String startWithP(String s,Integer number){
|
|
|
+ if(number == -1){
|
|
|
+ if(s.startsWith("<p>")){
|
|
|
+ s = s.replaceAll("<p>","<p style=\"margin-left:40px;\">").replaceFirst("<p style=\"margin-left:40px;\">", "<p style=\"margin-left:20px;\">" + "答案:");
|
|
|
+ }else{
|
|
|
+ s = "<p style=\"margin-left:20px;\">" + "答案:" + s + "</p>";
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if(s.startsWith("<p>")){
|
|
|
+ s = s.replaceAll("<p>","<p style=\"margin-left:40px;\">").replaceFirst("<p style=\"margin-left:40px;\">", "<p style=\"margin-left:20px;\">" + number + ".");
|
|
|
+ }else{
|
|
|
+ s = "<p style=\"margin-left:20px;\">" + number + "." + s + "</p>";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return s;
|
|
|
+ }
|
|
|
|
|
|
}
|