From f880633deb4bc242be87ae4de6e8642c9c547cf6 Mon Sep 17 00:00:00 2001 From: Mlxa0324 Date: Fri, 30 Sep 2022 15:36:08 +0800 Subject: [PATCH] 1 --- .../TeacherOpenCourseQuestionLogScoreInfo.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionLogScoreInfo.java b/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionLogScoreInfo.java index 6f646674..be2c3c04 100644 --- a/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionLogScoreInfo.java +++ b/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionLogScoreInfo.java @@ -39,6 +39,13 @@ public class TeacherOpenCourseQuestionLogScoreInfo extends BaseEntity { /** ========================================================================= */ + // 题目总数量 + + @FetchSql("select count(1) from resources_question_snapshot t " + + "where t.question_status = 1 " + + "and t.resources_question_snapshot_from_id = #resourcesQuestionSnapshotFromId# " + ) + private int questionTotalCount; // 答对数量 @@ -101,16 +108,21 @@ public class TeacherOpenCourseQuestionLogScoreInfo extends BaseEntity { tryCalcCorrectRate(); } + public void setQuestionTotalCount(int questionTotalCount) { + this.questionTotalCount = questionTotalCount; + tryCalcCorrectRate(); + } + /** * 尝试计算正确率 */ private void tryCalcCorrectRate() { - int temp = this.getCorrectCount() + this.getWrongCount(); - if (this.getCorrectCount() > 0 && this.getWrongCount() > 0) { + int sumTotalCount = getCorrectCount() + getWrongCount(); + if (getQuestionTotalCount() == sumTotalCount) { // 计算正确率, 取小数点后2位数 // 计算规则:正确率 = 正确数量 / (正确数量 + 错误数量) * 100 this.setCorrectRate(NumberUtil - .round(NumberUtil.div(this.getCorrectCount(), temp) * 100, 0) + .round(NumberUtil.div(getCorrectCount(), sumTotalCount) * 100, 0) .intValue()); } }