sql修复

beetlsql3-dev
Mlxa0324 2 years ago
parent 1097a4a88f
commit fdf30dd650

@ -417,7 +417,7 @@
Common.awaitTime(1200, function () { Common.awaitTime(1200, function () {
//window.location.href = ret.data; //window.location.href = ret.data;
// window.location.href = "http://116.205.131.177:8080/Login"; // window.location.href = "http://116.205.131.177:8080/Login";
window.location.href = Common.ctxPath; window.location.href = Common.ctxPath.replace(/\/server\/?/, '');
}); });
} }
}); });

@ -803,6 +803,21 @@ getQuestionTestSimpleInfo
* 学生端- 题目的简单信息(包含学生得分) * 学生端- 题目的简单信息(包含学生得分)
SELECT SELECT
@pageTag(){ @pageTag(){
z.general_question_setting_id,
z.general_question_setting_name,
z.general_question_setting_type,
z.general_question_start_time,
z.general_question_end_time,
z.question_total_count,
z.is_finished,
z.finish_time,
z.finish_second_time,
z.my_success_count,
round(z.my_success_count / z.question_total_count * 100, 2) as correct_rate
@}
FROM
(
SELECT
t.general_question_setting_id, t.general_question_setting_id,
t.general_question_setting_name, t.general_question_setting_name,
t.general_question_setting_type, t.general_question_setting_type,
@ -810,28 +825,19 @@ getQuestionTestSimpleInfo
t.general_question_end_time, t.general_question_end_time,
( (
SELECT SELECT
sum( @// 我的分数
@ // 已经交卷的状态才算分 sum( ta.student_score )
CASE WHEN ta.question_log_add_type = #questionLogAddType# THEN IFNULL( ta.student_score, 0 ) ELSE 0 END
)
FROM FROM
general_question_log ta general_question_log ta
WHERE WHERE
ta.general_question_setting_id = t.general_question_setting_id ta.general_question_setting_id = t.general_question_setting_id
and ta.general_question_log_status = 1 AND ta.general_question_log_status = 1
AND t.general_question_setting_status = 1 AND ta.question_log_add_type = #questionLogAddType#
AND t.general_question_setting_push_status = 1
AND ta.student_id = #studentId# AND ta.student_id = #studentId#
) AS my_score, ) AS my_score,
( @// 题目总数
SELECT ( SELECT count( 1 ) FROM general_resources_question_snapshot tb WHERE tb.general_question_setting_id = t.general_question_setting_id AND tb.question_status = 1 ) AS question_total_count,
count( 1 ) @// 是否交卷
FROM
general_resources_question_snapshot tb
WHERE
tb.general_question_setting_id = t.general_question_setting_id
AND tb.question_status = 1
) AS question_total_count,
( (
SELECT SELECT
count( 1 ) > 0 count( 1 ) > 0
@ -840,55 +846,59 @@ getQuestionTestSimpleInfo
WHERE WHERE
tc.general_question_setting_id = t.general_question_setting_id tc.general_question_setting_id = t.general_question_setting_id
AND tc.general_question_log_status = 1 AND tc.general_question_log_status = 1
@ // 是否已交卷
AND tc.question_log_add_type = #questionLogAddType# AND tc.question_log_add_type = #questionLogAddType#
LIMIT 1 LIMIT 1
) AS is_finished, ) AS is_finished,
@// 完成时间 00:00:00
( (
SELECT max(TIMEDIFF( td.general_question_log_update_time , td.general_question_log_add_time )) as finish_time SELECT
FROM general_question_log td max(
WHERE td.general_question_log_status = 1 TIMEDIFF( td.general_question_log_update_time, td.general_question_log_add_time )) AS finish_time
@if(!isEmpty(studentId)) { FROM
and td.student_id = #studentId# general_question_log td
@} WHERE
and td.question_log_add_type = #questionLogAddType# td.general_question_log_status = 1
and td.general_question_setting_id = t.general_question_setting_id AND td.student_id = #studentId#
AND td.general_question_log_update_time IS NOT NULL AND td.question_log_add_type = #questionLogAddType#
) as finish_time, AND td.general_question_setting_id = t.general_question_setting_id
) AS finish_time,
@// 完成时间(秒)
( (
SELECT abs(max(TIMESTAMPDIFF(SECOND, te.general_question_log_update_time , te.general_question_log_add_time ))) as finish_second_time SELECT
FROM general_question_log te abs(
WHERE te.general_question_log_status = 1 max(
@if(!isEmpty(studentId)) { TIMESTAMPDIFF( SECOND, te.general_question_log_update_time, te.general_question_log_add_time )))
and te.student_id = #studentId# FROM
@} general_question_log te
and te.question_log_add_type = #questionLogAddType# WHERE
and te.general_question_setting_id = t.general_question_setting_id te.general_question_log_status = 1
AND te.general_question_log_update_time IS NOT NULL AND te.student_id = #studentId#
) as finish_second_time, AND te.question_log_add_type = #questionLogAddType#
AND te.general_question_setting_id = t.general_question_setting_id
) AS finish_second_time,
@// 题目正确数大于0就算对的
( (
SELECT round(sum(case when tf.question_score = tf.student_score then 1 else 0 end) SELECT
/ ifnull(count(distinct(tf.general_resources_question_snapshot_id)), 0) * 100, 2) as finish_second_time sum( tf.student_score > 0 )
FROM general_question_log tf FROM
WHERE tf.general_question_log_status = 1 general_question_log tf
@if(!isEmpty(studentId)) { WHERE
and tf.student_id = #studentId# tf.general_question_log_status = 1
@} AND tf.student_id = #studentId#
and tf.question_log_add_type = #questionLogAddType# AND tf.question_log_add_type = #questionLogAddType#
and tf.general_question_setting_id = t.general_question_setting_id AND tf.general_question_setting_id = t.general_question_setting_id
AND tf.general_question_log_update_time IS NOT NULL ) AS my_success_count
) as correct_rate
@}
FROM FROM
general_question_setting t general_question_setting t
left join course_info za on za.course_info_id = t.business_id and t.business_type = 'FROM_SYSTEM'
WHERE WHERE
1 = 1 1 = 1
AND t.general_question_setting_type = #generalQuestionSettingType# AND t.general_question_setting_type = #teacherOpenCourseQuestionSettingType#
AND t.general_question_setting_push_status = 1 AND t.general_question_setting_push_status = 1
AND t.general_question_setting_status = 1 AND t.general_question_setting_status = 1
AND za.course_info_parent_id = #courseInfoParentId# AND t.general_id = #teacherOpenCourseId#
order by t.general_question_setting_name asc ORDER BY
t.general_question_setting_name ASC
) z
questionTestResults questionTestResults

