| | |
| | | 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; |
| | |
| | | import com.gkhy.exam.system.service.ExStudentAnswerService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | 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()); |
| | |
| | | |
| | | 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("考试已完成,不能再作答"); |
| | | } |
| | | |