@ -149,7 +149,7 @@ class Competitions::CompetitionTeamsController < Competitions::BaseController
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('sum(compelete_status !=0 ) as finish, count(*) as total')
.select('sum(compelete_status >0 ) as finish, count(*) as total')
.having('total != 0 and finish >= (total / 2)').to_sql
@ -160,7 +160,7 @@ class Competitions::CompetitionTeamsController < Competitions::BaseController
defget_valid_shixun_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('sum(compelete_status !=0 ) as finish, count(*) as total')
.select('sum(compelete_status >0 ) as finish, count(*) as total')
.having('total != 0 and finish >= (total / 2)').to_sql
@videos=@videos.select("course_videos.id, videos.user_id, videos.title AS video_title, IFNULL(hisotries.time,0) AS total_time, IFNULL(hisotries.num,0) AS people_num")
@videos=paginate@videos
end
# 学生角度观看课堂视频的记录
defown_watch_histories
@current_user=current_user
@videos=CourseVideo.joins("
JOINvideosONcourse_videos.course_id=#{@course.id} AND videos.id = course_videos.video_id
@videos=@videos.select("course_videos.id, watch_course_videos.id AS watch_course_video_id, course_videos.video_id, watch_course_videos.start_at, watch_course_videos.total_duration, watch_course_videos.end_at, watch_course_videos.is_finished, videos.title, IFNULL(hisotries.num,0) AS freq")
@videos=paginate@videos
end
# 课堂视频的统计总览
defwatch_statics
course_videos=@course.course_videos.joins(:watch_course_videos).joins("JOIN course_members ON course_members.user_id = watch_course_videos.user_id AND course_members.course_id = #{@course.id} AND role = 4").where("watch_course_videos.end_at IS NOT NULL")
@frequencies=course_videos.joins("JOIN watch_video_histories ON watch_course_videos.id = watch_video_histories.watch_course_video_id AND watch_video_histories.end_at IS NOT NULL").count(:id)
@frequencies=course_videos.joins("JOIN watch_video_histories ON watch_course_videos.id = watch_video_histories.watch_course_video_id AND watch_video_histories.end_at IS NOT NULL").count(:id)
@num=course_videos.count(:id)
end
renderjson:{
total_duration:@total_duration,
freq:@frequencies,
num:@num,
begin_at:'2020-03-13 24:00'
}
end
private
# Use callbacks to share common setup or constraints between actions.
where("(attendance_date = '#{current_date}' and start_time <= '#{current_end_time}' and end_time > '#{current_end_time}') or (attendance_date > '#{current_date}')").pluck(:id)
where("(attendance_date = '#{current_date}' and end_time > '#{current_end_time}') or (attendance_date > '#{current_date}')").pluck(:id)