From f0f00e9ba8a755e4317e029d73b69a92ad9f9df1 Mon Sep 17 00:00:00 2001
From: kongzy <kongzy>
Date: 星期六, 14 九月 2024 17:02:41 +0800
Subject: [PATCH] update

---
 exam-system/src/main/java/com/gkhy/exam/system/service/impl/ExStudentAnswerServiceImpl.java |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/exam-system/src/main/java/com/gkhy/exam/system/service/impl/ExStudentAnswerServiceImpl.java b/exam-system/src/main/java/com/gkhy/exam/system/service/impl/ExStudentAnswerServiceImpl.java
index 775123e..e99ed18 100644
--- a/exam-system/src/main/java/com/gkhy/exam/system/service/impl/ExStudentAnswerServiceImpl.java
+++ b/exam-system/src/main/java/com/gkhy/exam/system/service/impl/ExStudentAnswerServiceImpl.java
@@ -1,9 +1,9 @@
 package com.gkhy.exam.system.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gkhy.exam.common.enums.PaperStudentStateEnum;
 import com.gkhy.exam.common.exception.ApiException;
 import com.gkhy.exam.system.domain.ExPaperStudent;
-import com.gkhy.exam.system.domain.ExQuestion;
 import com.gkhy.exam.system.domain.ExStudentAnswer;
 import com.gkhy.exam.system.mapper.ExPaperStudentMapper;
 import com.gkhy.exam.system.mapper.ExQuestionMapper;
@@ -11,6 +11,8 @@
 import com.gkhy.exam.system.service.ExStudentAnswerService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
+import java.util.Objects;
 
 /**
  * <p>
@@ -30,12 +32,18 @@
     public int addStudentAnswer(ExStudentAnswer studentAnswer) {
         int row=0;
         validData(studentAnswer);
-        ExQuestion question=questionMapper.selectById(studentAnswer.getQuestionId());
-        if(studentAnswer.getAnswer().equals(question.getAnswer())){
-            studentAnswer.setPassed(1);
-        }else{
-            studentAnswer.setPassed(0);
-        }
+//        ExQuestion question=questionMapper.selectById(studentAnswer.getQuestionId());
+//        if(question.getQuestionType().equals(QuestionTypeEnum.EASY.getCode())){
+//            studentAnswer.setPassed(StudentAnswerPassEnum.WAIT_REVIEW.getCode());
+//        }else{
+//            if(studentAnswer.getAnswer().equals(question.getAnswer())){
+//                studentAnswer.setPassed(StudentAnswerPassEnum.CORRECT.getCode());
+//                studentAnswer.setScore();
+//            }else{
+//                studentAnswer.setPassed(StudentAnswerPassEnum.ERROR.getCode());
+//                studentAnswer.setScore(0);
+//            }
+//        }
         ExStudentAnswer existAnswer= baseMapper.getStudentAnswer(studentAnswer);
         if(existAnswer!=null){
             studentAnswer.setId(existAnswer.getId());
@@ -51,7 +59,7 @@
 
     public void validData(ExStudentAnswer studentAnswer){
         ExPaperStudent paperStudent=paperStudentMapper.selectByPaperStudentId(new ExPaperStudent().setPaperId(studentAnswer.getPaperId()).setStudentId(studentAnswer.getStudentId()));
-        if(paperStudent.getCompleted()==1){
+        if(!Objects.equals(paperStudent.getState(), PaperStudentStateEnum.WAIT_EXAM.getCode())){
             throw new ApiException("考试已完成,不能再作答");
         }
 

--
Gitblit v1.9.2