新增,修改,批量导入试题,重复校验修改

hehai
shijie 4 years ago
parent 0fd60e01f9
commit f043c9f4b9
  1. 12
      src/main/java/com/msdw/tms/service/impl/EvaluationRulesServiceImpl.java
  2. 11
      src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java

@ -55,11 +55,11 @@ public class EvaluationRulesServiceImpl extends ServiceImpl<EvaluationRulesDao,
evaluationRulesVO.setTotalQuestionNum(questionsService.count(queryWrapper));//总题数 evaluationRulesVO.setTotalQuestionNum(questionsService.count(queryWrapper));//总题数
int totalSingleNum = questionsService.count(queryWrapper.eq("question_type_no", int totalSingleNum = questionsService.count(queryWrapper.eq("question_type",
Constant.QuestionType.SINGLE_CHOICE.getType()));//单选题总数 Constant.QuestionType.SINGLE_CHOICE.getType()));//单选题总数
int totalMultipleNum = questionsService.count(queryWrapper.eq("question_type_no", int totalMultipleNum = questionsService.count(queryWrapper.eq("question_type",
Constant.QuestionType.MULTIPLE_CHOICE.getType()));//多选题总数 Constant.QuestionType.MULTIPLE_CHOICE.getType()));//多选题总数
int totalJudgmentNum = questionsService.count(queryWrapper.eq("question_type_no", int totalJudgmentNum = questionsService.count(queryWrapper.eq("question_type",
Constant.QuestionType.TRUE_OR_FALSE.getType()));//判断题总数 Constant.QuestionType.TRUE_OR_FALSE.getType()));//判断题总数
evaluationRulesVO.setTotalSingleNum(totalSingleNum); evaluationRulesVO.setTotalSingleNum(totalSingleNum);
@ -88,19 +88,19 @@ public class EvaluationRulesServiceImpl extends ServiceImpl<EvaluationRulesDao,
} else if (evaluationType.equals(Constant.RulesType.CUSTOMIZE.getType())) {//自定义 } else if (evaluationType.equals(Constant.RulesType.CUSTOMIZE.getType())) {//自定义
if (evaluationRules.getIsSingleEnable().equals(Constant.IsEnable.ENABLE.getType())) {//启用 if (evaluationRules.getIsSingleEnable().equals(Constant.IsEnable.ENABLE.getType())) {//启用
int singleNum = evaluationRules.getSingleNum(); int singleNum = evaluationRules.getSingleNum();
int totalSingleNum = questionsService.count(queryWrapper.eq("question_type_no", int totalSingleNum = questionsService.count(queryWrapper.eq("question_type",
Constant.QuestionType.SINGLE_CHOICE.getType()));//单选题总数 Constant.QuestionType.SINGLE_CHOICE.getType()));//单选题总数
numIncalid(singleNum, totalSingleNum); numIncalid(singleNum, totalSingleNum);
} }
if (evaluationRules.getIsMultipleEnable().equals(Constant.IsEnable.ENABLE.getType())) {//启用 if (evaluationRules.getIsMultipleEnable().equals(Constant.IsEnable.ENABLE.getType())) {//启用
int multipleNum = evaluationRules.getMultipleNum(); int multipleNum = evaluationRules.getMultipleNum();
int totalMultipleNum = questionsService.count(queryWrapper.eq("question_type_no", int totalMultipleNum = questionsService.count(queryWrapper.eq("question_type",
Constant.QuestionType.MULTIPLE_CHOICE.getType()));//多选题总数 Constant.QuestionType.MULTIPLE_CHOICE.getType()));//多选题总数
numIncalid(multipleNum, totalMultipleNum); numIncalid(multipleNum, totalMultipleNum);
} }
if (evaluationRules.getIsJudgmentEnable().equals(Constant.IsEnable.ENABLE.getType())) {//启用 if (evaluationRules.getIsJudgmentEnable().equals(Constant.IsEnable.ENABLE.getType())) {//启用
int judgmentNum = evaluationRules.getJudgmentNum(); int judgmentNum = evaluationRules.getJudgmentNum();
int totalJudgmentNum = questionsService.count(queryWrapper.eq("question_type_no", int totalJudgmentNum = questionsService.count(queryWrapper.eq("question_type",
Constant.QuestionType.TRUE_OR_FALSE.getType()));//判断题总数 Constant.QuestionType.TRUE_OR_FALSE.getType()));//判断题总数
numIncalid(judgmentNum, totalJudgmentNum); numIncalid(judgmentNum, totalJudgmentNum);
} }

@ -460,32 +460,27 @@ public class QuestionsServiceImpl extends ServiceImpl<QuestionsDao, QuestionsEnt
if (evaluationRules.getIsSingleEnable().equals(Constant.IsEnable.ENABLE.getType())) { if (evaluationRules.getIsSingleEnable().equals(Constant.IsEnable.ENABLE.getType())) {
singleNum = evaluationRules.getSingleNum(); singleNum = evaluationRules.getSingleNum();
List<QuestionsEntity> singleChoice = this.list(queryWrapper.eq("question_type_no", List<QuestionsEntity> singleChoice = this.list(queryWrapper.eq("question_type",
Constant.QuestionType.SINGLE_CHOICE.getType())); Constant.QuestionType.SINGLE_CHOICE.getType()));
set.addAll(getRandomList(singleNum, singleChoice)); set.addAll(getRandomList(singleNum, singleChoice));
} }
if (evaluationRules.getIsMultipleEnable().equals(Constant.IsEnable.ENABLE.getType())) { if (evaluationRules.getIsMultipleEnable().equals(Constant.IsEnable.ENABLE.getType())) {
multipleNum = evaluationRules.getMultipleNum(); multipleNum = evaluationRules.getMultipleNum();
List<QuestionsEntity> multipleChoice = this.list(queryWrapper.eq("question_type_no", List<QuestionsEntity> multipleChoice = this.list(queryWrapper.eq("question_type",
Constant.QuestionType.MULTIPLE_CHOICE.getType())); Constant.QuestionType.MULTIPLE_CHOICE.getType()));
set.addAll(getRandomList(multipleNum, multipleChoice)); set.addAll(getRandomList(multipleNum, multipleChoice));
} }
if (evaluationRules.getIsJudgmentEnable().equals(Constant.IsEnable.ENABLE.getType())) { if (evaluationRules.getIsJudgmentEnable().equals(Constant.IsEnable.ENABLE.getType())) {
judgmentNum = evaluationRules.getJudgmentNum(); judgmentNum = evaluationRules.getJudgmentNum();
List<QuestionsEntity> judgments = this.list(queryWrapper.eq("question_type_no", List<QuestionsEntity> judgments = this.list(queryWrapper.eq("question_type",
Constant.QuestionType.TRUE_OR_FALSE.getType())); Constant.QuestionType.TRUE_OR_FALSE.getType()));
set.addAll(getRandomList(judgmentNum, judgments)); set.addAll(getRandomList(judgmentNum, judgments));
} }
// 总题数等于各类题目数量之和 // 总题数等于各类题目数量之和
evaluation.setQuestionNum(singleNum + multipleNum + judgmentNum); evaluation.setQuestionNum(singleNum + multipleNum + judgmentNum);
} }
// Set<QuestionsVO> collect = set.stream().map(item -> {
// QuestionsVO questionsVO = new QuestionsVO();
// BeanUtils.copyProperties(item, questionsVO);
// return questionsVO;
// }).collect(Collectors.toSet());
evaluation.setQuestions(set); evaluation.setQuestions(set);
return evaluation; return evaluation;

Loading…
Cancel
Save