From af72a800ce389fbc9db0d5a9625d532c91101f02 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Fri, 5 Jul 2019 10:24:16 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E6=88=98=E9=98=9F=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_competition_team_detail.html.erb | 113 +++++++++++++----- public/stylesheets/educoder/edu-all.css | 41 +++++++ 2 files changed, 125 insertions(+), 29 deletions(-) diff --git a/app/views/competitions/_competition_team_detail.html.erb b/app/views/competitions/_competition_team_detail.html.erb index 9574db58..a44f8717 100644 --- a/app/views/competitions/_competition_team_detail.html.erb +++ b/app/views/competitions/_competition_team_detail.html.erb @@ -1,39 +1,94 @@ -
-

+

+

战队详情 返回

-
-

实训项目

- - - - - - - - +
+

实训项目

+
创建者名称学习人数fork版的学习人数有效作品数制作应用经验值
+ + + + + + + + + - - - - - - - + + + + + + + + + + + + + + + + + + +
创建者名称学习人数fork版的学习人数有效作品数经验值
胡莎莎 - 单链表的学习与应用(I) - 2.5万14562.5万4545667
张三 + MySQL数据库编程开发实训(基础入门篇)MySQL数据库编程开发实训(基础入门篇) + 原创 + 1545124611154987
合计612万112233
+
+ +
+

翻转课堂

+ + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + + +
创建者名称学生数量发布的实训作业数量有效作品数经验值
张三 + MySQL数据库编程开发实训(基础入门篇)MySQL数据库编程开发实训(基础入门篇) + 1545124611154987
合计:65.5万78782.5万245364
合计612万112233
-
\ No newline at end of file +
+ + \ No newline at end of file diff --git a/public/stylesheets/educoder/edu-all.css b/public/stylesheets/educoder/edu-all.css index 60018b85..13639287 100644 --- a/public/stylesheets/educoder/edu-all.css +++ b/public/stylesheets/educoder/edu-all.css @@ -728,6 +728,47 @@ li.challenge_box:last-child{ width: 360px;height: 70px;background: #2CDAD4;color: #fff!important;font-size: 30px;line-height: 70px;text-align: center; margin:0px auto;display: block; } +table.tBodyScroll tbody tr td{ + padding:6px 5px;box-sizing: border-box;font-size: 16px;color: #05101A;font-weight: normal; +} +table.tBodyScroll tbody { + display:block; + max-height:420px; + overflow-y:auto; +} +.connectTag{ + display: inline-block;background: #4CACFF;border-radius: 12px;height: 24px;line-height: 24px;color: #fff; + padding:0px 12px;font-size: 14px; +} +table.tBodyScroll thead,table.tBodyScroll tfoot,table.tBodyScroll tbody tr { + display:table; + width:100%; + table-layout:fixed; +} + +table.tBodyScroll thead,table.tBodyScroll tfoot { + width:100%; +} +table.tBodyScroll tfoot tr th{ + padding:10px 5px;box-sizing: border-box;border-top: 1px solid #eaeaea;font-weight: normal!important; +} +.lastPart,.tfootLastPart{ + width: calc( 100% - 1em )!important; +} +.lastPart tr th:last-child,.tfootLastPart tr th:last-child{position: relative;} +.tfootLastPart tr th:last-child:after{ + content: '';width: 1em;height: 100%;position: absolute;right: -1em;top:0px;border-top: 1px solid #eaeaea; +} +.lastPart tr th:last-child:after{ + content: '';background: #F5F5F5;width: 1em;height: 100%;position: absolute;right: -1em;top:0px +} +table.tBodyScroll thead th{ + background: #F5F5F5;color: #656565;padding:10px 5px;box-sizing: border-box; +} +.modalTitle{display: block;padding: 0px 30px;position: relative;line-height: 20px} +.modalTitle:before{ + position: absolute;height: 100%;width: 2px;content: '';background: #4cacff;left: 0px;top: 0px; +} From d7ce826e5691fdb27de307a5e3cfbf42eaad4dba Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 5 Jul 2019 11:15:34 +0800 Subject: [PATCH 02/10] add competition feature --- .../competition_teams_controller.rb | 27 ++++ app/controllers/competitions_controller.rb | 14 ++- .../_competition_team_form.html.erb | 5 +- app/views/competition_teams/show.html.erb | 118 ++++++++++++++++++ .../_competition_team_detail.html.erb | 94 -------------- app/views/competitions/_header.html.erb | 2 +- app/views/competitions/enroll.html.erb | 2 +- app/views/competitions/index.html.erb | 18 +++ app/views/competitions/publish.js.erb | 1 + app/views/managements/_competionList.html.erb | 4 + config/routes.rb | 1 + ...021338_add_published_at_to_competitions.rb | 5 + 12 files changed, 188 insertions(+), 103 deletions(-) create mode 100644 app/views/competition_teams/show.html.erb delete mode 100644 app/views/competitions/_competition_team_detail.html.erb create mode 100644 app/views/competitions/publish.js.erb create mode 100644 db/migrate/20190705021338_add_published_at_to_competitions.rb diff --git a/app/controllers/competition_teams_controller.rb b/app/controllers/competition_teams_controller.rb index f39c7708..6ecbb9aa 100644 --- a/app/controllers/competition_teams_controller.rb +++ b/app/controllers/competition_teams_controller.rb @@ -12,6 +12,33 @@ class CompetitionTeamsController < ApplicationController @team_user = User.current end + def show + return render_404 if @competition.identifier != 'gcc-course-2019' + + @team_user_ids = @team.team_members.pluck(:user_id) + + shixuns = Shixun.where(user_id: @team_user_ids, status: 2) + shixuns = shixuns.joins('left join shixuns forked_shixuns on forked_shixuns.fork_from = shixuns.id and forked_shixuns.status = 2') + shixuns = shixuns.joins('left join myshixuns on myshixuns.shixun_id = shixuns.id and exists(select 1 from games where games.myshixun_id = myshixuns.id and games.status = 2)') + shixuns = shixuns.select('shixuns.id, shixuns.identifier, shixuns.user_id, shixuns.myshixuns_count, shixuns.name, shixuns.fork_from, sum(forked_shixuns.myshixuns_count) forked_myshixun_count') + @shixuns = shixuns.group('shixuns.id').order('shixuns.myshixuns_count desc').includes(:creator) + @myshixun_count_map = Myshixun.where(shixun_id: @shixuns.map(&:id)) + .where('exists(select 1 from games where games.myshixun_id = myshixuns.id and games.status = 2)') + .group('shixun_id').count + + course_ids = Course.joins('join members on members.course_id = courses.id') + .joins('join member_roles on member_roles.member_id = members.id and member_roles.role_id in (3,7,9)') + .where(members: { user_id: @team_user_ids }).pluck(:id) + courses = Course.where(id: course_ids).joins(:shixun_homework_commons) + @courses = courses.select('courses.id, courses.name, courses.members_count, count(*) shixun_homework_count') + .group('courses.id').order('shixun_homework_count desc') + + @course_myshixun_map = Myshixun.joins(student_works: :homework_common) + .where(homework_commons: { course_id: @courses.map(&:id) }) + .where('exists(select 1 from games where games.myshixun_id = myshixuns.id and games.status = 2)') + .group('homework_commons.course_id').count + end + def search_teacher if params[:team] && params[:team] != "" @team = @competition.competition_teams.where(:id => params[:team]).first diff --git a/app/controllers/competitions_controller.rb b/app/controllers/competitions_controller.rb index 0e9fb376..a868cbf0 100644 --- a/app/controllers/competitions_controller.rb +++ b/app/controllers/competitions_controller.rb @@ -4,7 +4,7 @@ class CompetitionsController < ApplicationController :edit_md_content, :update_md_content, :new_competition_stage, :new_stage_section, :update_competition_stage] before_filter :find_inform, :only => [:edit_inform, :update_inform] - before_filter :require_login, :only => [:enroll_portal] + before_filter :require_login, :only => [:enroll_portal, :publish] skip_before_filter :verify_authenticity_token, :only => [:edit_rule] layout 'base_competition' @@ -25,7 +25,7 @@ class CompetitionsController < ApplicationController end def index - @competitions = Competition.where(:status => 1).reorder("online_time desc") + @competitions = Competition.where('status = 1 or published_at is not null').reorder("published_at desc, online_time desc") respond_to do |format| format.html { render :layout => "base_edu"} format.js @@ -438,10 +438,10 @@ class CompetitionsController < ApplicationController def online_switch if @competition.present? if @competition.status - @competition.update_attributes(:status => 0) + @competition.update_attributes(status: false, published_at: nil) @btn_html = "上架" else - @competition.update_attributes(:status => 1, :online_time => Time.now) + @competition.update_attributes(status: true, online_time: Time.now, published_at: nil) @btn_html = "下架" end end @@ -601,6 +601,12 @@ class CompetitionsController < ApplicationController @competition.competition_stage_sections.where(:id => params[:section_id]).destroy_all end + def publish + return render_403 unless admin_or_business? + + @competition.update_column(:published_at, Time.now) + end + private def chart_exp_score_mo myshixuns, s_time, e_time diff --git a/app/views/competition_teams/_competition_team_form.html.erb b/app/views/competition_teams/_competition_team_form.html.erb index fbba4618..c68cc3b2 100644 --- a/app/views/competition_teams/_competition_team_form.html.erb +++ b/app/views/competition_teams/_competition_team_form.html.erb @@ -24,13 +24,12 @@
- autocomplete="off" placeholder="请您输入老师姓名进行搜索;可以后续再添加导师" id="teacher_search_input" - value="<%= @team.try(:id).present? ? @team.teacher.try(:show_name) : (@team_user.user_extensions.identity == 0 ? @team_user.show_name : "") %>"> + "> "> - +
diff --git a/app/views/competition_teams/show.html.erb b/app/views/competition_teams/show.html.erb new file mode 100644 index 00000000..31937688 --- /dev/null +++ b/app/views/competition_teams/show.html.erb @@ -0,0 +1,118 @@ +
+

+ 战队详情 + <%= link_to '返回', enroll_competition_path(@competition), class: 'color-grey-9 fr' %> +

+
+

实训项目

+ + + + + + + + + + + + + <% + total_myshixun_count = 0 + total_forked_myshixun_count = 0 + %> + <% @shixuns.each do |shixun| %> + <% + total_myshixun_count += shixun.myshixuns_count + total_forked_myshixun_count += shixun['forked_myshixun_count'].to_i + %> + + + + + + + + + <% 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, '--') %>--
合计<%= @shixuns.size %><%= total_myshixun_count %><%= total_forked_myshixun_count %><%= @myshixun_count_map.values.reduce(:+) %>--
+
+ +
+

