|
@@ -7,6 +7,9 @@
|
|
|
|
|
|
package cn.com.qmth.examcloud.core.print.service.impl;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.core.print.common.utils.Check;
|
|
|
+import cn.com.qmth.examcloud.core.print.entity.ObjectiveQuestionStructure;
|
|
|
+import cn.com.qmth.examcloud.core.print.entity.SubjectiveQuestionStructure;
|
|
|
import cn.com.qmth.examcloud.core.print.repository.ObjectiveQuestionStructureRepository;
|
|
|
import cn.com.qmth.examcloud.core.print.repository.SubjectiveQuestionStructureRepository;
|
|
|
import cn.com.qmth.examcloud.core.print.service.CommonService;
|
|
@@ -18,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* @author: fengdesheng
|
|
@@ -35,8 +39,27 @@ public class QuestionStructureServiceImpl implements QuestionStructureService {
|
|
|
|
|
|
@Override
|
|
|
public void savePaperQuestionStructure(@NotNull Long examId, @NotNull String paperId) {
|
|
|
+ Check.isNull(examId, "考试ID不能为空!");
|
|
|
+ Check.isEmpty(paperId, "试卷ID不能为空!");
|
|
|
+
|
|
|
+ //从题库端获取试卷的试题结构信息
|
|
|
PaperQuestionStructureInfo info = commonService.findStructureByPaperId(paperId);
|
|
|
- //todo
|
|
|
+
|
|
|
+ //先清理旧数据
|
|
|
+ objectiveQuestionStructureRepository.deleteByPaperId(examId, paperId);
|
|
|
+ subjectiveQuestionStructureRepository.deleteByPaperId(examId, paperId);
|
|
|
+
|
|
|
+ //保存客观题数据
|
|
|
+ List<ObjectiveQuestionStructure> objectives = info.getObjectives();
|
|
|
+ if (objectives != null && !objectives.isEmpty()) {
|
|
|
+ objectiveQuestionStructureRepository.save(info.getObjectives());
|
|
|
+ }
|
|
|
+
|
|
|
+ //保存主观题数据
|
|
|
+ List<SubjectiveQuestionStructure> subjectives = info.getSubjectives();
|
|
|
+ if (subjectives != null && !subjectives.isEmpty()) {
|
|
|
+ subjectiveQuestionStructureRepository.save(info.getSubjectives());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|