xiangpei
2024-05-31 16d10cef208de048f8b325facd143c54b7be9963
src/main/java/com/ycl/jxkg/service/impl/ExamPaperQuestionCustomerAnswerServiceImpl.java
@@ -5,14 +5,14 @@
import com.ycl.jxkg.domain.other.KeyValue;
import com.ycl.jxkg.domain.TextContent;
import com.ycl.jxkg.domain.enums.QuestionTypeEnum;
import com.ycl.jxkg.repository.ExamPaperQuestionCustomerAnswerMapper;
import com.ycl.jxkg.mapper.ExamPaperQuestionCustomerAnswerMapper;
import com.ycl.jxkg.service.ExamPaperQuestionCustomerAnswerService;
import com.ycl.jxkg.service.TextContentService;
import com.ycl.jxkg.utility.DateTimeUtil;
import com.ycl.jxkg.utility.ExamUtil;
import com.ycl.jxkg.utility.JsonUtil;
import com.ycl.jxkg.viewmodel.student.exam.ExamPaperSubmitItemVM;
import com.ycl.jxkg.viewmodel.student.question.answer.QuestionPageStudentRequestVM;
import com.ycl.jxkg.utils.DateTimeUtil;
import com.ycl.jxkg.utils.ExamUtil;
import com.ycl.jxkg.utils.JsonUtil;
import com.ycl.jxkg.vo.student.exam.ExamPaperSubmitItemVO;
import com.ycl.jxkg.vo.student.question.answer.QuestionPageStudentRequestVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
@@ -37,7 +37,7 @@
    @Override
    public PageInfo<ExamPaperQuestionCustomerAnswer> studentPage(QuestionPageStudentRequestVM requestVM) {
    public PageInfo<ExamPaperQuestionCustomerAnswer> studentPage(QuestionPageStudentRequestVO requestVM) {
        return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() ->
                examPaperQuestionCustomerAnswerMapper.studentPage(requestVM)
        );
@@ -55,16 +55,16 @@
    }
    @Override
    public ExamPaperSubmitItemVM examPaperQuestionCustomerAnswerToVM(ExamPaperQuestionCustomerAnswer qa) {
        ExamPaperSubmitItemVM examPaperSubmitItemVM = new ExamPaperSubmitItemVM();
        examPaperSubmitItemVM.setId(qa.getId());
        examPaperSubmitItemVM.setQuestionId(qa.getQuestionId());
        examPaperSubmitItemVM.setDoRight(qa.getDoRight());
        examPaperSubmitItemVM.setItemOrder(qa.getItemOrder());
        examPaperSubmitItemVM.setQuestionScore(ExamUtil.scoreToVM(qa.getQuestionScore()));
        examPaperSubmitItemVM.setScore(ExamUtil.scoreToVM(qa.getCustomerScore()));
        setSpecialToVM(examPaperSubmitItemVM, qa);
        return examPaperSubmitItemVM;
    public ExamPaperSubmitItemVO examPaperQuestionCustomerAnswerToVM(ExamPaperQuestionCustomerAnswer qa) {
        ExamPaperSubmitItemVO examPaperSubmitItemVO = new ExamPaperSubmitItemVO();
        examPaperSubmitItemVO.setId(qa.getId());
        examPaperSubmitItemVO.setQuestionId(qa.getQuestionId());
        examPaperSubmitItemVO.setDoRight(qa.getDoRight());
        examPaperSubmitItemVO.setItemOrder(qa.getItemOrder());
        examPaperSubmitItemVO.setQuestionScore(ExamUtil.scoreToVM(qa.getQuestionScore()));
        examPaperSubmitItemVO.setScore(ExamUtil.scoreToVM(qa.getCustomerScore()));
        setSpecialToVM(examPaperSubmitItemVO, qa);
        return examPaperSubmitItemVO;
    }
    @Override
@@ -89,24 +89,24 @@
        return examPaperQuestionCustomerAnswerMapper.updateScore(examPaperAnswerUpdates);
    }
    private void setSpecialToVM(ExamPaperSubmitItemVM examPaperSubmitItemVM, ExamPaperQuestionCustomerAnswer examPaperQuestionCustomerAnswer) {
    private void setSpecialToVM(ExamPaperSubmitItemVO examPaperSubmitItemVO, ExamPaperQuestionCustomerAnswer examPaperQuestionCustomerAnswer) {
        QuestionTypeEnum questionTypeEnum = QuestionTypeEnum.fromCode(examPaperQuestionCustomerAnswer.getQuestionType());
        switch (questionTypeEnum) {
            case MultipleChoice:
                examPaperSubmitItemVM.setContent(examPaperQuestionCustomerAnswer.getAnswer());
                examPaperSubmitItemVM.setContentArray(ExamUtil.contentToArray(examPaperQuestionCustomerAnswer.getAnswer()));
                examPaperSubmitItemVO.setContent(examPaperQuestionCustomerAnswer.getAnswer());
                examPaperSubmitItemVO.setContentArray(ExamUtil.contentToArray(examPaperQuestionCustomerAnswer.getAnswer()));
                break;
            case GapFilling:
                TextContent textContent = textContentService.selectById(examPaperQuestionCustomerAnswer.getTextContentId());
                List<String> correctAnswer = JsonUtil.toJsonListObject(textContent.getContent(), String.class);
                examPaperSubmitItemVM.setContentArray(correctAnswer);
                examPaperSubmitItemVO.setContentArray(correctAnswer);
                break;
            default:
                if (QuestionTypeEnum.needSaveTextContent(examPaperQuestionCustomerAnswer.getQuestionType())) {
                    TextContent content = textContentService.selectById(examPaperQuestionCustomerAnswer.getTextContentId());
                    examPaperSubmitItemVM.setContent(content.getContent());
                    examPaperSubmitItemVO.setContent(content.getContent());
                } else {
                    examPaperSubmitItemVM.setContent(examPaperQuestionCustomerAnswer.getAnswer());
                    examPaperSubmitItemVO.setContent(examPaperQuestionCustomerAnswer.getAnswer());
                }
                break;
        }