翻转课堂

+ + + + + + + + + + + + + <% + total_members_count = 0 + total_shixun_homework_count = 0 + %> + <% @courses.each do |course| %> + <% + total_members_count += course.members_count.to_i + total_shixun_homework_count += course['shixun_homework_count'].to_i + %> + + + + + + + + + <% end %> + + + + + + + + + + + +
创建者名称学生数量发布的实训作业数量有效作品数经验值
<%= course.teachers.where(user_id: @team_user_ids).first.user.show_real_name %> + <%= course.name %> + <%= course.members_count %><%= course['shixun_homework_count'].presence || '--' %><%= @course_myshixun_map.fetch(course.id, '--') %>--
合计<%= @courses.size %><%= total_members_count %><%= total_shixun_homework_count %><%= @course_myshixun_map.values.reduce(:+) %>--
+
+
+ + \ No newline at end of file diff --git a/app/views/competitions/_competition_team_detail.html.erb b/app/views/competitions/_competition_team_detail.html.erb deleted file mode 100644 index a44f8717..00000000 --- a/app/views/competitions/_competition_team_detail.html.erb +++ /dev/null @@ -1,94 +0,0 @@ -
-

- 战队详情 - 返回 -

-
-

实训项目

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
创建者名称学习人数fork版的学习人数有效作品数经验值
张三 - MySQL数据库编程开发实训(基础入门篇)MySQL数据库编程开发实训(基础入门篇) - 原创 - 1545124611154987
合计612万112233
-
- -
-

