qirong
2023-08-17 81dfe248054eaa3c2751ba32576f48598adcd04f
src/main/java/com/mindskip/xzs/service/impl/ExamPaperAnswerServiceImpl.java
@@ -21,6 +21,7 @@
import com.mindskip.xzs.utility.JsonUtil;
import com.mindskip.xzs.viewmodel.student.exam.ExamPaperSubmitItemVM;
import com.mindskip.xzs.viewmodel.student.exam.ExamPaperSubmitVM;
import com.mindskip.xzs.viewmodel.student.exampaper.ExamPaperAnswerPageResponseVM;
import com.mindskip.xzs.viewmodel.student.exampaper.ExamPaperAnswerPageVM;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@@ -220,13 +221,17 @@
        QuestionTypeEnum questionTypeEnum = QuestionTypeEnum.fromCode(examPaperQuestionCustomerAnswer.getQuestionType());
        switch (questionTypeEnum) {
            case SingleChoice:
                examPaperQuestionCustomerAnswer.setAnswer(customerQuestionAnswer.getContent());
                examPaperQuestionCustomerAnswer.setDoRight(question.getCorrect().equals(customerQuestionAnswer.getContent()));
                examPaperQuestionCustomerAnswer.setCustomerScore(examPaperQuestionCustomerAnswer.getDoRight() ? question.getScore() : 0);
                break;
            case TrueFalse:
                examPaperQuestionCustomerAnswer.setAnswer(customerQuestionAnswer.getContent());
                examPaperQuestionCustomerAnswer.setDoRight(question.getCorrect().equals(customerQuestionAnswer.getContent()));
                examPaperQuestionCustomerAnswer.setCustomerScore(examPaperQuestionCustomerAnswer.getDoRight() ? question.getScore() : 0);
                break;
            case MultipleChoice:
                String customerAnswer = ExamUtil.contentToString(customerQuestionAnswer.getContentArray());
                String customerAnswer = customerQuestionAnswer.getContent() ==null ? ExamUtil.contentToString(customerQuestionAnswer.getContentArray()) : customerQuestionAnswer.getContent();
                examPaperQuestionCustomerAnswer.setAnswer(customerAnswer);
                examPaperQuestionCustomerAnswer.setDoRight(customerAnswer.equals(question.getCorrect()));
                examPaperQuestionCustomerAnswer.setCustomerScore(examPaperQuestionCustomerAnswer.getDoRight() ? question.getScore() : 0);
@@ -275,4 +280,19 @@
        return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "user_score desc").doSelectPageInfo(() ->
                examPaperAnswerMapper.adminPage(requestVM));
    }
    @Override
    public ExamPaperAnswer getById(Integer id) {
        return examPaperAnswerMapper.getById(id);
    }
    @Override
    public List<ExamPaperAnswer> selectByPaperName(String paperName) {
        return examPaperAnswerMapper.selectByPaperName(paperName);
    }
    @Override
    public List<ExamPaperAnswer> getByExamPaperIdAndUserId(List<ExamTemplatesUserCount> examTemplatesUserCount) {
        return examPaperAnswerMapper.getByExamPaperIdAndUserId(examTemplatesUserCount);
    }
}