毕设作品列表的已评数调整

dev_course
cxt 5 years ago
parent 952221970b
commit ddc67bc14f

@ -258,7 +258,7 @@ class Course < ApplicationRecord
# 是否具有分班权限,返回分班的id # 是否具有分班权限,返回分班的id
def group_course_power(user_id) def group_course_power(user_id)
teacher_course_groups.where(user_id: user_id).pluck(:id) teacher_course_groups.where(user_id: user_id).pluck(:course_group_id)
end end
#课程动态公共表记录 #课程动态公共表记录

@ -100,15 +100,15 @@ class GraduationTask < ApplicationRecord
SELECT count(distinct graduation_work_id) cnt FROM graduation_work_scores WHERE reviewer_role IN(1,2) AND graduation_work_id SELECT count(distinct graduation_work_id) cnt FROM graduation_work_scores WHERE reviewer_role IN(1,2) AND graduation_work_id
IN(SELECT id FROM graduation_works WHERE graduation_task_id = #{self.id} AND user_id IN(SELECT id FROM graduation_works WHERE graduation_task_id = #{self.id} AND user_id
IN(SELECT user_id FROM course_members WHERE role = 4 AND course_group_id IN(SELECT user_id FROM course_members WHERE role = 4 AND course_group_id
IN(SELECT course_group_id FROM teacher_course_groups WHERE id IN(#{course_group_ids.join(",")})) IN(#{course_group_ids.join(",")})
) )
) )
} }
else else
%Q{ %Q{
SELECT COUNT(distinct graduation_work_id) cnt FROM graduation_works gw SELECT COUNT(distinct graduation_work_id) cnt FROM graduation_works gw
JOIN graduation_work_scores gwc ON gw.graduation_task_id = gwc.graduation_task_id JOIN graduation_work_scores gwc ON gw.id = gwc.graduation_work_id
WHERE reviewer_role IN(1,2) AND gwc.graduation_task_id = #{self.id} WHERE reviewer_role IN(1,2) AND gw.graduation_task_id = #{self.id}
} }
end end
GraduationWorkScore.find_by_sql(sql).first.try(:cnt).to_i GraduationWorkScore.find_by_sql(sql).first.try(:cnt).to_i
@ -127,7 +127,7 @@ class GraduationTask < ApplicationRecord
sql = %Q{ sql = %Q{
SELECT count(*) cnt FROM graduation_works gw WHERE work_status = 0 AND gw.graduation_task_id = #{self.id} AND gw.user_id SELECT count(*) cnt FROM graduation_works gw WHERE work_status = 0 AND gw.graduation_task_id = #{self.id} AND gw.user_id
IN( SELECT user_id FROM course_members WHERE role = 4 AND course_group_id IN( SELECT user_id FROM course_members WHERE role = 4 AND course_group_id
IN( SELECT course_group_id FROM teacher_course_groups WHERE id not IN(#{course_group_ids.join(",")}) ) IN(#{course_group_ids.join(",")})
) )
} }
GraduationWork.find_by_sql(sql).first.try(:cnt) GraduationWork.find_by_sql(sql).first.try(:cnt)
@ -144,7 +144,7 @@ class GraduationTask < ApplicationRecord
sql = %Q{ sql = %Q{
SELECT count(*) cnt FROM graduation_works gw WHERE work_status = 1 AND gw.graduation_task_id = #{self.id} AND gw.user_id SELECT count(*) cnt FROM graduation_works gw WHERE work_status = 1 AND gw.graduation_task_id = #{self.id} AND gw.user_id
IN( SELECT user_id FROM course_members WHERE role = 4 AND course_group_id IN( SELECT user_id FROM course_members WHERE role = 4 AND course_group_id
IN( SELECT course_group_id FROM teacher_course_groups WHERE id IN(#{course_group_ids.join(",")}) ) IN(#{course_group_ids.join(",")})
) )
} }
GraduationWork.find_by_sql(sql).first.try(:cnt) GraduationWork.find_by_sql(sql).first.try(:cnt)
@ -160,7 +160,7 @@ class GraduationTask < ApplicationRecord
sql = %Q{ sql = %Q{
SELECT count(*) cnt FROM graduation_works gw WHERE work_status = 2 AND gw.graduation_task_id = #{self.id} AND gw.user_id SELECT count(*) cnt FROM graduation_works gw WHERE work_status = 2 AND gw.graduation_task_id = #{self.id} AND gw.user_id
IN( SELECT user_id FROM course_members WHERE role = 4 AND course_group_id IN( SELECT user_id FROM course_members WHERE role = 4 AND course_group_id
IN( SELECT course_group_id FROM teacher_course_groups WHERE id IN(#{course_group_ids.join(",")}) ) IN(#{course_group_ids.join(",")})
) )
} }
GraduationWork.find_by_sql(sql).first.try(:cnt) GraduationWork.find_by_sql(sql).first.try(:cnt)

@ -197,7 +197,7 @@ class HomeworkCommon < ApplicationRecord
JOIN student_works_scores sws on sws.student_work_id = sw.id WHERE JOIN student_works_scores sws on sws.student_work_id = sw.id WHERE
reviewer_role IN(1,2) AND sw.id IN (SELECT id FROM student_works WHERE homework_common_id = #{self.id} reviewer_role IN(1,2) AND sw.id IN (SELECT id FROM student_works WHERE homework_common_id = #{self.id}
AND user_id IN (SELECT user_id FROM course_members WHERE role = 4 AND course_group_id AND user_id IN (SELECT user_id FROM course_members WHERE role = 4 AND course_group_id
IN (SELECT course_group_id FROM teacher_course_groups WHERE id IN(#{course_group_ids.join(",")})) IN (#{course_group_ids.join(",")})
) )
) )
} }

Loading…
Cancel
Save