xiangpei
2024-07-16 a820ec5dc1682ac0a31fcbdba3eb4d2c0fe74b64
Merge remote-tracking branch 'origin/master'
9个文件已修改
45 ■■■■■ 已修改文件
src/main/java/com/mindskip/xzs/controller/student/ExamPaperAnswerController.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/domain/ExamPaperAnswerInfo.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/domain/vo/ExamTemplatesVO.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/listener/CalculateExamPaperAnswerListener.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/repository/ExamPaperAnswerMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/service/ExamPaperAnswerService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/service/impl/ExamPaperAnswerServiceImpl.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ExamPaperAnswerMapper.xml 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ExamTemplatesMapper.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/controller/student/ExamPaperAnswerController.java
@@ -87,6 +87,7 @@
                + " 得分:" + scoreVm
                + " 耗时:" + ExamUtil.secondToVM(examPaperAnswer.getDoTime());
        userEventLog.setContent(content);
        examPaperAnswerInfo.setTemplateId(examPaperSubmitVM.getTemplatesId());
        eventPublisher.publishEvent(new CalculateExamPaperAnswerCompleteEvent(examPaperAnswerInfo));
        eventPublisher.publishEvent(new UserEvent(userEventLog));
        //首页随机试卷操作
src/main/java/com/mindskip/xzs/domain/ExamPaperAnswerInfo.java
@@ -7,6 +7,15 @@
    public ExamPaper examPaper;
    public ExamPaperAnswer examPaperAnswer;
    public List<ExamPaperQuestionCustomerAnswer> examPaperQuestionCustomerAnswers;
    public Integer templateId;
    public Integer getTemplateId() {
        return templateId;
    }
    public void setTemplateId(Integer templateId) {
        this.templateId = templateId;
    }
    public ExamPaper getExamPaper() {
        return examPaper;
src/main/java/com/mindskip/xzs/domain/vo/ExamTemplatesVO.java
@@ -46,6 +46,6 @@
    /**
     * 时间周期
     */
    private List<LocalDateTime> period;
    private List<String> period;
}
src/main/java/com/mindskip/xzs/listener/CalculateExamPaperAnswerListener.java
@@ -60,7 +60,7 @@
        examPaperAnswerService.insertByFilter(examPaperAnswer);
        // 最优成绩有效,其余无效
        examPaperAnswerService.maxGrade(examPaperAnswer);
        examPaperAnswerService.maxGrade(examPaperAnswer, examPaperAnswerInfo.getTemplateId());
        examPaperQuestionCustomerAnswers.stream().filter(a -> QuestionTypeEnum.needSaveTextContent(a.getQuestionType())).forEach(d -> {
            TextContent textContent = new TextContent(d.getAnswer(), now);
src/main/java/com/mindskip/xzs/repository/ExamPaperAnswerMapper.java
@@ -77,7 +77,7 @@
     * @param examPaperAnswer 答卷
     * @return 最高成绩答卷
     */
    ExamPaperAnswer getTemplateOtherExamAnswer(ExamPaperAnswer examPaperAnswer);
    ExamPaperAnswer getTemplateOtherExamAnswer(@Param("examPaperAnswer") ExamPaperAnswer examPaperAnswer, @Param("templateId") Integer templateId);
    /**
     * 根据试卷id获取最高成绩答卷
src/main/java/com/mindskip/xzs/service/ExamPaperAnswerService.java
@@ -77,5 +77,5 @@
     * 获取之前的成绩,取最优成绩
     * @param examPaperAnswer 本次答卷
     */
    void maxGrade(ExamPaperAnswer examPaperAnswer);
    void maxGrade(ExamPaperAnswer examPaperAnswer, Integer templateId);
}
src/main/java/com/mindskip/xzs/service/impl/ExamPaperAnswerServiceImpl.java
@@ -404,25 +404,25 @@
    }
    @Override
    public void maxGrade(ExamPaperAnswer examPaperAnswer) {
        // 获取某一场考试的最高成绩
    public void maxGrade(ExamPaperAnswer examPaperAnswer, Integer templateId) {
        // 获取某一场考试曾经的最高成绩
        ExamPaperAnswer maxGrade;
        if (Objects.equals(examPaperAnswer.getPaperType(), 7)) {
            maxGrade = examPaperAnswerMapper.getTemplateOtherExamAnswer(examPaperAnswer);
            maxGrade = examPaperAnswerMapper.getTemplateOtherExamAnswer(examPaperAnswer, templateId);
        } else {
            maxGrade = examPaperAnswerMapper.getPaperOtherExamAnswer(examPaperAnswer);
        }
        if (Objects.isNull(maxGrade)) {
            return;
        }
        // 本次不是最高分
        if (!Objects.equals(maxGrade.getId(), examPaperAnswer.getId())) {
        // 本次考试分数不如之前,本次无效
        if (maxGrade.getUserScore() > examPaperAnswer.getUserScore()) {
            // 之前的成绩有效
            maxGrade.setInvalid(AnswerInvalidEnum.VALID);
            examPaperAnswerMapper.updateByPrimaryKey(maxGrade);
            examPaperAnswerMapper.updateByPrimaryKeySelective(maxGrade);
            // 本次的不是最高分,无效
            examPaperAnswer.setInvalid(AnswerInvalidEnum.INVALID);
            examPaperAnswerMapper.updateByPrimaryKey(examPaperAnswer);
            examPaperAnswerMapper.updateByPrimaryKeySelective(examPaperAnswer);
        }
    }
src/main/resources/mapper/ExamPaperAnswerMapper.xml
@@ -209,6 +209,9 @@
      <if test="taskExamId != null">
        task_exam_id = #{taskExamId,jdbcType=INTEGER},
      </if>
      <if test="invalid != null">
        invalid = #{invalid},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
@@ -659,14 +662,13 @@
  <select id="getTemplateOtherExamAnswer" resultType="com.mindskip.xzs.domain.ExamPaperAnswer">
    SELECT id, user_score FROM t_exam_paper_answer WHERE exam_paper_id IN
        (SELECT exam_paper_id FROM t_exam_templates_user_count WHERE user_id = #{createUser} AND exam_templates_id =
            (SELECT exam_templates_id FROM t_exam_templates_user_count WHERE exam_paper_id = #{examPaperId} LIMIT 1))
    HAVING MAX(user_score) ORDER BY create_time DESC LIMIT 1
        (SELECT exam_paper_id FROM t_exam_templates_user_count WHERE user_id = #{examPaperAnswer.createUser} AND exam_templates_id = #{templateId})
    ORDER BY user_score DESC LIMIT 1
  </select>
  <select id="getPaperOtherExamAnswer" resultType="com.mindskip.xzs.domain.ExamPaperAnswer">
    SELECT id, user_score FROM t_exam_paper_answer WHERE exam_paper_id = #{examPaperId} AND create_user = #{createUser}
    HAVING MAX(user_score) ORDER BY create_time DESC LIMIT 1
    ORDER BY user_score DESC LIMIT 1
  </select>
</mapper>
src/main/resources/mapper/ExamTemplatesMapper.xml
@@ -62,6 +62,7 @@
        left join t_exam_templates_user u on e.id = u.templates_id
        LEFT JOIN t_exam_templates_subject ts ON e.id = ts.templates_id
        LEFT JOIN t_subject s ON ts.subject_id = s.id
        LEFT JOIN t_user_department tud ON e.create_user = tud.user_id
        <where>
            <if test="status != null">
                and e.status = 0
@@ -73,7 +74,7 @@
                and u.user_id = #{userId}
            </if>
            <if test="deptId != null and deptId.size() > 0">
                and e.dept_id in <foreach collection="deptId" item="item" separator="," open="(" close=")"> #{item} </foreach>
                and tud.department_id in <foreach collection="deptId" item="item" separator="," open="(" close=")"> #{item} </foreach>
            </if>
            <if test="name != null and name != ''">
                and INSTR(e.name, #{name})