浏览代码

修改试卷接口,答卷提交补全缺失的任务试卷的数据关联关系

zhaosongshan 7 月之前
父节点
当前提交
c15ce3d5b7

+ 12 - 1
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/service/impl/ExamPaperAnswerServiceImpl.java

@@ -38,6 +38,8 @@ import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
+import static vip.xiaonuo.exam.domain.enums.ExamPaperTypeEnum.Task;
+
 @Service
 public class ExamPaperAnswerServiceImpl extends BaseServiceImpl<ExamPaperAnswer> implements ExamPaperAnswerService {
 
@@ -74,7 +76,7 @@ public class ExamPaperAnswerServiceImpl extends BaseServiceImpl<ExamPaperAnswer>
         ExamPaper examPaper = examPaperMapper.selectByPrimaryKey(examPaperSubmitVM.getId());
         ExamPaperTypeEnum paperTypeEnum = ExamPaperTypeEnum.fromCode(examPaper.getPaperType());
         //任务试卷只能做一次
-        if (paperTypeEnum == ExamPaperTypeEnum.Task) {
+        if (paperTypeEnum == Task) {
             ExamPaperAnswer examPaperAnswer = examPaperAnswerMapper.getByPidUid(examPaperSubmitVM.getId(), user.getId());
             if (null != examPaperAnswer)
                 return null;
@@ -110,6 +112,15 @@ public class ExamPaperAnswerServiceImpl extends BaseServiceImpl<ExamPaperAnswer>
             customerAnswers.setExamPaperAnswerId(examPaperAnswer.getId());
         });
         examPaperQuestionCustomerAnswerService.insertList(examPaperQuestionCustomerAnswers);
+        ExamPaperTypeEnum examPaperTypeEnum = ExamPaperTypeEnum.fromCode(examPaper.getPaperType());
+        if(Task.equals(examPaperTypeEnum)){
+            TaskExamCustomerAnswer taskExamCustomerAnswer = new TaskExamCustomerAnswer();
+            taskExamCustomerAnswer.setCreateUser(user.getId());
+            taskExamCustomerAnswer.setTaskExamId(examPaper.getTaskExamId());
+            taskExamCustomerAnswer.setCreateTime(now);
+            taskExamCustomerAnswer.setTextContentId(textContent.getId());
+            taskExamCustomerAnswerMapper.insertSelective(taskExamCustomerAnswer);
+        }
         return examPaperAnswerInfo;
     }