瀏覽代碼

试题增加题库类型

zhaosongshan 7 月之前
父節點
當前提交
addb7e0f6d

+ 11 - 3
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/service/impl/QuestionServiceImpl.java

@@ -59,7 +59,11 @@ public class QuestionServiceImpl extends BaseServiceImpl<Question> implements Qu
     @Transactional
     public Question insertFullQuestion(QuestionEditRequestVM model, String userId) {
         Date now = new Date();
-        Integer gradeLevel = subjectService.levelBySubjectId(model.getSubjectId());
+        Integer gradeLevel = null;
+        if(model.getSubjectId() != null){
+            gradeLevel = subjectService.levelBySubjectId(model.getSubjectId());
+        }
+
 
         //题干、解析、选项等 插入
         TextContent infoTextContent = new TextContent();
@@ -68,8 +72,12 @@ public class QuestionServiceImpl extends BaseServiceImpl<Question> implements Qu
         textContentService.insertByFilter(infoTextContent);
 
         Question question = new Question();
-        question.setSubjectId(model.getSubjectId());
-        question.setGradeLevel(gradeLevel);
+        if(model.getSubjectId() != null){
+            question.setSubjectId(model.getSubjectId());
+        }
+        if(gradeLevel != null){
+            question.setGradeLevel(gradeLevel);
+        }
         question.setCreateTime(now);
         question.setQuestionType(model.getQuestionType());
         question.setStatus(QuestionStatusEnum.OK.getCode());