|
@@ -10,6 +10,7 @@ import java.util.Random;
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.nlpcn.commons.lang.util.StringUtil;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -32,6 +33,7 @@ import com.qmth.cqb.paper.dao.ExtractConfigRepo;
|
|
import com.qmth.cqb.paper.dao.PaperDetailRepo;
|
|
import com.qmth.cqb.paper.dao.PaperDetailRepo;
|
|
import com.qmth.cqb.paper.dao.PaperDetailUnitRepo;
|
|
import com.qmth.cqb.paper.dao.PaperDetailUnitRepo;
|
|
import com.qmth.cqb.paper.dao.PaperRepo;
|
|
import com.qmth.cqb.paper.dao.PaperRepo;
|
|
|
|
+import com.qmth.cqb.paper.dto.PaperDetailUnitExp;
|
|
import com.qmth.cqb.paper.model.ExamPaper;
|
|
import com.qmth.cqb.paper.model.ExamPaper;
|
|
import com.qmth.cqb.paper.model.ExtractConfig;
|
|
import com.qmth.cqb.paper.model.ExtractConfig;
|
|
import com.qmth.cqb.paper.model.Paper;
|
|
import com.qmth.cqb.paper.model.Paper;
|
|
@@ -370,26 +372,28 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
List<PaperDetailUnit> paperDetailUnits = paperDetailUnitRepo.findByPaperDetail(paperDetails.get(i));
|
|
List<PaperDetailUnit> paperDetailUnits = paperDetailUnitRepo.findByPaperDetail(paperDetails.get(i));
|
|
//设置答案
|
|
//设置答案
|
|
setAnswer(paperDetailUnits);
|
|
setAnswer(paperDetailUnits);
|
|
- List<PaperDetailUnitDto> paperDetailUnitDtos = BeanCopierUtil.copyPropertiesOfList(paperDetailUnits,
|
|
|
|
- PaperDetailUnitDto.class);
|
|
|
|
|
|
+ List<PaperDetailUnitDto> paperDetailUnitDtos = BeanCopierUtil.copyPropertiesOfList(paperDetailUnits,PaperDetailUnitDto.class);
|
|
for (int j = 0; j < paperDetailUnitDtos.size(); j++) {
|
|
for (int j = 0; j < paperDetailUnitDtos.size(); j++) {
|
|
PaperDetailUnit paperDetailUnit = paperDetailUnits.get(j);
|
|
PaperDetailUnit paperDetailUnit = paperDetailUnits.get(j);
|
|
if(paperDetailUnit==null||paperDetailUnit.getQuestion()==null){
|
|
if(paperDetailUnit==null||paperDetailUnit.getQuestion()==null){
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
PaperDetailUnitDto unitDto = paperDetailUnitDtos.get(j);
|
|
PaperDetailUnitDto unitDto = paperDetailUnitDtos.get(j);
|
|
- unitDto.setQuesId(paperDetailUnit.getQuestion().getId());
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 此处不能传questionId,需要传paperDetailUnitId
|
|
|
|
+ * 因为选项乱序在paperDetailUnit里
|
|
|
|
+ * unitDto.setQuesId(paperDetailUnit.getQuestion().getId());
|
|
|
|
+ */
|
|
|
|
+ unitDto.setQuesId(paperDetailUnit.getId());
|
|
String answer = paperDetailUnit.getQuestion().getQuesAnswer();
|
|
String answer = paperDetailUnit.getQuestion().getQuesAnswer();
|
|
- if (StringUtils.isNotEmpty(answer)) {
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(answer)){
|
|
unitDto.setAnswer(answer);
|
|
unitDto.setAnswer(answer);
|
|
}
|
|
}
|
|
if (unitDto.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {// 假如是套题
|
|
if (unitDto.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {// 假如是套题
|
|
List<Question> subQuesList = paperDetailUnit.getQuestion().getSubQuestions();
|
|
List<Question> subQuesList = paperDetailUnit.getQuestion().getSubQuestions();
|
|
- List<SubQuestionDto> subQuesDtos = BeanCopierUtil.copyPropertiesOfList(subQuesList,
|
|
|
|
- SubQuestionDto.class);
|
|
|
|
|
|
+ List<SubQuestionDto> subQuesDtos = BeanCopierUtil.copyPropertiesOfList(subQuesList,SubQuestionDto.class);
|
|
for (int m = 0; m < subQuesList.size(); m++) {
|
|
for (int m = 0; m < subQuesList.size(); m++) {
|
|
- List<QuesOptionDto> quesOptionDtos = BeanCopierUtil
|
|
|
|
- .copyPropertiesOfList(subQuesList.get(m).getQuesOptions(), QuesOptionDto.class);
|
|
|
|
|
|
+ List<QuesOptionDto> quesOptionDtos = BeanCopierUtil.copyPropertiesOfList(subQuesList.get(m).getQuesOptions(), QuesOptionDto.class);
|
|
subQuesDtos.get(m).setQuesOptions(quesOptionDtos);
|
|
subQuesDtos.get(m).setQuesOptions(quesOptionDtos);
|
|
if(StringUtils.isNotEmpty(subQuesList.get(m).getQuesAnswer())){
|
|
if(StringUtils.isNotEmpty(subQuesList.get(m).getQuesAnswer())){
|
|
subQuesDtos.get(m).setQuesAnswer(subQuesList.get(m).getQuesAnswer());
|
|
subQuesDtos.get(m).setQuesAnswer(subQuesList.get(m).getQuesAnswer());
|
|
@@ -459,10 +463,13 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Map<String, Object> getQuestionById(String id) {
|
|
|
|
|
|
+ public Map<String, Object> getQuestionById(String paperDetailUnitId) {
|
|
String msg = "";
|
|
String msg = "";
|
|
Map<String, Object> quesMap = new HashMap<String, Object>();
|
|
Map<String, Object> quesMap = new HashMap<String, Object>();
|
|
- Question ques = quesRepo.findOne(id);
|
|
|
|
|
|
+ PaperDetailUnit paperDetailUnit = paperDetailUnitRepo.findOne(paperDetailUnitId);
|
|
|
|
+ //重新对选择题option进行排序(多选、单选、套题下选择题)
|
|
|
|
+ reorderChoicequestionOption(paperDetailUnit);
|
|
|
|
+ Question ques = paperDetailUnit.getQuestion();
|
|
QuestionDto dto = BeanCopierUtil.copyProperties(ques, QuestionDto.class);
|
|
QuestionDto dto = BeanCopierUtil.copyProperties(ques, QuestionDto.class);
|
|
if (ques.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
|
|
if (ques.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
|
|
List<Question> subQuesList = ques.getSubQuestions();
|
|
List<Question> subQuesList = ques.getSubQuestions();
|
|
@@ -480,5 +487,91 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
quesMap.put("quesDto", dto);
|
|
quesMap.put("quesDto", dto);
|
|
quesMap.put("msg", msg);
|
|
quesMap.put("msg", msg);
|
|
return quesMap;
|
|
return quesMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 重新对选择题option进行排序(多选、单选、套题下选择题)
|
|
|
|
+ */
|
|
|
|
+ private void reorderChoicequestionOption(PaperDetailUnit paperDetailUnit) {
|
|
|
|
+ String optionOrder = paperDetailUnit.getOptionOrder();
|
|
|
|
+ if (StringUtil.isNotBlank(optionOrder)) {
|
|
|
|
+ Question question = paperDetailUnit.getQuestion();
|
|
|
|
+ if (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
|
|
|
|
+ || question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
|
|
|
|
+ question.setQuesOptions(reorderOptionCore(question.getQuesOptions(), optionOrder));
|
|
|
|
+ //设置选择题答案 暂不需要
|
|
|
|
+ //setChoiceQuestionAnswer(question);
|
|
|
|
+ }
|
|
|
|
+ if (question.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
|
|
|
|
+ List<Question> subQuestions = question.getSubQuestions();
|
|
|
|
+ int index = 0;
|
|
|
|
+ for (int k = 0; k < subQuestions.size(); k++) {
|
|
|
|
+ Question subQuestion = subQuestions.get(k);
|
|
|
|
+ if (subQuestion.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
|
|
|
|
+ || subQuestion.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
|
|
|
|
+ subQuestion.setQuesOptions(reorderOptionCore(subQuestion.getQuesOptions(), optionOrder.split(";")[index]));
|
|
|
|
+ index++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ /*
|
|
|
|
+ * //设置套题中选择题答案 暂不需要
|
|
|
|
+ for (int m = 0; m < subQuestions.size(); m++) {
|
|
|
|
+ Question subQuestion = subQuestions.get(m);
|
|
|
|
+ setChoiceQuestionAnswer(subQuestion);
|
|
|
|
+ }
|
|
|
|
+ */
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 对option排序
|
|
|
|
+ * @param quesOptions
|
|
|
|
+ * @param optionOrder
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private List<QuesOption> reorderOptionCore(List<QuesOption> quesOptions, String optionOrder) {
|
|
|
|
+ List<QuesOption> newQuesOptions = new ArrayList<QuesOption>();
|
|
|
|
+ if (StringUtil.isBlank(optionOrder) || quesOptions.isEmpty()) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ String[] optionOrderArr = optionOrder.split(",");
|
|
|
|
+ for (int j = 0; j < optionOrderArr.length; j++) {
|
|
|
|
+ for (int k = 0; k < quesOptions.size(); k++) {
|
|
|
|
+ if (optionOrderArr[j].equals(quesOptions.get(k).getNumber())) {
|
|
|
|
+ newQuesOptions.add(quesOptions.get(k));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ quesOptions = null;
|
|
|
|
+ return newQuesOptions;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 设置选择题答案
|
|
|
|
+ * @param question
|
|
|
|
+ */
|
|
|
|
+ private void setChoiceQuestionAnswer(Question question){
|
|
|
|
+ if (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION) {
|
|
|
|
+ for(int i = 0;i<question.getQuesOptions().size();i++){
|
|
|
|
+ QuesOption option = question.getQuesOptions().get(i);
|
|
|
|
+ if(option.getIsCorrect()==1){
|
|
|
|
+ char answer = (char)(i+65);
|
|
|
|
+ question.setQuesAnswer(String.valueOf(answer));
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION){
|
|
|
|
+ String[] answerArray = {};
|
|
|
|
+ for(int i = 0;i<question.getQuesOptions().size();i++){
|
|
|
|
+ QuesOption option = question.getQuesOptions().get(i);
|
|
|
|
+ if(option.getIsCorrect()==1){
|
|
|
|
+ char answer = (char)(i+65);
|
|
|
|
+ answerArray[i] = String.valueOf(answer);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ question.setQuesAnswer(StringUtils.join(answerArray,","));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|