|
|
@ -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)
|
|
|
|