fix: 错题回顾答错次数显示不正确
This commit is contained in:
@@ -293,6 +293,9 @@ public class HotTrainingAnswerRecordServiceImpl implements IHotTrainingAnswerRec
|
|||||||
// 更新
|
// 更新
|
||||||
HotTrainingAnswerRecord existing = existingMap.get(entity.getQuestionSource());
|
HotTrainingAnswerRecord existing = existingMap.get(entity.getQuestionSource());
|
||||||
entity.setId(existing.getId());
|
entity.setId(existing.getId());
|
||||||
|
|
||||||
|
mergeErrorData(entity, existing);
|
||||||
|
|
||||||
toUpdate.add(entity);
|
toUpdate.add(entity);
|
||||||
} else {
|
} else {
|
||||||
// 插入
|
// 插入
|
||||||
@@ -506,4 +509,18 @@ public class HotTrainingAnswerRecordServiceImpl implements IHotTrainingAnswerRec
|
|||||||
}
|
}
|
||||||
throw new ServiceException("无法获取提交人姓名,签名校验失败");
|
throw new ServiceException("无法获取提交人姓名,签名校验失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 累加错误次数并拼接最新的错误答案
|
||||||
|
* 拼接后的总长度控制在200字符内,保留最新产生的数据(先不要)
|
||||||
|
*
|
||||||
|
* @param entity 当前传入的答题实体
|
||||||
|
* @param existing 数据库中已存在的答题实体
|
||||||
|
*/
|
||||||
|
private void mergeErrorData(HotTrainingAnswerRecord entity, HotTrainingAnswerRecord existing) {
|
||||||
|
// 1. 累加错误次数,前端提交一次答题,只会加一次
|
||||||
|
int currentErrorCount = entity.getErrorCount() != null ? 1 : 0;
|
||||||
|
int existingErrorCount = existing.getErrorCount() != null ? existing.getErrorCount() : 0;
|
||||||
|
entity.setErrorCount(existingErrorCount + currentErrorCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,7 +140,7 @@
|
|||||||
<select id="selectWrongQuestionReviewList"
|
<select id="selectWrongQuestionReviewList"
|
||||||
resultType="com.hotwj.platform.securityManagement.trainingAnswer.domain.vo.HotTrainingWrongQuestionReviewVo">
|
resultType="com.hotwj.platform.securityManagement.trainingAnswer.domain.vo.HotTrainingWrongQuestionReviewVo">
|
||||||
SELECT ar.question_id AS questionId,
|
SELECT ar.question_id AS questionId,
|
||||||
count(ar.question_id) AS errorCount
|
SUM(ar.error_count) AS errorCount
|
||||||
FROM hot_training_answer_record ar
|
FROM hot_training_answer_record ar
|
||||||
WHERE ar.is_deleted = 0
|
WHERE ar.is_deleted = 0
|
||||||
AND ar.company_id = #{companyId}
|
AND ar.company_id = #{companyId}
|
||||||
@@ -148,8 +148,7 @@
|
|||||||
AND ar.scene_type = 'PLAN'
|
AND ar.scene_type = 'PLAN'
|
||||||
AND ar.training_id = #{bo.trainingId}
|
AND ar.training_id = #{bo.trainingId}
|
||||||
AND ar.exam_id = #{bo.examId}
|
AND ar.exam_id = #{bo.examId}
|
||||||
AND ar.error_answers IS NOT NULL
|
AND ar.error_count > 0
|
||||||
AND ar.error_answers <> ''
|
|
||||||
GROUP BY ar.question_id
|
GROUP BY ar.question_id
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user