翻转课堂

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
创建者名称学生数量发布的实训作业数量有效作品数经验值
张三 - MySQL数据库编程开发实训(基础入门篇)MySQL数据库编程开发实训(基础入门篇) - 1545124611154987
合计612万112233
-
-
- - \ No newline at end of file diff --git a/app/views/competitions/_header.html.erb b/app/views/competitions/_header.html.erb index 6aa4c1a2..4017f82b 100644 --- a/app/views/competitions/_header.html.erb +++ b/app/views/competitions/_header.html.erb @@ -46,7 +46,7 @@ 排行榜 <% when '报名' %> -
  • +
  • 报名
  • <% else %> diff --git a/app/views/competitions/enroll.html.erb b/app/views/competitions/enroll.html.erb index eca04c58..746251f1 100644 --- a/app/views/competitions/enroll.html.erb +++ b/app/views/competitions/enroll.html.erb @@ -99,7 +99,7 @@ <% end %> <% if @competition.identifier == 'gcc-course-2019' %> - <%= link_to '战队详情', competition_team_path(id: @competition.id) %> + <%= link_to '战队详情', competition_team_path(id: team.id), class: 'fl mt13 ml10' %> <% end %> <% end %> diff --git a/app/views/competitions/index.html.erb b/app/views/competitions/index.html.erb index 3f03f6ef..19627026 100644 --- a/app/views/competitions/index.html.erb +++ b/app/views/competitions/index.html.erb @@ -2,6 +2,7 @@ <% if @competitions.count > 0 %> <% else %> diff --git a/app/views/competitions/publish.js.erb b/app/views/competitions/publish.js.erb new file mode 100644 index 00000000..4fd255a7 --- /dev/null +++ b/app/views/competitions/publish.js.erb @@ -0,0 +1 @@ +notice_box_redirect('<%= competition_managements_path %>', '发布成功') \ No newline at end of file diff --git a/app/views/managements/_competionList.html.erb b/app/views/managements/_competionList.html.erb index f2c4921f..ddc8b69b 100644 --- a/app/views/managements/_competionList.html.erb +++ b/app/views/managements/_competionList.html.erb @@ -65,6 +65,10 @@ 取消 保存 <%= competition.status ? "下架" : "上架" %> + + <% if !competition.status? && competition.published_at.blank? %> + <%= link_to '发布', publish_competition_path(competition), class: 'mr10', method: :post, remote: true %> + <% end %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 2bc0038c..c9d01c3b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -260,6 +260,7 @@ RedmineApp::Application.routes.draw do ## oauth相关 get 'send_message' get 'export_chart_score' post 'competition_images' + post 'publish' end collection do post 'new_competition' diff --git a/db/migrate/20190705021338_add_published_at_to_competitions.rb b/db/migrate/20190705021338_add_published_at_to_competitions.rb new file mode 100644 index 00000000..a3420621 --- /dev/null +++ b/db/migrate/20190705021338_add_published_at_to_competitions.rb @@ -0,0 +1,5 @@ +class AddPublishedAtToCompetitions < ActiveRecord::Migration + def change + add_column :competitions, :published_at, :datetime + end +end From 4ccde9d71c5e6d348139be32d84ef20430e9d5eb Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 5 Jul 2019 11:30:22 +0800 Subject: [PATCH 03/10] fix --- app/controllers/competition_teams_controller.rb | 3 ++- app/views/competition_teams/show.html.erb | 4 +++- app/views/competitions/_header.html.erb | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/competition_teams_controller.rb b/app/controllers/competition_teams_controller.rb index 6ecbb9aa..5b46986a 100644 --- a/app/controllers/competition_teams_controller.rb +++ b/app/controllers/competition_teams_controller.rb @@ -26,10 +26,11 @@ class CompetitionTeamsController < ApplicationController .where('exists(select 1 from games where games.myshixun_id = myshixuns.id and games.status = 2)') .group('shixun_id').count + # todo:使用新版course_members course_ids = Course.joins('join members on members.course_id = courses.id') .joins('join member_roles on member_roles.member_id = members.id and member_roles.role_id in (3,7,9)') .where(members: { user_id: @team_user_ids }).pluck(:id) - courses = Course.where(id: course_ids).joins(:shixun_homework_commons) + 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') diff --git a/app/views/competition_teams/show.html.erb b/app/views/competition_teams/show.html.erb index 31937688..bc176c1e 100644 --- a/app/views/competition_teams/show.html.erb +++ b/app/views/competition_teams/show.html.erb @@ -82,7 +82,9 @@ <%= course.teachers.where(user_id: @team_user_ids).first.user.show_real_name %> - <%= course.name %> + <%= link_to course_path(course), target: '_blank' do %> + <%= course.name %> + <% end %> <%= course.members_count %> <%= course['shixun_homework_count'].presence || '--' %> diff --git a/app/views/competitions/_header.html.erb b/app/views/competitions/_header.html.erb index 4017f82b..b6790839 100644 --- a/app/views/competitions/_header.html.erb +++ b/app/views/competitions/_header.html.erb @@ -46,7 +46,7 @@ 排行榜 <% when '报名' %> -
  • +
  • 报名
  • <% else %> From 776634299f655e0e4dc0f4f44b49bf21ca0431cb Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Fri, 5 Jul 2019 13:42:22 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E5=BC=80=E6=BA=90=E5=88=9B=E6=96=B0?= =?UTF-8?q?=E7=BB=84=E7=9A=84=E7=AB=9E=E8=B5=9B=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_qg_second_competition.html.erb | 4 +- .../_qg_second_opensource.html.erb | 47 ++++++++++++++++++ app/views/competitions/enroll.html.erb | 14 +++--- .../educoder/competition/qg/qg_open_1.png | Bin 0 -> 146465 bytes .../educoder/competition/qg/qg_open_2.png | Bin 0 -> 107478 bytes .../educoder/competition/qg/qg_open_3.png | Bin 0 -> 43765 bytes .../educoder/competition/qg/qg_open_4.png | Bin 0 -> 26554 bytes .../educoder/competition/qg/qg_open_5.png | Bin 0 -> 102898 bytes .../educoder/competition/qg/qg_open_6.png | Bin 0 -> 127016 bytes .../educoder/competition/qg/qg_open_7.png | Bin 0 -> 82823 bytes public/images/educoder/teach_ex.png | Bin 393242 -> 180979 bytes public/stylesheets/educoder/edu-all.css | 25 +++++++++- 12 files changed, 80 insertions(+), 10 deletions(-) create mode 100644 app/views/competitions/_qg_second_opensource.html.erb create mode 100644 public/images/educoder/competition/qg/qg_open_1.png create mode 100644 public/images/educoder/competition/qg/qg_open_2.png create mode 100644 public/images/educoder/competition/qg/qg_open_3.png create mode 100644 public/images/educoder/competition/qg/qg_open_4.png create mode 100644 public/images/educoder/competition/qg/qg_open_5.png create mode 100644 public/images/educoder/competition/qg/qg_open_6.png create mode 100644 public/images/educoder/competition/qg/qg_open_7.png diff --git a/app/views/competitions/_qg_second_competition.html.erb b/app/views/competitions/_qg_second_competition.html.erb index aa45d32e..9a8c28f4 100644 --- a/app/views/competitions/_qg_second_competition.html.erb +++ b/app/views/competitions/_qg_second_competition.html.erb @@ -5,10 +5,10 @@ <% index += 1 %> <% @competition.competition_stages.each_with_index do |stage, i| %> -
    +
    " style="background: url(<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>) no-repeat top center;">
    <% stage.competition_stage_sections.each do |section| %> -