From 65e31445e158ae105ae0434369ad054d9ac85fd2 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 26 Aug 2019 09:52:37 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=EF=BC=9A?= =?UTF-8?q?=E5=B7=B2=E5=8F=91=E5=B8=83=E7=9A=84=E5=AE=9E=E8=AE=AD=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E7=9A=84excel=E5=AF=BC=E5=87=BA=EF=BC=8C=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E7=9A=84=E9=93=BE=E6=8E=A5=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index b018e38d..093b3e4e 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -4206,7 +4206,7 @@ end sheet1[count_row, 5] = show_shixun_mirror(shixun) sheet1[count_row, 6] = shixun.fork_identifier sheet1[count_row, 7] = shixun.challenges.count - sheet1[count_row, 8] = Setting.server_url + shixun_path(shixun) + sheet1[count_row, 8] = Setting.server_url + shixun_path(shixun).sub("/", "") count_row += 1 end book.write xls_report From 34b254b9c8efdc87de30830fdc400826568f0c98 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Mon, 26 Aug 2019 09:58:37 +0800 Subject: [PATCH 2/5] fix school course count error bug --- app/controllers/managements_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 093b3e4e..b3d944f5 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -2084,7 +2084,7 @@ end @school_id = params[:school_id] if params[:school_id] && params[:school_id] != '' - @courses = @courses.joins("join user_extensions ue on courses.tea_id = ue.user_id").where("ue.school_id = #{params[:school_id]}") + @courses = @courses.where(school_id: params[:school_id]) end if params[:homepage_show] From 72da25070647937f23f796b2b2d6d6ae1ee95e8a Mon Sep 17 00:00:00 2001 From: p31729568 Date: Mon, 26 Aug 2019 15:58:08 +0800 Subject: [PATCH 3/5] competition team detail modify --- .../competition_teams_controller.rb | 16 ++- .../_competition_team_detail_course.html.erb | 52 ++++++++++ .../_competition_team_detail_shixun.html.erb | 68 +++++++++++++ .../competition_teams/course_detail.js.erb | 1 + .../competition_teams/shixun_detail.js.erb | 1 + app/views/competition_teams/show.html.erb | 99 ++++--------------- config/routes.rb | 2 + 7 files changed, 154 insertions(+), 85 deletions(-) create mode 100644 app/views/competition_teams/_competition_team_detail_course.html.erb create mode 100644 app/views/competition_teams/_competition_team_detail_shixun.html.erb create mode 100644 app/views/competition_teams/course_detail.js.erb create mode 100644 app/views/competition_teams/shixun_detail.js.erb 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 @@