题目完成用时

beetlsql3-dev
Mlxa0324 2 years ago
parent e3e6cc0650
commit 602e8fd747

@ -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 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_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 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_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_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 '评语'; ALTER TABLE teacher_open_course_question_log ADD COLUMN teacher_open_course_question_log_reply varchar(300) COMMENT '评语';

@ -1,6 +1,7 @@
package com.ibeetl.jlw.entity; package com.ibeetl.jlw.entity;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import com.ibeetl.admin.core.entity.BaseEntity; import com.ibeetl.admin.core.entity.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -52,7 +53,7 @@ public class TeacherOpenCourseQuestionLogScoreInfo extends BaseEntity {
"@} \n" + "@} \n" +
"and t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# " "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_setting_id = #teacherOpenCourseQuestionSettingId# " +
"and t.teacher_open_course_question_log_answer = t.question_answer " "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 " + @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_setting_id = #teacherOpenCourseQuestionSettingId# " +
"and t.teacher_open_course_question_log_answer != t.question_answer " "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 " + @FetchSql("select sum(IFNULL(t.question_score, 0)) as total_score " +
@ -96,7 +97,7 @@ public class TeacherOpenCourseQuestionLogScoreInfo extends BaseEntity {
@FetchSql(value = "SELECT t.* " + @FetchSql(value = "SELECT t.* " +
"FROM teacher_open_course_question_log 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" + "@if(!isEmpty(studentId)) { \n" +
"and t.student_id = #studentId# \n" + "and t.student_id = #studentId# \n" +
"@} \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 " + "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 and t.question_log_add_type = 'FINALLY_SUBMIT' \n" +
"@if(!isEmpty(studentId)) { \n" + "@if(!isEmpty(studentId)) { \n" +
"and t.student_id = #studentId# \n" + "and t.student_id = #studentId# \n" +
"@} \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 " "AND t.teacher_open_course_question_log_update_time IS NOT NULL "
) )
private String finishTime; private String finishTime;
public void setCorrectCount(int correctCount) { public void setCorrectCount(Integer correctCount) {
this.correctCount = correctCount; this.correctCount = correctCount;
tryCalcCorrectRate(); tryCalcCorrectRate();
} }
public void setWrongCount(int wrongCount) { public void setWrongCount(Integer wrongCount) {
this.wrongCount = wrongCount; this.wrongCount = wrongCount;
tryCalcCorrectRate(); tryCalcCorrectRate();
} }
public void setQuestionTotalCount(int questionTotalCount) { public void setQuestionTotalCount(Integer questionTotalCount) {
this.questionTotalCount = questionTotalCount; this.questionTotalCount = questionTotalCount;
tryCalcCorrectRate(); tryCalcCorrectRate();
} }
@ -137,16 +149,10 @@ public class TeacherOpenCourseQuestionLogScoreInfo extends BaseEntity {
* *
*/ */
private void tryCalcCorrectRate() { private void tryCalcCorrectRate() {
int sumTotalCount = getCorrectCount() + getWrongCount(); if (ObjectUtil.isAllNotEmpty(getCorrectCount(), getWrongCount(), getQuestionTotalCount())) {
if (sumTotalCount == 0) {
this.setCorrectRate(0); return;
}
if (getQuestionTotalCount() == sumTotalCount) {
// 计算正确率, 取小数点后2位数 // 计算正确率, 取小数点后2位数
// 计算规则:正确率 = 正确数量 / (正确数量 + 错误数量) * 100 // 计算规则:正确率 = 正确数量 / (正确数量 + 错误数量) * 100
this.setCorrectRate(NumberUtil this.setCorrectRate(NumberUtil.round(((float)getCorrectCount() / getQuestionTotalCount()) * 100, 2).floatValue());
.round(NumberUtil.div(getCorrectCount(), sumTotalCount) * 100, 2)
.floatValue());
} }
} }
} }

Loading…
Cancel
Save