Parcourir la source

阅卷端接口修改3

weiwenhai il y a 7 ans
Parent
commit
02790fde35

+ 26 - 17
cqb-paper/src/main/java/com/qmth/cqb/paper/service/impl/ExtractConfigServiceImpl.java

@@ -994,20 +994,21 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
 					//获取选项
 					List<QuesOptionDto> quesOptionDtos = paperDetailUnitDto.getQuesOptions();
 					//添加题干
-					body = startWithP(paperDetailUnitDto.getQuesBody(), paperDetailUnitDto.getNumber());
+					body = startWithP(paperDetailUnitDto.getQuesBody(), paperDetailUnitDto.getNumber(),false);
 					answerHtml.append(body);
 					//添加选项
 					for(QuesOptionDto quesOptionDto:quesOptionDtos){
-						option = startWithP(quesOptionDto.getOptionBody(),Integer.parseInt(quesOptionDto.getNumber()));
+						option = startWithP(quesOptionDto.getOptionBody(),Integer.parseInt(quesOptionDto.getNumber()),true);
 						answerHtml.append(option);
 					}
-					answer = startWithP(paperDetailUnitDto.getAnswer(), -1);
+					answer = startWithP(paperDetailUnitDto.getAnswer(), -1,false);
 					answerHtml.append(answer);
 				}
 				//7.如果为套题
 				else if(paperDetailUnitDto.getSubQuestions()!=null && paperDetailUnitDto.getSubQuestions().size()>0){
 					//添加主题干
-					String BigBody = startWithP(paperDetailUnitDto.getQuesBody(),-1);
+					String BigBody = startWithP(paperDetailUnitDto.getQuesBody(),-1,false);
+					answerHtml.append(BigBody);
 					List<SubQuestionDto> subQuestionDtos = paperDetailUnitDto.getSubQuestions();
 					for(SubQuestionDto subQuestionDto:subQuestionDtos){
 						//如果子题为单选或者多选
@@ -1015,30 +1016,30 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
 							//获取选项
 							List<QuesOptionDto> quesOptionDtos = subQuestionDto.getQuesOptions();
 							//添加题干
-							body = startWithP(subQuestionDto.getQuesBody(), subQuestionDto.getNumber());
+							body = startWithP(subQuestionDto.getQuesBody(), subQuestionDto.getNumber(),false);
 							answerHtml.append(body);
 							//添加选项
 							for(QuesOptionDto quesOptionDto:quesOptionDtos){
-								option = startWithP(quesOptionDto.getOptionBody(),Integer.parseInt(quesOptionDto.getNumber()));
+								option = startWithP(quesOptionDto.getOptionBody(),Integer.parseInt(quesOptionDto.getNumber()),true);
 								answerHtml.append(option);
 							}
-							answer = startWithP(subQuestionDto.getQuesAnswer(), -1);
+							answer = startWithP(subQuestionDto.getQuesAnswer(), -1,false);
 							answerHtml.append(answer);
 						}else {
 							//添加题干
-							body = startWithP(subQuestionDto.getQuesBody(), subQuestionDto.getNumber());
+							body = startWithP(subQuestionDto.getQuesBody(), subQuestionDto.getNumber(),false);
 							answerHtml.append(body);
 							//添加答案
-							answer = startWithP(subQuestionDto.getQuesAnswer(), -1);
+							answer = startWithP(subQuestionDto.getQuesAnswer(), -1,false);
 							answerHtml.append(answer);
 						}
 					}
 				}else{
 					//添加题干
-					body = startWithP(paperDetailUnitDto.getQuesBody(), paperDetailUnitDto.getNumber());
+					body = startWithP(paperDetailUnitDto.getQuesBody(), paperDetailUnitDto.getNumber(),false);
 					answerHtml.append(body);
 					//添加答案
-					answer = startWithP(paperDetailUnitDto.getAnswer(), -1);
+					answer = startWithP(paperDetailUnitDto.getAnswer(), -1,false);
 					answerHtml.append(answer);
 				}
 			}
@@ -1046,18 +1047,26 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
 		return answerHtml.toString();
 	}
 	
-	public String startWithP(String s,Integer number){
+	public String startWithP(String s,Integer number,boolean option){
 		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;backgroud-color:red;\">" +  "答案:" + s + "</p>";
+				s = "<p style=\"margin-left:20px;color:red;\">" +  "答案:" + 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;\">" + CommonUtils.getOptionNum(number) + ".");
-			}else{
-				s = "<p style=\"margin-left:20px;\">" + CommonUtils.getOptionNum(number) + "." + s + "</p>";
+			if(option){
+				if(s.startsWith("<p>")){
+					s = s.replaceAll("<p>","<p style=\"margin-left:40px;\">").replaceFirst("<p style=\"margin-left:40px;\">", "<p style=\"margin-left:20px;\">" + CommonUtils.getOptionNum(number) + ".");
+				}else{
+					s = "<p style=\"margin-left:20px;\">" + number + "." + 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;\">" + CommonUtils.getOptionNum(number) + ".");
+				}else{
+					s = "<p style=\"margin-left:20px;\">" + number + "." + s + "</p>";
+				}
 			}
 		}
 		return s;