From 602e8fd747987d97d1ef54bf51d0bb028bbc89f8 Mon Sep 17 00:00:00 2001 From: Mlxa0324 Date: Tue, 29 Nov 2022 22:09:53 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=98=E7=9B=AE=E5=AE=8C=E6=88=90=E7=94=A8?= =?UTF-8?q?=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/sql/mysql/tianze-pro-update.sql | 1 - ...TeacherOpenCourseQuestionLogScoreInfo.java | 40 +++++++++++-------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/doc/sql/mysql/tianze-pro-update.sql b/doc/sql/mysql/tianze-pro-update.sql index 307edfc8..7a722ffc 100644 --- a/doc/sql/mysql/tianze-pro-update.sql +++ b/doc/sql/mysql/tianze-pro-update.sql @@ -365,7 +365,6 @@ ALTER TABLE resources_question_snapshot ADD COLUMN teacher_open_course_merge_res ALTER TABLE teacher_open_course_question_log ADD COLUMN question_analysis varchar(1000) COMMENT '解析'; ALTER TABLE teacher_open_course_question_log ADD COLUMN is_tuck int(2) default 0 COMMENT '是否收藏夹'; ALTER TABLE teacher_open_course_question_log ADD COLUMN is_error_favorite int(2) default 0 COMMENT '是否错题库'; -ALTER TABLE teacher_open_course_question_log ADD COLUMN teacher_open_course_question_log_create_time datetime COMMENT '创建时间'; ALTER TABLE teacher_open_course_question_log ADD COLUMN teacher_open_course_question_log_update_time datetime COMMENT '修改时间'; ALTER TABLE teacher_open_course_question_log ADD COLUMN teacher_open_course_question_log_finish_time int(10) default 1 COMMENT '总用时(分钟)'; ALTER TABLE teacher_open_course_question_log ADD COLUMN teacher_open_course_question_log_reply varchar(300) COMMENT '评语'; 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 99a818fa..c8081d2d 100644 --- a/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionLogScoreInfo.java +++ b/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionLogScoreInfo.java @@ -1,6 +1,7 @@ package com.ibeetl.jlw.entity; import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; import com.ibeetl.admin.core.entity.BaseEntity; import lombok.Data; import lombok.EqualsAndHashCode; @@ -52,7 +53,7 @@ public class TeacherOpenCourseQuestionLogScoreInfo extends BaseEntity { "@} \n" + "and t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# " ) - private int questionTotalCount; + private Integer questionTotalCount; // 答对数量 @@ -65,7 +66,7 @@ public class TeacherOpenCourseQuestionLogScoreInfo extends BaseEntity { "and t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# " + "and t.teacher_open_course_question_log_answer = t.question_answer " ) - private int correctCount; + private Integer correctCount; // 答错数量 @FetchSql("select count(1) from teacher_open_course_question_log t " + @@ -76,7 +77,7 @@ public class TeacherOpenCourseQuestionLogScoreInfo extends BaseEntity { "and t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# " + "and t.teacher_open_course_question_log_answer != t.question_answer " ) - private int wrongCount; + private Integer wrongCount; // 总得分 @FetchSql("select sum(IFNULL(t.question_score, 0)) as total_score " + @@ -96,7 +97,7 @@ public class TeacherOpenCourseQuestionLogScoreInfo extends BaseEntity { @FetchSql(value = "SELECT t.* " + "FROM teacher_open_course_question_log t " + - "WHERE t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT' \n" + + "WHERE t.teacher_open_course_question_log_status = 1 \n" + "@if(!isEmpty(studentId)) { \n" + "and t.student_id = #studentId# \n" + "@} \n" + @@ -107,28 +108,39 @@ public class TeacherOpenCourseQuestionLogScoreInfo extends BaseEntity { /** * 完成用时 */ - @FetchSql(value = "SELECT max(TIMEDIFF( t.teacher_open_course_question_log_update_time , t.teacher_open_course_question_log_add_time )) as finish_time " + +// @FetchSql(value = "SELECT max(TIMEDIFF( t.teacher_open_course_question_log_update_time , t.teacher_open_course_question_log_add_time )) as finish_time " + +// "FROM teacher_open_course_question_log t " + +// "WHERE t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT' \n" + +// "@if(!isEmpty(studentId)) { \n" + +// "and t.student_id = #studentId# \n" + +// "@} \n" + +// "and t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# " + +// "AND t.teacher_open_course_question_log_update_time IS NOT NULL " +// ) +// private String finishTime; + + @FetchSql(value = "SELECT max(ifnull(t.teacher_open_course_question_log_finish_time , 0)) as finish_time " + "FROM teacher_open_course_question_log t " + "WHERE t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT' \n" + "@if(!isEmpty(studentId)) { \n" + "and t.student_id = #studentId# \n" + "@} \n" + - "and t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId#" + + "and t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# " + "AND t.teacher_open_course_question_log_update_time IS NOT NULL " ) private String finishTime; - public void setCorrectCount(int correctCount) { + public void setCorrectCount(Integer correctCount) { this.correctCount = correctCount; tryCalcCorrectRate(); } - public void setWrongCount(int wrongCount) { + public void setWrongCount(Integer wrongCount) { this.wrongCount = wrongCount; tryCalcCorrectRate(); } - public void setQuestionTotalCount(int questionTotalCount) { + public void setQuestionTotalCount(Integer questionTotalCount) { this.questionTotalCount = questionTotalCount; tryCalcCorrectRate(); } @@ -137,16 +149,10 @@ public class TeacherOpenCourseQuestionLogScoreInfo extends BaseEntity { * 尝试计算正确率 */ private void tryCalcCorrectRate() { - int sumTotalCount = getCorrectCount() + getWrongCount(); - if (sumTotalCount == 0) { - this.setCorrectRate(0); return; - } - if (getQuestionTotalCount() == sumTotalCount) { + if (ObjectUtil.isAllNotEmpty(getCorrectCount(), getWrongCount(), getQuestionTotalCount())) { // 计算正确率, 取小数点后2位数 // 计算规则:正确率 = 正确数量 / (正确数量 + 错误数量) * 100 - this.setCorrectRate(NumberUtil - .round(NumberUtil.div(getCorrectCount(), sumTotalCount) * 100, 2) - .floatValue()); + this.setCorrectRate(NumberUtil.round(((float)getCorrectCount() / getQuestionTotalCount()) * 100, 2).floatValue()); } } }