@ -589,8 +589,24 @@ getValuesByQueryNotWithPermission
getQuestionTestSimpleInfo getQuestionTestSimpleInfo
=== ===
* 学生端- 题目的简单信息(包含学生得分) * 学生端- 题目的简单信息(包含学生得分)
SELECT SELECT
@pageTag(){ @pageTag(){
z.teacher_open_course_question_setting_id,
z.teacher_open_course_question_setting_name,
z.teacher_open_course_question_setting_type,
z.teacher_open_course_question_start_time,
z.teacher_open_course_question_end_time,
z.question_total_count,
z.is_finished,
z.finish_time,
z.finish_second_time,
z.my_success_count,
round(z.my_success_count / z.question_total_count * 100, 2) as correct_rate
@}
FROM
(
SELECT
t.teacher_open_course_question_setting_id, t.teacher_open_course_question_setting_id,
t.teacher_open_course_question_setting_name, t.teacher_open_course_question_setting_name,
t.teacher_open_course_question_setting_type, t.teacher_open_course_question_setting_type,
@ -598,27 +614,19 @@ getQuestionTestSimpleInfo
t.teacher_open_course_question_end_time, t.teacher_open_course_question_end_time,
( (
SELECT SELECT
@// 我的分数
sum( ta.student_score ) sum( ta.student_score )
FROM FROM
teacher_open_course_question_log ta teacher_open_course_question_log ta
WHERE WHERE
ta.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id ta.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id
and ta.teacher_open_course_question_log_status = 1 AND ta.teacher_open_course_question_log_status = 1
AND t.teacher_open_course_question_setting_status = 1
AND t.teacher_open_course_question_setting_push_status = 1
@ // 是否已交卷
AND ta.question_log_add_type = #questionLogAddType# AND ta.question_log_add_type = #questionLogAddType#
AND ta.student_id = #studentId# AND ta.student_id = #studentId#
) AS my_score, ) AS my_score,
( @// 题目总数
SELECT ( SELECT count( 1 ) FROM resources_question_snapshot tb WHERE tb.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id AND tb.question_status = 1 ) AS question_total_count,
count( 1 ) @// 是否交卷
FROM
resources_question_snapshot tb
WHERE
tb.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id
AND tb.question_status = 1
) AS question_total_count,
( (
SELECT SELECT
count( 1 ) > 0 count( 1 ) > 0
@ -627,51 +635,48 @@ getQuestionTestSimpleInfo
WHERE WHERE
tc.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id tc.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id
AND tc.teacher_open_course_question_log_status = 1 AND tc.teacher_open_course_question_log_status = 1
@ // 是否已交卷
AND tc.question_log_add_type = #questionLogAddType# AND tc.question_log_add_type = #questionLogAddType#
LIMIT 1 LIMIT 1
) AS is_finished, ) AS is_finished,
@// 完成时间 00:00:00
( (
SELECT max(TIMEDIFF( td.teacher_open_course_question_log_update_time , td.teacher_open_course_question_log_add_time )) as finish_time SELECT
FROM teacher_open_course_question_log td max(
WHERE td.teacher_open_course_question_log_status = 1 TIMEDIFF( td.teacher_open_course_question_log_update_time, td.teacher_open_course_question_log_add_time )) AS finish_time
@if(!isEmpty(studentId)) { FROM
and td.student_id = #studentId# teacher_open_course_question_log td
@} WHERE
and td.question_log_add_type = #questionLogAddType# td.teacher_open_course_question_log_status = 1
and td.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id AND td.student_id = #studentId#
) as finish_time, AND td.question_log_add_type = #questionLogAddType#
AND td.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id
) AS finish_time,
@// 完成时间(秒)
( (
SELECT abs(max(TIMESTAMPDIFF(SECOND, te.teacher_open_course_question_log_update_time , te.teacher_open_course_question_log_add_time ))) SELECT
FROM teacher_open_course_question_log te abs(
WHERE te.teacher_open_course_question_log_status = 1 max(
@if(!isEmpty(studentId)) { TIMESTAMPDIFF( SECOND, te.teacher_open_course_question_log_update_time, te.teacher_open_course_question_log_add_time )))
and te.student_id = #studentId# FROM
@} teacher_open_course_question_log te
and te.question_log_add_type = #questionLogAddType# WHERE
and te.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id te.teacher_open_course_question_log_status = 1
) as finish_second_time, AND te.student_id = #studentId#
round( AND te.question_log_add_type = #questionLogAddType#
AND te.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id
) AS finish_second_time,
@// 题目正确数大于0就算对的
( (
SELECT sum(tf.student_score <> 1 )
FROM teacher_open_course_question_log tf
WHERE tf.teacher_open_course_question_log_status = 1
@if(!isEmpty(studentId)) {
and tf.student_id = #studentId#
@}
and tf.question_log_add_type = #questionLogAddType#
and tf.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id
) / (
SELECT SELECT
count(DISTINCT ( t.resources_question_snapshot_id )) sum( tf.student_score > 0 )
FROM FROM
resources_question_snapshot t teacher_open_course_question_log tf
WHERE WHERE
1 = 1 tf.teacher_open_course_question_log_status = 1
AND t.question_status = 1 AND tf.student_id = #studentId#
AND t.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id AND tf.question_log_add_type = #questionLogAddType#
) ,2) * 100 as correct_rate AND tf.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id
@} ) AS my_success_count
FROM FROM
teacher_open_course_question_setting t teacher_open_course_question_setting t
WHERE WHERE
@ -680,8 +685,9 @@ getQuestionTestSimpleInfo
AND t.teacher_open_course_question_setting_push_status = 1 AND t.teacher_open_course_question_setting_push_status = 1
AND t.teacher_open_course_question_setting_status = 1 AND t.teacher_open_course_question_setting_status = 1
AND t.teacher_open_course_id = #teacherOpenCourseId# AND t.teacher_open_course_id = #teacherOpenCourseId#
order by t.teacher_open_course_question_setting_name asc ORDER BY
t.teacher_open_course_question_setting_name ASC
) z
questionTestResults questionTestResults
=== ===

Loading…
Cancel
Save