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

翻转课堂

+ + + + + + + + + + + + + <% + total_members_count = 0 + total_shixun_homework_count = 0 + total_course_score = 0 + %> + <% @courses.each do |course| %> + <% + total_members_count += course.members_count.to_i + total_shixun_homework_count += course['shixun_homework_count'].to_i + + score = 500 + 5 * @course_shixun_count_map.fetch(course.id, 0) * @course_myshixun_map.fetch(course.id, 0) + total_course_score += score + %> + + + + + + + + + <% end %> + + + + + + + + + + + +
创建者名称学生数量发布的实训作业数量有效作品数经验值
<%= 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 %>
\ No newline at end of file diff --git a/app/views/competition_teams/_competition_team_detail_shixun.html.erb b/app/views/competition_teams/_competition_team_detail_shixun.html.erb new file mode 100644 index 00000000..993fcc4b --- /dev/null +++ b/app/views/competition_teams/_competition_team_detail_shixun.html.erb @@ -0,0 +1,68 @@ +

实训项目

+ + + + + + + + + + + + + <% + total_myshixun_count = 0 + total_forked_myshixun_count = 0 + total_shixun_score = 0 + %> + <% @shixuns.each do |shixun| %> + <% + total_myshixun_count += shixun.myshixuns_count + total_forked_myshixun_count += shixun['forked_myshixun_count'].to_i + + valid_course_count = @course_count_map.fetch(shixun.id, 0) + valid_student_count = @original_myshixun_count_map.fetch(shixun.id, 0) + score = + if shixun.fork_from.blank? + 500 + 50 * valid_course_count + 10 * valid_student_count + else + 100 + 10 * valid_course_count + 5 * valid_student_count + end + + @forked_shixun_map.each do |shixun_id, fork_from_id| + next if fork_from_id != shixun.id + + score += 100 + 10 * @forked_map.fetch(shixun_id, 0) + 5 * @forked_myshixun_count_map.fetch(shixun_id, 0) + end + + total_shixun_score += score + %> + + + + + + + + + <% end %> + + + + + + + + + + + +
创建者名称学习人数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 %>
\ No newline at end of file diff --git a/app/views/competition_teams/course_detail.js.erb b/app/views/competition_teams/course_detail.js.erb new file mode 100644 index 00000000..29e6e799 --- /dev/null +++ b/app/views/competition_teams/course_detail.js.erb @@ -0,0 +1 @@ +$('.competition-detail-course').html("<%= j(render :partial => 'competition_team_detail_course') %>"); \ No newline at end of file diff --git a/app/views/competition_teams/shixun_detail.js.erb b/app/views/competition_teams/shixun_detail.js.erb new file mode 100644 index 00000000..34e48cb9 --- /dev/null +++ b/app/views/competition_teams/shixun_detail.js.erb @@ -0,0 +1 @@ +$('.competition-detail-shixun').html("<%= j(render :partial => 'competition_team_detail_shixun') %>"); \ No newline at end of file diff --git a/app/views/competition_teams/show.html.erb b/app/views/competition_teams/show.html.erb index 66fe48d7..74cad257 100644 --- a/app/views/competition_teams/show.html.erb +++ b/app/views/competition_teams/show.html.erb @@ -3,7 +3,7 @@ 战队详情 <%= link_to '返回', enroll_competition_path(@competition), class: 'color-grey-9 fr' %>

-
+

实训项目

@@ -17,64 +17,22 @@ - <% - total_myshixun_count = 0 - total_forked_myshixun_count = 0 - total_shixun_score = 0 - %> - <% @shixuns.each do |shixun| %> - <% - total_myshixun_count += shixun.myshixuns_count - total_forked_myshixun_count += shixun['forked_myshixun_count'].to_i - - valid_course_count = @course_count_map.fetch(shixun.id, 0) - valid_student_count = @original_myshixun_count_map.fetch(shixun.id, 0) - score = - if shixun.fork_from.blank? - 500 + 50 * valid_course_count + 10 * valid_student_count - else - 100 + 10 * valid_course_count + 5 * valid_student_count - end - - @forked_shixun_map.each do |shixun_id, fork_from_id| - next if fork_from_id != shixun.id - - score += 100 + 10 * @forked_map.fetch(shixun_id, 0) + 5 * @forked_myshixun_count_map.fetch(shixun_id, 0) - end - - total_shixun_score += score - %> - - - - - - - - - <% end %> + - - - - - + + + + +
<%= 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 %>
-
+

翻转课堂

@@ -88,41 +46,16 @@ - <% - total_members_count = 0 - total_shixun_homework_count = 0 - total_course_score = 0 - %> - <% @courses.each do |course| %> - <% - total_members_count += course.members_count.to_i - total_shixun_homework_count += course['shixun_homework_count'].to_i - - score = 500 + 5 * @course_shixun_count_map.fetch(course.id, 0) * @course_myshixun_map.fetch(course.id, 0) - total_course_score += score - %> - - - - - - - - - <% end %> + - - - - - + + + + +
<%= 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 %>
@@ -131,6 +64,10 @@