|
@@ -53,7 +53,9 @@ import java.util.regex.Pattern;
|
|
*/
|
|
*/
|
|
@Service("quesService")
|
|
@Service("quesService")
|
|
public class QuesServiceImpl implements QuesService {
|
|
public class QuesServiceImpl implements QuesService {
|
|
|
|
+
|
|
private static final Logger log = LoggerFactory.getLogger(QuesServiceImpl.class);
|
|
private static final Logger log = LoggerFactory.getLogger(QuesServiceImpl.class);
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private QuesRepo quesRepo;
|
|
private QuesRepo quesRepo;
|
|
|
|
|
|
@@ -109,59 +111,39 @@ public class QuesServiceImpl implements QuesService {
|
|
* @param previous
|
|
* @param previous
|
|
* @param update
|
|
* @param update
|
|
*/
|
|
*/
|
|
- /*private void updateMainInfo(Question previous, Question update) {
|
|
|
|
- String now = CommonUtils.getCurDateTime();
|
|
|
|
- if (update.getScore() != null) {
|
|
|
|
- previous.setScore(update.getScore());
|
|
|
|
- }
|
|
|
|
- previous.setQuesAnswer(update.getQuesAnswer());
|
|
|
|
- previous.setQuesAnswerAnalysis(update.getQuesAnswerAnalysis());
|
|
|
|
- previous.setQuesBody(update.getQuesBody());
|
|
|
|
- if (update.getQuesOptions() != null && update.getQuesOptions().size() > 0) {
|
|
|
|
- List<QuesOption> quesOptions = update.getQuesOptions();
|
|
|
|
- List<QuesOption> saveQuesOptions = previous.getQuesOptions();
|
|
|
|
- if (saveQuesOptions.size() != quesOptions.size()) {
|
|
|
|
- previous.setQuesOptions(quesOptions);
|
|
|
|
- } else {
|
|
|
|
- for (int i = 0; i < quesOptions.size(); i++) {
|
|
|
|
- saveQuesOptions.get(i).setOptionBody(quesOptions.get(i).getOptionBody());
|
|
|
|
- // 设置正确答案(chenken-2017.4.24)
|
|
|
|
- saveQuesOptions.get(i).setIsCorrect(quesOptions.get(i).getIsCorrect());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (update.getQuesParams() != null) {
|
|
|
|
- if (previous.getQuesParams() == null) {
|
|
|
|
- previous.setQuesParams(new HashMap<>());
|
|
|
|
- }
|
|
|
|
- for (String key : update.getQuesParams().keySet()) {
|
|
|
|
- previous.getQuesParams().put(key, update.getQuesParams().get(key));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (previous.getCreateTime() == null) {
|
|
|
|
- previous.setCreateTime(now);
|
|
|
|
- }
|
|
|
|
- if (update.getSubQuestions() != null) {
|
|
|
|
- if (previous.getSubQuestions() == null) {
|
|
|
|
- previous.setSubQuestions(new ArrayList<>());
|
|
|
|
- }
|
|
|
|
- int previousSize = previous.getSubQuestions().size();
|
|
|
|
- int updateSize = update.getSubQuestions().size();
|
|
|
|
- for (int i = 0; i < updateSize; i++) {
|
|
|
|
- if (previousSize <= i) {
|
|
|
|
- previous.getSubQuestions().add(update.getSubQuestions().get(i));
|
|
|
|
- } else {
|
|
|
|
- updateMainInfo(previous.getSubQuestions().get(i), update.getSubQuestions().get(i));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- previous.setUpdateTime(now);
|
|
|
|
- updateSubId(previous);
|
|
|
|
- }*/
|
|
|
|
|
|
+ /*
|
|
|
|
+ * private void updateMainInfo(Question previous, Question update) { String
|
|
|
|
+ * now = CommonUtils.getCurDateTime(); if (update.getScore() != null) {
|
|
|
|
+ * previous.setScore(update.getScore()); }
|
|
|
|
+ * previous.setQuesAnswer(update.getQuesAnswer());
|
|
|
|
+ * previous.setQuesAnswerAnalysis(update.getQuesAnswerAnalysis());
|
|
|
|
+ * previous.setQuesBody(update.getQuesBody()); if (update.getQuesOptions()
|
|
|
|
+ * != null && update.getQuesOptions().size() > 0) { List<QuesOption>
|
|
|
|
+ * quesOptions = update.getQuesOptions(); List<QuesOption> saveQuesOptions =
|
|
|
|
+ * previous.getQuesOptions(); if (saveQuesOptions.size() !=
|
|
|
|
+ * quesOptions.size()) { previous.setQuesOptions(quesOptions); } else { for
|
|
|
|
+ * (int i = 0; i < quesOptions.size(); i++) {
|
|
|
|
+ * saveQuesOptions.get(i).setOptionBody(quesOptions.get(i).getOptionBody());
|
|
|
|
+ * // 设置正确答案(chenken-2017.4.24)
|
|
|
|
+ * saveQuesOptions.get(i).setIsCorrect(quesOptions.get(i).getIsCorrect()); }
|
|
|
|
+ * } } if (update.getQuesParams() != null) { if (previous.getQuesParams() ==
|
|
|
|
+ * null) { previous.setQuesParams(new HashMap<>()); } for (String key :
|
|
|
|
+ * update.getQuesParams().keySet()) { previous.getQuesParams().put(key,
|
|
|
|
+ * update.getQuesParams().get(key)); } } if (previous.getCreateTime() ==
|
|
|
|
+ * null) { previous.setCreateTime(now); } if (update.getSubQuestions() !=
|
|
|
|
+ * null) { if (previous.getSubQuestions() == null) {
|
|
|
|
+ * previous.setSubQuestions(new ArrayList<>()); } int previousSize =
|
|
|
|
+ * previous.getSubQuestions().size(); int updateSize =
|
|
|
|
+ * update.getSubQuestions().size(); for (int i = 0; i < updateSize; i++) {
|
|
|
|
+ * if (previousSize <= i) {
|
|
|
|
+ * previous.getSubQuestions().add(update.getSubQuestions().get(i)); } else {
|
|
|
|
+ * updateMainInfo(previous.getSubQuestions().get(i),
|
|
|
|
+ * update.getSubQuestions().get(i)); } } } previous.setUpdateTime(now);
|
|
|
|
+ * updateSubId(previous); }
|
|
|
|
+ */
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 保存试题,用于页面新增和更新
|
|
|
|
- * 导入时不能调用该方法,里面有更新Word的代码
|
|
|
|
|
|
+ * 保存试题,用于页面新增和更新 导入时不能调用该方法,里面有更新Word的代码
|
|
*
|
|
*
|
|
* @param question
|
|
* @param question
|
|
*/
|
|
*/
|
|
@@ -180,12 +162,12 @@ public class QuesServiceImpl implements QuesService {
|
|
} else {
|
|
} else {
|
|
question.setUpdateTime(now);
|
|
question.setUpdateTime(now);
|
|
}
|
|
}
|
|
- //跟新音频文件,以及音频文件排序
|
|
|
|
|
|
+ // 跟新音频文件,以及音频文件排序
|
|
if (question.getHasAudio() != null && question.getHasAudio()) {
|
|
if (question.getHasAudio() != null && question.getHasAudio()) {
|
|
questionAudioService.deleteAudioNotInQuestion(question);
|
|
questionAudioService.deleteAudioNotInQuestion(question);
|
|
- //给音频重新排序
|
|
|
|
|
|
+ // 给音频重新排序
|
|
questionAudioService.sortAudio(question);
|
|
questionAudioService.sortAudio(question);
|
|
- //如果根据questionId查询不出音频了,将hasAudio设置为false
|
|
|
|
|
|
+ // 如果根据questionId查询不出音频了,将hasAudio设置为false
|
|
List<QuestionAudio> questionAudios = questionAudioRepo.findByQuestionId(question.getId());
|
|
List<QuestionAudio> questionAudios = questionAudioRepo.findByQuestionId(question.getId());
|
|
if (questionAudios.size() == 0) {
|
|
if (questionAudios.size() == 0) {
|
|
question.setHasAudio(false);
|
|
question.setHasAudio(false);
|
|
@@ -194,7 +176,7 @@ public class QuesServiceImpl implements QuesService {
|
|
setSelectQuestionAnswer(question, "");
|
|
setSelectQuestionAnswer(question, "");
|
|
updateSubId(question);
|
|
updateSubId(question);
|
|
updateQuesWord(question);
|
|
updateQuesWord(question);
|
|
- //更新QuesBody,把 下划线 转成 ##
|
|
|
|
|
|
+ // 更新QuesBody,把 下划线 转成 ##
|
|
updateQuesBody(question);
|
|
updateQuesBody(question);
|
|
return quesRepo.save(question);
|
|
return quesRepo.save(question);
|
|
}
|
|
}
|
|
@@ -249,16 +231,19 @@ public class QuesServiceImpl implements QuesService {
|
|
}
|
|
}
|
|
|
|
|
|
if (searchCondition.getCoursePropertyName() != null) {
|
|
if (searchCondition.getCoursePropertyName() != null) {
|
|
- query.addCriteria(Criteria.where("quesProperties.coursePropertyName").is(searchCondition.getCoursePropertyName()));
|
|
|
|
|
|
+ query.addCriteria(
|
|
|
|
+ Criteria.where("quesProperties.coursePropertyName").is(searchCondition.getCoursePropertyName()));
|
|
}
|
|
}
|
|
|
|
|
|
- //二级属性不为空,那么一级属性也不为空
|
|
|
|
|
|
+ // 二级属性不为空,那么一级属性也不为空
|
|
if (StringUtils.isNotEmpty(searchCondition.getSecondPropertyId())) {
|
|
if (StringUtils.isNotEmpty(searchCondition.getSecondPropertyId())) {
|
|
- query.addCriteria(Criteria.where("quesProperties").elemMatch(
|
|
|
|
- Criteria.where("firstProperty.id").is(searchCondition.getFirstPropertyId()).and("secondProperty.id").is(searchCondition.getSecondPropertyId())));
|
|
|
|
|
|
+ query.addCriteria(Criteria.where("quesProperties")
|
|
|
|
+ .elemMatch(Criteria.where("firstProperty.id").is(searchCondition.getFirstPropertyId())
|
|
|
|
+ .and("secondProperty.id").is(searchCondition.getSecondPropertyId())));
|
|
} else {
|
|
} else {
|
|
if (searchCondition.getFirstPropertyId() != null) {
|
|
if (searchCondition.getFirstPropertyId() != null) {
|
|
- query.addCriteria(Criteria.where("quesProperties").elemMatch(Criteria.where("firstProperty.id").is(searchCondition.getFirstPropertyId())));
|
|
|
|
|
|
+ query.addCriteria(Criteria.where("quesProperties")
|
|
|
|
+ .elemMatch(Criteria.where("firstProperty.id").is(searchCondition.getFirstPropertyId())));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -315,7 +300,8 @@ public class QuesServiceImpl implements QuesService {
|
|
* @param pageSize
|
|
* @param pageSize
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public Page<Question> findByIdExclude(Set<String> idSet, String courseNo, QuesStructType quesType, int curPage, int pageSize, Long orgId, String quesBody) {
|
|
|
|
|
|
+ public Page<Question> findByIdExclude(Set<String> idSet, String courseNo, QuesStructType quesType, int curPage,
|
|
|
|
+ int pageSize, Long orgId, String quesBody) {
|
|
Query query = new Query();
|
|
Query query = new Query();
|
|
query.addCriteria(Criteria.where("orgId").is(orgId + ""));
|
|
query.addCriteria(Criteria.where("orgId").is(orgId + ""));
|
|
query.addCriteria(Criteria.where("course.enable").is("true"));
|
|
query.addCriteria(Criteria.where("course.enable").is("true"));
|
|
@@ -324,7 +310,7 @@ public class QuesServiceImpl implements QuesService {
|
|
}
|
|
}
|
|
query.addCriteria(Criteria.where("course.code").is(courseNo));
|
|
query.addCriteria(Criteria.where("course.code").is(courseNo));
|
|
query.addCriteria(Criteria.where("id").nin(idSet));
|
|
query.addCriteria(Criteria.where("id").nin(idSet));
|
|
- //模糊匹配
|
|
|
|
|
|
+ // 模糊匹配
|
|
if (StringUtils.isNotBlank(quesBody)) {
|
|
if (StringUtils.isNotBlank(quesBody)) {
|
|
Pattern pattern = Pattern.compile("^.*" + quesBody + ".*$", Pattern.CASE_INSENSITIVE);
|
|
Pattern pattern = Pattern.compile("^.*" + quesBody + ".*$", Pattern.CASE_INSENSITIVE);
|
|
query.addCriteria(Criteria.where("quesBody").regex(pattern));
|
|
query.addCriteria(Criteria.where("quesBody").regex(pattern));
|
|
@@ -334,7 +320,8 @@ public class QuesServiceImpl implements QuesService {
|
|
query.limit(pageSize);
|
|
query.limit(pageSize);
|
|
query.skip((curPage - 1L) * pageSize);
|
|
query.skip((curPage - 1L) * pageSize);
|
|
List<Question> questionList = this.mongoTemplate.find(query, Question.class);
|
|
List<Question> questionList = this.mongoTemplate.find(query, Question.class);
|
|
- Page<Question> questionPageList = new PageImpl<Question>(questionList, new PageRequest(curPage - 1, pageSize), total);
|
|
|
|
|
|
+ Page<Question> questionPageList = new PageImpl<Question>(questionList, new PageRequest(curPage - 1, pageSize),
|
|
|
|
+ total);
|
|
for (Question question : questionPageList) {
|
|
for (Question question : questionPageList) {
|
|
formatQues(question);
|
|
formatQues(question);
|
|
}
|
|
}
|
|
@@ -427,10 +414,10 @@ public class QuesServiceImpl implements QuesService {
|
|
StringBuffer pWordMl = new StringBuffer();
|
|
StringBuffer pWordMl = new StringBuffer();
|
|
question.setQuesBodyWord(reduceImage(quesBody, pWordMl, wordMLPackage));
|
|
question.setQuesBodyWord(reduceImage(quesBody, pWordMl, wordMLPackage));
|
|
}
|
|
}
|
|
- if (!StringUtils.isEmpty(quesAnswer)
|
|
|
|
- && (question.getQuestionType() == QuesStructType.FILL_BLANK_QUESTION
|
|
|
|
|
|
+ if (!StringUtils.isEmpty(quesAnswer) && (question.getQuestionType() == QuesStructType.FILL_BLANK_QUESTION
|
|
|| question.getQuestionType() == QuesStructType.TEXT_ANSWER_QUESTION)) {
|
|
|| question.getQuestionType() == QuesStructType.TEXT_ANSWER_QUESTION)) {
|
|
- //question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(quesAnswer)));
|
|
|
|
|
|
+ // question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage,
|
|
|
|
+ // CommonUtils.formatHtml(quesAnswer)));
|
|
StringBuffer pWordMl = new StringBuffer();
|
|
StringBuffer pWordMl = new StringBuffer();
|
|
question.setQuesAnswerWord(reduceImage(quesAnswer, pWordMl, wordMLPackage));
|
|
question.setQuesAnswerWord(reduceImage(quesAnswer, pWordMl, wordMLPackage));
|
|
}
|
|
}
|
|
@@ -438,9 +425,8 @@ public class QuesServiceImpl implements QuesService {
|
|
quesAnswer = "<p>" + quesAnswer + "</p>";
|
|
quesAnswer = "<p>" + quesAnswer + "</p>";
|
|
question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(quesAnswer)));
|
|
question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(quesAnswer)));
|
|
}
|
|
}
|
|
- if (!StringUtils.isEmpty(quesAnswer) &&
|
|
|
|
- (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
|
|
|
|
- || question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION)) {
|
|
|
|
|
|
+ if (!StringUtils.isEmpty(quesAnswer) && (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
|
|
|
|
+ || question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION)) {
|
|
question.setQuesAnswerWord(makeQuesAnswerWord(quesAnswer));
|
|
question.setQuesAnswerWord(makeQuesAnswerWord(quesAnswer));
|
|
}
|
|
}
|
|
List<QuesOption> quesOptions = question.getQuesOptions();
|
|
List<QuesOption> quesOptions = question.getQuesOptions();
|
|
@@ -450,14 +436,15 @@ public class QuesServiceImpl implements QuesService {
|
|
quesOption.setOptionBody("<p></p>");
|
|
quesOption.setOptionBody("<p></p>");
|
|
}
|
|
}
|
|
StringBuffer pWordMl = new StringBuffer();
|
|
StringBuffer pWordMl = new StringBuffer();
|
|
- //quesOption.setOptionBodyWord(DocxProcessUtil.html2Docx(wordMLPackage,CommonUtils.formatHtml(quesOption.getOptionBody())));
|
|
|
|
|
|
+ // quesOption.setOptionBodyWord(DocxProcessUtil.html2Docx(wordMLPackage,CommonUtils.formatHtml(quesOption.getOptionBody())));
|
|
quesOption.setOptionBodyWord(reduceImage(quesOption.getOptionBody(), pWordMl, wordMLPackage));
|
|
quesOption.setOptionBodyWord(reduceImage(quesOption.getOptionBody(), pWordMl, wordMLPackage));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //如果图片过大,改变图片大小
|
|
|
|
- private String reduceImage(String html, StringBuffer pWordMl, WordprocessingMLPackage wordMLPackage) throws Exception {
|
|
|
|
|
|
+ // 如果图片过大,改变图片大小
|
|
|
|
+ private String reduceImage(String html, StringBuffer pWordMl, WordprocessingMLPackage wordMLPackage)
|
|
|
|
+ throws Exception {
|
|
String bodyString = DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(html));
|
|
String bodyString = DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(html));
|
|
if (bodyString.indexOf("cx") > -1 || bodyString.indexOf("cy") > -1) {
|
|
if (bodyString.indexOf("cx") > -1 || bodyString.indexOf("cy") > -1) {
|
|
String tmpStr = DocxProcessUtil.BODY_HEADER + bodyString + DocxProcessUtil.BODY_TAIL;
|
|
String tmpStr = DocxProcessUtil.BODY_HEADER + bodyString + DocxProcessUtil.BODY_TAIL;
|
|
@@ -511,15 +498,9 @@ public class QuesServiceImpl implements QuesService {
|
|
}
|
|
}
|
|
|
|
|
|
private String makeQuesAnswerWord(String quesAnswer) {
|
|
private String makeQuesAnswerWord(String quesAnswer) {
|
|
- String template = "<w:p xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" w:rsidR=\"00F65544\" w:rsidP=\"00F65544\" w:rsidRDefault=\"001738E2\">" +
|
|
|
|
- "<w:r w:rsidR=\"00F65544\">" +
|
|
|
|
- "<w:rPr>" +
|
|
|
|
- "<w:rFonts w:hint=\"eastAsia\"/>" +
|
|
|
|
- "<w:szCs w:val=\"21\"/>" +
|
|
|
|
- "</w:rPr>" +
|
|
|
|
- "<w:t>quesAnswer</w:t>" +
|
|
|
|
- "</w:r>" +
|
|
|
|
- "</w:p>";
|
|
|
|
|
|
+ String template = "<w:p xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" w:rsidR=\"00F65544\" w:rsidP=\"00F65544\" w:rsidRDefault=\"001738E2\">"
|
|
|
|
+ + "<w:r w:rsidR=\"00F65544\">" + "<w:rPr>" + "<w:rFonts w:hint=\"eastAsia\"/>"
|
|
|
|
+ + "<w:szCs w:val=\"21\"/>" + "</w:rPr>" + "<w:t>quesAnswer</w:t>" + "</w:r>" + "</w:p>";
|
|
return template.replace("quesAnswer", quesAnswer);
|
|
return template.replace("quesAnswer", quesAnswer);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -574,7 +555,6 @@ public class QuesServiceImpl implements QuesService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
private String getSelectQuestionAnswer(Question question, String optionOrder) {
|
|
private String getSelectQuestionAnswer(Question question, String optionOrder) {
|
|
String answer = "";
|
|
String answer = "";
|
|
List<QuesOption> quesOptions = question.getQuesOptions();
|
|
List<QuesOption> quesOptions = question.getQuesOptions();
|
|
@@ -624,20 +604,23 @@ public class QuesServiceImpl implements QuesService {
|
|
}
|
|
}
|
|
|
|
|
|
if (searchCondition.getCoursePropertyName() != null) {
|
|
if (searchCondition.getCoursePropertyName() != null) {
|
|
- query.addCriteria(Criteria.where("quesProperties.coursePropertyName").is(searchCondition.getCoursePropertyName()));
|
|
|
|
|
|
+ query.addCriteria(
|
|
|
|
+ Criteria.where("quesProperties.coursePropertyName").is(searchCondition.getCoursePropertyName()));
|
|
}
|
|
}
|
|
|
|
|
|
if (searchCondition.getDifficulty() != null) {
|
|
if (searchCondition.getDifficulty() != null) {
|
|
query.addCriteria(Criteria.where("difficulty").is(searchCondition.getDifficulty()));
|
|
query.addCriteria(Criteria.where("difficulty").is(searchCondition.getDifficulty()));
|
|
}
|
|
}
|
|
|
|
|
|
- //二级属性不为空,那么一级属性也不为空
|
|
|
|
|
|
+ // 二级属性不为空,那么一级属性也不为空
|
|
if (StringUtils.isNotEmpty(searchCondition.getSecondPropertyId())) {
|
|
if (StringUtils.isNotEmpty(searchCondition.getSecondPropertyId())) {
|
|
- query.addCriteria(Criteria.where("quesProperties").elemMatch(
|
|
|
|
- Criteria.where("firstProperty.id").is(searchCondition.getFirstPropertyId()).and("secondProperty.id").is(searchCondition.getSecondPropertyId())));
|
|
|
|
|
|
+ query.addCriteria(Criteria.where("quesProperties")
|
|
|
|
+ .elemMatch(Criteria.where("firstProperty.id").is(searchCondition.getFirstPropertyId())
|
|
|
|
+ .and("secondProperty.id").is(searchCondition.getSecondPropertyId())));
|
|
} else {
|
|
} else {
|
|
if (searchCondition.getFirstPropertyId() != null) {
|
|
if (searchCondition.getFirstPropertyId() != null) {
|
|
- query.addCriteria(Criteria.where("quesProperties").elemMatch(Criteria.where("firstProperty.id").is(searchCondition.getFirstPropertyId())));
|
|
|
|
|
|
+ query.addCriteria(Criteria.where("quesProperties")
|
|
|
|
+ .elemMatch(Criteria.where("firstProperty.id").is(searchCondition.getFirstPropertyId())));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -662,7 +645,7 @@ public class QuesServiceImpl implements QuesService {
|
|
query2.addCriteria(Criteria.where("paperType").is(PaperType.IMPORT));
|
|
query2.addCriteria(Criteria.where("paperType").is(PaperType.IMPORT));
|
|
List<PaperDetailUnit> paperDetailUnits = this.mongoTemplate.find(query2, PaperDetailUnit.class);
|
|
List<PaperDetailUnit> paperDetailUnits = this.mongoTemplate.find(query2, PaperDetailUnit.class);
|
|
String quesNames = searchCondition.getQuesNames();
|
|
String quesNames = searchCondition.getQuesNames();
|
|
- List<String> list = Arrays.asList(quesNames.split(","));//[单选题] 单选
|
|
|
|
|
|
+ List<String> list = Arrays.asList(quesNames.split(","));// [单选题] 单选
|
|
for (PaperDetailUnit unit : paperDetailUnits) {
|
|
for (PaperDetailUnit unit : paperDetailUnits) {
|
|
if (list.contains(unit.getPaperDetail().getName())) {
|
|
if (list.contains(unit.getPaperDetail().getName())) {
|
|
count++;
|
|
count++;
|
|
@@ -676,12 +659,14 @@ public class QuesServiceImpl implements QuesService {
|
|
public void updateProByPapers(List<String> paperList, Double difficultyDegree, Boolean publicity, User user) {
|
|
public void updateProByPapers(List<String> paperList, Double difficultyDegree, Boolean publicity, User user) {
|
|
List<Paper> papers = new ArrayList<>();
|
|
List<Paper> papers = new ArrayList<>();
|
|
String difficulty = "";
|
|
String difficulty = "";
|
|
- if (difficultyDegree > 0 && difficultyDegree < 0.4) {
|
|
|
|
- difficulty = "难";
|
|
|
|
- } else if (difficultyDegree > 0.3 && difficultyDegree < 0.8) {
|
|
|
|
- difficulty = "中";
|
|
|
|
- } else {
|
|
|
|
- difficulty = "易";
|
|
|
|
|
|
+ if (difficultyDegree != null) {
|
|
|
|
+ if (difficultyDegree > 0 && difficultyDegree < 0.4) {
|
|
|
|
+ difficulty = "难";
|
|
|
|
+ } else if (difficultyDegree > 0.3 && difficultyDegree < 0.8) {
|
|
|
|
+ difficulty = "中";
|
|
|
|
+ } else {
|
|
|
|
+ difficulty = "易";
|
|
|
|
+ }
|
|
}
|
|
}
|
|
List<String> quesIds = new ArrayList<>();
|
|
List<String> quesIds = new ArrayList<>();
|
|
List<Question> subQues = new ArrayList<>();
|
|
List<Question> subQues = new ArrayList<>();
|
|
@@ -693,9 +678,13 @@ public class QuesServiceImpl implements QuesService {
|
|
if (question.getSubQuestions() != null && question.getSubQuestions().size() > 0) {
|
|
if (question.getSubQuestions() != null && question.getSubQuestions().size() > 0) {
|
|
List<Question> subQuestions = question.getSubQuestions();
|
|
List<Question> subQuestions = question.getSubQuestions();
|
|
for (Question subQuestion : subQuestions) {
|
|
for (Question subQuestion : subQuestions) {
|
|
- subQuestion.setDifficultyDegree(difficultyDegree);
|
|
|
|
- subQuestion.setDifficulty(difficulty);
|
|
|
|
- subQuestion.setPublicity(publicity);
|
|
|
|
|
|
+ if (difficultyDegree != null) {
|
|
|
|
+ subQuestion.setDifficultyDegree(difficultyDegree);
|
|
|
|
+ subQuestion.setDifficulty(difficulty);
|
|
|
|
+ }
|
|
|
|
+ if (publicity != null) {
|
|
|
|
+ subQuestion.setPublicity(publicity);
|
|
|
|
+ }
|
|
question.setSubQuestions(subQuestions);
|
|
question.setSubQuestions(subQuestions);
|
|
}
|
|
}
|
|
subQues.add(question);
|
|
subQues.add(question);
|
|
@@ -708,9 +697,17 @@ public class QuesServiceImpl implements QuesService {
|
|
if (quesIds != null && quesIds.size() > 0) {
|
|
if (quesIds != null && quesIds.size() > 0) {
|
|
Query query = new Query();
|
|
Query query = new Query();
|
|
query.addCriteria(Criteria.where("id").in(quesIds));
|
|
query.addCriteria(Criteria.where("id").in(quesIds));
|
|
- //query.addCriteria(Criteria.where("subQuestions.id").in(subQuesIds));
|
|
|
|
- Update update = Update.update("difficultyDegree", difficultyDegree).set("publicity", publicity).set("difficulty", difficulty);
|
|
|
|
- //Update update = Update.update("subQuestions.$.difficultyDegree", difficultyDegree).set("subQuestions.$.publicity", publicity);
|
|
|
|
|
|
+ Update update = null;
|
|
|
|
+ if (difficultyDegree != null) {
|
|
|
|
+ update = Update.update("difficultyDegree", difficultyDegree).set("difficulty", difficulty);
|
|
|
|
+ }
|
|
|
|
+ if (publicity != null) {
|
|
|
|
+ if (difficultyDegree != null) {
|
|
|
|
+ update = update.set("publicity", publicity);
|
|
|
|
+ } else {
|
|
|
|
+ update = Update.update("publicity", publicity);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
this.mongoTemplate.updateMulti(query, update, Question.class);
|
|
this.mongoTemplate.updateMulti(query, update, Question.class);
|
|
}
|
|
}
|
|
for (Paper paper : papers) {
|
|
for (Paper paper : papers) {
|
|
@@ -761,13 +758,15 @@ public class QuesServiceImpl implements QuesService {
|
|
Question question = optional.get();
|
|
Question question = optional.get();
|
|
QuestionAnswerBean bean = new QuestionAnswerBean();
|
|
QuestionAnswerBean bean = new QuestionAnswerBean();
|
|
List<String> answers = new ArrayList<>();
|
|
List<String> answers = new ArrayList<>();
|
|
- final String separator = "";//默认分隔符
|
|
|
|
|
|
+ final String separator = "";// 默认分隔符
|
|
|
|
|
|
if (QuesStructType.NESTED_ANSWER_QUESTION == question.getQuestionType()) {
|
|
if (QuesStructType.NESTED_ANSWER_QUESTION == question.getQuestionType()) {
|
|
List<Question> subQuestions = question.getSubQuestions();
|
|
List<Question> subQuestions = question.getSubQuestions();
|
|
for (Question subQuestion : subQuestions) {
|
|
for (Question subQuestion : subQuestions) {
|
|
- if (QuesStructType.SINGLE_ANSWER_QUESTION == subQuestion.getQuestionType() || QuesStructType.MULTIPLE_ANSWER_QUESTION == subQuestion.getQuestionType()) {
|
|
|
|
- List<String> values = QuestionAnswerConvert.parseQuestionOptionAnswerList(subQuestion.getQuesOptions());
|
|
|
|
|
|
+ if (QuesStructType.SINGLE_ANSWER_QUESTION == subQuestion.getQuestionType()
|
|
|
|
+ || QuesStructType.MULTIPLE_ANSWER_QUESTION == subQuestion.getQuestionType()) {
|
|
|
|
+ List<String> values = QuestionAnswerConvert
|
|
|
|
+ .parseQuestionOptionAnswerList(subQuestion.getQuesOptions());
|
|
answers.add(StringUtils.join(values, separator));
|
|
answers.add(StringUtils.join(values, separator));
|
|
} else {
|
|
} else {
|
|
List<String> values = QuestionAnswerConvert.parseQuestionAnswerList(subQuestion);
|
|
List<String> values = QuestionAnswerConvert.parseQuestionAnswerList(subQuestion);
|
|
@@ -775,7 +774,8 @@ public class QuesServiceImpl implements QuesService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- if (QuesStructType.SINGLE_ANSWER_QUESTION == question.getQuestionType() || QuesStructType.MULTIPLE_ANSWER_QUESTION == question.getQuestionType()) {
|
|
|
|
|
|
+ if (QuesStructType.SINGLE_ANSWER_QUESTION == question.getQuestionType()
|
|
|
|
+ || QuesStructType.MULTIPLE_ANSWER_QUESTION == question.getQuestionType()) {
|
|
List<String> values = QuestionAnswerConvert.parseQuestionOptionAnswerList(question.getQuesOptions());
|
|
List<String> values = QuestionAnswerConvert.parseQuestionOptionAnswerList(question.getQuesOptions());
|
|
answers.add(StringUtils.join(values, separator));
|
|
answers.add(StringUtils.join(values, separator));
|
|
} else {
|
|
} else {
|