.where("exists(select 1 from homework_commons hcs where hcs.course_id = courses.id and hcs.homework_type = 4 and exists(#{subquery}))")
.where("exists(select 1 from homework_commons hcs where hcs.course_id = courses.id and hcs.publish_time is not null and hcs.publish_time < NOW() and hcs.homework_type = 4 and exists(#{subquery}))")
.joins('join course_members on course_members.course_id = courses.id and course_members.role in (1,2,3)')
@ -366,8 +366,8 @@ class CompetitionTeamsController < ApplicationController
defget_valid_course_count(ids)
percentage_sql=StudentWork.where('homework_common_id = homework_commons.id and homework_commons.publish_time is not null and homework_commons.publish_time < NOW()')
.select('count(compelete_status !=0 ) as finish, count(*) as total')
.having('finish > (total / 2)').to_sql
.select('sum(compelete_status !=0 ) as finish, count(*) as total')
.select('count(compelete_status !=0 ) as finish, count(*) as total')
percentage_sql=StudentWork.where('homework_common_id = homework_commons.id and homework_commons.publish_time is not null and homework_commons.publish_time < NOW()')
.select('sum(compelete_status !=0 ) as finish, count(*) as total')