一些子查询

beetlsql3-dev
Mlxa0324 2 years ago
parent 79146a80f0
commit 6af5baabb9

@ -57,37 +57,34 @@ public class TeacherOpenCourseQuestionLogScoreInfo extends BaseEntity {
// 答对数量
@FetchSql("select count(1) from teacher_open_course_question_log t " +
@FetchSql("select sum( ifnull( t.student_score > 0 , 0)) from teacher_open_course_question_log t " +
"where 1 = 1 " +
"and 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_answer = t.question_answer "
"and t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# "
)
private Integer correctCount;
// 答错数量
@FetchSql("select count(1) from teacher_open_course_question_log t " +
@FetchSql("select sum( ifnull( t.student_score <= 0 , 0)) 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_answer != t.question_answer "
"and t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# "
)
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 " +
"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_answer = t.question_answer "
"and t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# "
)
private float totalScore;

@ -134,7 +134,7 @@ public class TeacherOpenCourseQuestionSetting extends BaseEntity {
private int questionCount;
// 平均答对数量
@FetchSql("select sum(t.student_score > 0) / if(count(DISTINCT(t.student_id)) =0, 1, count(DISTINCT(t.student_id))) \n" +
@FetchSql("select sum( ifnull(t.student_score, 0) > 0) / count(DISTINCT(t.student_id)) \n" +
"from teacher_open_course_question_log t \n" +
"where t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT' " +
" AND t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# ")
@ -143,7 +143,7 @@ public class TeacherOpenCourseQuestionSetting extends BaseEntity {
private Integer avgSuccessCount;
// 平均答错数量
@FetchSql("select sum(t.student_score = 0) / if(count(DISTINCT(t.student_id)) =0, 1, count(DISTINCT(t.student_id))) \n" +
@FetchSql("select sum( ifnull(t.student_score, 0) <= 0) / count(DISTINCT(t.student_id)) \n" +
"from teacher_open_course_question_log t \n" +
"where t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT' " +
" AND t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# ")
@ -157,7 +157,7 @@ public class TeacherOpenCourseQuestionSetting extends BaseEntity {
private float avgSuccessRate;
// 平均得分
@FetchSql("select sum(t.student_score) / if(count(DISTINCT(t.student_id)) =0, 1, count(DISTINCT(t.student_id))) \n" +
@FetchSql("select ifnull(sum(t.student_score) / count(DISTINCT(t.student_id), 0) \n" +
"from teacher_open_course_question_log t \n" +
"where t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT' " +
" AND t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# ")
@ -228,25 +228,36 @@ public class TeacherOpenCourseQuestionSetting extends BaseEntity {
)
private String resourcesQuestionIdPlural;
/**
*
*/
@UpdateIgnore
@InsertIgnore
@FetchSql("select max(ifnull(t.teacher_open_course_question_log_finish_time , 0)) from teacher_open_course_question_log t " +
"where t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# " +
"and t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT'")
private String finishTime;
/**
*
*/
@UpdateIgnore
@InsertIgnore
@FetchSql("select round(sum(ifnull(t.student_score , 0)), 1) from teacher_open_course_question_log t " +
"where t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# " +
"and t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT' ")
private String myScore;
// TODO 下面这些查询在这里不合适
// /**
// * 用时(秒)
// */
// @UpdateIgnore
// @InsertIgnore
// @FetchSql("select max(TIMEDIFF( t.general_question_log_update_time , t.general_question_log_add_time )) as finish_time " +
// " from teacher_open_course_question_log t " +
// "where t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# " +
// "and t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT'")
// private Long finishTime;
// /**
// * 用时(秒)时间显示
// */
// @UpdateIgnore
// @InsertIgnore
// @FetchSql("select max(ifnull(t.teacher_open_course_question_log_finish_time , 0)) from teacher_open_course_question_log t " +
// "where t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# " +
// "and t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT'")
// private String finishSecondTime;
//
// /**
// * 我的得分
// */
// @UpdateIgnore
// @InsertIgnore
// @FetchSql("select round(sum(ifnull(t.student_score , 0)), 1) from teacher_open_course_question_log t " +
// "where t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# " +
// "and t.teacher_open_course_question_log_status = 1 and t.question_log_add_type = 'FINALLY_SUBMIT' ")
// private String myScore;
public void setAvgSuccessCount(Integer avgSuccessCount) {
this.avgSuccessCount = avgSuccessCount;

@ -856,7 +856,7 @@ getQuestionTestSimpleInfo
AND td.general_question_log_update_time IS NOT NULL
) as finish_time,
(
SELECT max(TIMESTAMPDIFF(SECOND, te.general_question_log_update_time , te.general_question_log_add_time )) as finish_second_time
SELECT abs(max(TIMESTAMPDIFF(SECOND, te.general_question_log_update_time , te.general_question_log_add_time ))) as finish_second_time
FROM general_question_log te
WHERE te.general_question_log_status = 1
@if(!isEmpty(studentId)) {

@ -643,7 +643,7 @@ getQuestionTestSimpleInfo
AND td.teacher_open_course_question_log_update_time IS NOT NULL
) as finish_time,
(
SELECT max(TIMESTAMPDIFF(SECOND, te.teacher_open_course_question_log_update_time , te.teacher_open_course_question_log_add_time )) as finish_second_time
SELECT abs(max(TIMESTAMPDIFF(SECOND, te.teacher_open_course_question_log_update_time , te.teacher_open_course_question_log_add_time ))) as finish_second_time
FROM teacher_open_course_question_log te
WHERE te.teacher_open_course_question_log_status = 1
@if(!isEmpty(studentId)) {

Loading…
Cancel
Save