diff --git a/app/controllers/competition_teams_controller.rb b/app/controllers/competition_teams_controller.rb index b1d6788e..cfae2acf 100644 --- a/app/controllers/competition_teams_controller.rb +++ b/app/controllers/competition_teams_controller.rb @@ -14,6 +14,10 @@ class CompetitionTeamsController < ApplicationController def show return render_404 if @competition.identifier != 'gcc-course-2019' + end + + def shixun_detail + return render_404 if @competition.identifier != 'gcc-course-2019' @team_user_ids = @team.team_members.pluck(:user_id) @@ -40,13 +44,17 @@ class CompetitionTeamsController < ApplicationController @forked_course_count_map[forked_shixun_map[forked_id]] += course_count end @forked_shixun_map = forked_shixun_map + end + def course_detail + return render_404 if @competition.identifier != 'gcc-course-2019' + + @team_user_ids = @team.team_members.pluck(:user_id) - # 课堂 student_count_subquery = CourseMember.where('course_id = courses.id AND role = 4').select('count(*)').to_sql subquery = StudentWork.where('homework_common_id = hcs.id') - .select('sum(compelete_status !=0 ) as finish, count(*) as total') - .having('total != 0 and finish >= (total / 2)').to_sql + .select('sum(compelete_status !=0 ) as finish, count(*) as total') + .having('total != 0 and finish >= (total / 2)').to_sql course_ids = Course.where('courses.created_at > ?', Time.parse('2018-06-01')) .where('courses.created_at <= ?', @competition.end_time) .where("(#{student_count_subquery}) >= 3") @@ -55,7 +63,7 @@ class CompetitionTeamsController < ApplicationController .where(course_members: { user_id: @team_user_ids }).pluck(:id) courses = Course.where(id: course_ids).joins(:shixun_homework_commons).where('homework_commons.publish_time < now()') @courses = courses.select('courses.id, courses.name, courses.members_count, count(*) shixun_homework_count') - .group('courses.id').order('shixun_homework_count desc').having('shixun_homework_count > 0') + .group('courses.id').order('shixun_homework_count desc').having('shixun_homework_count > 0') course_ids = @courses.map(&:id) @course_myshixun_map = Myshixun.joins(student_works: :homework_common) diff --git a/app/views/competition_teams/_competition_team_detail_course.html.erb b/app/views/competition_teams/_competition_team_detail_course.html.erb new file mode 100644 index 00000000..6f9015d2 --- /dev/null +++ b/app/views/competition_teams/_competition_team_detail_course.html.erb @@ -0,0 +1,52 @@ + +
翻转课堂
+创建者 | +名称 | +学生数量 | +发布的实训作业数量 | +有效作品数 | +经验值 | +
---|---|---|---|---|---|
<%= course.teachers.where(user_id: @team_user_ids).first.user.show_real_name %> | ++ <%= link_to course_path(course), target: '_blank' do %> + <%= course.name %> + <% end %> + | +<%= course.members_count %> | +<%= course['shixun_homework_count'].presence || '--' %> | +<%= @course_myshixun_map.fetch(course.id, '--') %> | +<%= score.zero? ? '--' : score %> | +
合计 | +<%= @courses.size %> | +<%= total_members_count %> | +<%= total_shixun_homework_count %> | +<%= @course_myshixun_map.values.reduce(:+) || 0 %> | +<%= total_course_score %> | +
实训项目
+创建者 | +名称 | +学习人数 | +fork版的学习人数 | +有效作品数 | +经验值 | +
---|---|---|---|---|---|
<%= shixun.creator.show_real_name %> | ++ <%= link_to shixun_path(shixun), target: '_blank' do %> + <%= shixun.name %> + <% end %> + <% if shixun.fork_from.blank? %> + 原创 + <% end %> + | +<%= shixun.myshixuns_count.to_i.zero? ? '--' : shixun.myshixuns_count.to_i %> | +<%= shixun['forked_myshixun_count'].to_i.zero? ? '--' : shixun['forked_myshixun_count'].to_i %> | +<%= @myshixun_count_map.fetch(shixun.id, '--') %> | +<%= score.zero? ? '--' : score %> | +
合计 | +<%= @shixuns.size %> | +<%= total_myshixun_count %> | +<%= total_forked_myshixun_count %> | +<%= @myshixun_count_map.values.reduce(:+) %> | +<%= total_shixun_score %> | +
实训项目
<%= shixun.creator.show_real_name %> | -- <%= link_to shixun_path(shixun), target: '_blank' do %> - <%= shixun.name %> - <% end %> - <% if shixun.fork_from.blank? %> - 原创 - <% end %> - | -<%= shixun.myshixuns_count.to_i.zero? ? '--' : shixun.myshixuns_count.to_i %> | -<%= shixun['forked_myshixun_count'].to_i.zero? ? '--' : shixun['forked_myshixun_count'].to_i %> | -<%= @myshixun_count_map.fetch(shixun.id, '--') %> | -<%= score.zero? ? '--' : score %> | -||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
加载中... | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
合计 | -<%= @shixuns.size %> | -<%= total_myshixun_count %> | -<%= total_forked_myshixun_count %> | -<%= @myshixun_count_map.values.reduce(:+) %> | -<%= total_shixun_score %> | ++ | + | + | + |
---|
翻转课堂
<%= course.teachers.where(user_id: @team_user_ids).first.user.show_real_name %> | -- <%= link_to course_path(course), target: '_blank' do %> - <%= course.name %> - <% end %> - | -<%= course.members_count %> | -<%= course['shixun_homework_count'].presence || '--' %> | -<%= @course_myshixun_map.fetch(course.id, '--') %> | -<%= score.zero? ? '--' : score %> | -||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
加载中... | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
合计 | -<%= @courses.size %> | -<%= total_members_count %> | -<%= total_shixun_homework_count %> | -<%= @course_myshixun_map.values.reduce(:+) || 0 %> | -<%= total_course_score %> | ++ | + | + | + |
---|