From 40dfc7d490ed6d8b0b1123af9152fe4b9622c09a Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 23 Oct 2019 17:27:15 +0800 Subject: [PATCH 01/10] =?UTF-8?q?python=E6=96=87=E4=BB=B6=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 4e587513a..4b2e3f54f 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -264,11 +264,13 @@ class MyshixunsController < ApplicationController unless @hide_code || (@myshixun.shixun&.vnc_evaluate && params[:evaluate].present?) # 远程版本库文件内容 last_content = GitService.file_content(repo_path: @repo_path, path: path)["content"] - content = if @myshixun.mirror_name.select {|a| a.include?("MachineLearning") || a.include?("Python")}.present? && params[:content].present? - params[:content].gsub(/\t/, ' ').gsub(/ /, ' ') # 这个不是空格,在windows机器上带来的问题 - else - params[:content] - end + + content = + if python_file?(path) + params[:content].gsub(/\t/, ' ').gsub(/ /, ' ') + else + params[:content] + end uid_logger_dubug("###11222333####{content}") uid_logger_dubug("###222333####{last_content}") @@ -374,4 +376,9 @@ class MyshixunsController < ApplicationController @repo_path = @myshixun.try(:repo_path) @path = params[:path] end + + def python_file?(path) + false if path.blank? + path.to_s.split(".").last.downcase == "py" + end end From 2b8fb35f5a3c32f87268822566a7ad5128636242 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 25 Oct 2019 09:13:28 +0800 Subject: [PATCH 02/10] competition: fix bug --- app/models/competition.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/competition.rb b/app/models/competition.rb index 845c5c00f..332ed09e5 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -85,7 +85,7 @@ class Competition < ApplicationRecord # 是否开放 def open?(user) user_school_id = user.user_extension&.school_id.to_i - competition.region_schools.size == 0 || competition.region_schools.exists?(school_id: user_school_id) + region_schools.size == 0 || region_schools.exists?(school_id: user_school_id) end # 是否禁止教师报名 From 75446cb998d38ff0a61f32103909b12d6141a3c3 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 25 Oct 2019 09:16:22 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admins/competition_settings/index.js | 5 +- app/models/competition.rb | 4 +- .../competition_settings/index.html.erb | 185 ++++++++++++------ 3 files changed, 132 insertions(+), 62 deletions(-) diff --git a/app/assets/javascripts/admins/competition_settings/index.js b/app/assets/javascripts/admins/competition_settings/index.js index cc56c8641..207fd0ee3 100644 --- a/app/assets/javascripts/admins/competition_settings/index.js +++ b/app/assets/javascripts/admins/competition_settings/index.js @@ -249,7 +249,8 @@ $(function () { } }) -}) +}); + //新增子阶段 function add_task_sub(item){ var index = $(item).parents(".large_panel_part").attr("attr_line"); @@ -355,7 +356,7 @@ function Del_tab(item) { $(item).parents(".large_panel_part").remove(); } //新增tab -function addNewTab() { +function addNewTab() { var count = parseInt($("#large_panel").find(".large_panel_part").length)+1; var html = '
\n' + ' tab标题\n' + diff --git a/app/models/competition.rb b/app/models/competition.rb index 845c5c00f..461af5471 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -23,8 +23,8 @@ class Competition < ApplicationRecord has_many :competition_awards, dependent: :destroy has_many :competition_schools, dependent: :destroy - has_one :sponsor_schools, -> { where(source: :sponsor) }, class_name: 'CompetitionSchool' # 主办方 - has_one :region_schools, -> { where(source: :region) }, class_name: 'CompetitionSchool' # 开放范围 + has_many :sponsor_schools, -> { where(source: :sponsor) }, class_name: 'CompetitionSchool' # 主办方 + has_many :region_schools, -> { where(source: :region) }, class_name: 'CompetitionSchool' # 开放范围 after_create :create_competition_modules diff --git a/app/views/admins/competition_settings/index.html.erb b/app/views/admins/competition_settings/index.html.erb index 34a326dee..c06dc0000 100644 --- a/app/views/admins/competition_settings/index.html.erb +++ b/app/views/admins/competition_settings/index.html.erb @@ -210,7 +210,7 @@
  
- +
~
@@ -312,74 +312,143 @@
+<% if @competition.mode == 1 %> +
+
+ 排行榜设置 + + 新增tab + 实训ID填写示例:实训地址为https://www.educoder.net/shixuns/u5plmgka/challenges,则填写“u5plmgka” +
+
+
+ <% if @competition.competition_stages.count > 0 %> + <% @competition.competition_stages.each do |stage| %> + <%= form_tag(admins_competition_competition_stage_path(competition_id: @competition.id, id: stage.id), method: :put, class: 'stage_update_form flex-1', remote: true) do %> +
+
+ tab标题 +
+ +
+ 总排行榜占比: +
+ +
% + + 删除 + 保存 +
-
-
- 排行榜设置 - + 新增tab +
+
+ 第1阶段 +
+
+ 有效时间: +
+ +
+ ~ +
+ +
+ 任务完成要求: +
+ +
+ / +
+ +
+ (总任务) + 成绩来源: +
+ +
+
+
+
+ + 删除 + +
+
+
+ <% end %> + <% end %> + <% else %> + <% end %> +
+
- 实训ID填写示例:实训地址为https://www.educoder.net/shixuns/u5plmgka/challenges,则填写“u5plmgka” -
-
-
-
-
- tab标题 -
- -
- 总排行榜占比: -
- -
% - - 删除 - 保存 -
-
-
- 第1阶段 +
+
+
+
+ tab标题 +
+ +
+ 总排行榜占比: +
+ +
%
-
- 有效时间: -
- -
- ~ -
- -
- 任务完成要求: -
- -
- / -
- -
- (总任务) - 成绩来源: -
- + 新增子阶段 + 发送短信提醒 + 计算成绩 +
+ 删除 + 保存 +
+
+
+ 第1阶段 +
+
+ 有效时间: +
+ +
+ ~ +
+ +
+ 任务完成要求: +
+ +
+ / +
+ +
+ (总任务) + 成绩来源: +
+ +
+
-
-
- + 删除 +
-
+<% end %> From 8c69a4dd0f63fa7ab379702ed51a490e1f4bf9fe Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 25 Oct 2019 09:22:43 +0800 Subject: [PATCH 04/10] weapp: save user extra info at bind user --- app/controllers/weapps/code_sessions_controller.rb | 2 ++ app/controllers/weapps/sessions_controller.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/weapps/code_sessions_controller.rb b/app/controllers/weapps/code_sessions_controller.rb index c92c3cb70..887e97eed 100644 --- a/app/controllers/weapps/code_sessions_controller.rb +++ b/app/controllers/weapps/code_sessions_controller.rb @@ -25,6 +25,8 @@ class Weapps::CodeSessionsController < Weapps::BaseController end set_session_unionid(user_info['unionId']) + user_info['nickname'] = user_info['nickName'] + session[:wechat_user_extra] = user_info end set_session_openid(result['openid']) diff --git a/app/controllers/weapps/sessions_controller.rb b/app/controllers/weapps/sessions_controller.rb index 371a3f7d3..8c7c57a7f 100644 --- a/app/controllers/weapps/sessions_controller.rb +++ b/app/controllers/weapps/sessions_controller.rb @@ -16,7 +16,7 @@ class Weapps::SessionsController < Weapps::BaseController end # 绑定微信号 - OpenUsers::Wechat.create!(user: user, uid: session_unionid) if user.wechat_open_user.blank? + OpenUsers::Wechat.create!(user: user, uid: session_unionid, extra: session[:wechat_user_extra]) if user.wechat_open_user.blank? successful_authentication(user) end From e1410885c7dee6316209d45a6d924cc39ac1532e Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 25 Oct 2019 09:26:29 +0800 Subject: [PATCH 05/10] competition: fix join team fail bug --- app/services/competitions/join_team_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/competitions/join_team_service.rb b/app/services/competitions/join_team_service.rb index cb0253fa2..7ec453013 100644 --- a/app/services/competitions/join_team_service.rb +++ b/app/services/competitions/join_team_service.rb @@ -24,7 +24,7 @@ class Competitions::JoinTeamService < ApplicationService raise Error, '您已加入该战队' if team.team_members.exists?(user_id: user.id) enrolled = competition.team_members.exists?(user_id: user.id) - if enrolled && (is_teacher && competition.teacher_multiple_limited?) || (!is_teacher && competition.member_multiple_limited?) + if enrolled && ((is_teacher && competition.teacher_multiple_limited?) || (!is_teacher && competition.member_multiple_limited?)) raise Error, '您已加入其它战队' end From 34c3e693e1e77152b1d8932cd002f12a68bae8c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Fri, 25 Oct 2019 09:28:06 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E7=AB=9E=E8=B5=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/competition/Registration.js | 46 +++++++++++++++---- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/public/react/src/modules/competition/Registration.js b/public/react/src/modules/competition/Registration.js index f0fc873c8..91ab829a7 100644 --- a/public/react/src/modules/competition/Registration.js +++ b/public/react/src/modules/competition/Registration.js @@ -2,7 +2,8 @@ import React, {Component} from 'react'; import { BrowserRouter as Router, Route, - Switch + Switch, + Link } from 'react-router-dom'; import axios from 'axios'; import moment from 'moment'; @@ -115,11 +116,35 @@ class Registration extends React.Component { personal: result.data.personal, enroll_ended: result.data.enroll_ended, enrolled: result.data.enrolled, - teacher_staff: result.data.teacher_staff, - member_staff: result.data.member_staff, - mutiple_limited: result.data.member_staff.mutiple_limited, - teamutiple_limited: result.data.teacher_staff.mutiple_limited + teacher_staff: result.data.teacher_staff === undefined || result.data.teacher_staff === null ? undefined : result.data.teacher_staff, + member_staff: result.data.member_staff === undefined || result.data.member_staff === null ? undefined : result.data.member_staff, + }) + + try { + if (result.data.member_staff) { + this.setState({ + mutiple_limited: result.data.member_staff.mutiple_limited, + + }) + } + + + } catch (e) { + + } + + try { + if (result.data.teacher_staff) { + this.setState({ + teamutiple_limited: result.data.teacher_staff.mutiple_limited + }) + } + + } catch (e) { + + } + if (result.data.enroll_ended === true) { this.setState({ pint: 0 @@ -136,7 +161,8 @@ class Registration extends React.Component { } } }).catch((error) => { - //// //////console.log(error); + console.log("GetenrollmentAPI"); + console.log(error); }) } @@ -686,9 +712,11 @@ class Registration extends React.Component {
- 在线竞赛 - {competition_name === undefined || competition_name === null || competition_name === "" ? "全国高校计算机大赛" : competition_name} + 在线竞赛 + {competition_name === undefined || competition_name === null || competition_name === "" ? "全国高校计算机大赛" : competition_name} + {/**/} 报名
From e83ffc80719a8312b96787f5a56fa2c124f1cce0 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 25 Oct 2019 09:32:28 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../competitions/competitions_controller.rb | 2 +- .../competition_settings/index.html.erb | 68 ++++++++++--------- ...1023103633_add_column_to_stage_sections.rb | 10 --- ...1025012950_add_column_to_stage_sections.rb | 8 +++ 4 files changed, 44 insertions(+), 44 deletions(-) delete mode 100644 db/migrate/20191023103633_add_column_to_stage_sections.rb create mode 100644 db/migrate/20191025012950_add_column_to_stage_sections.rb diff --git a/app/controllers/competitions/competitions_controller.rb b/app/controllers/competitions/competitions_controller.rb index 009c3183f..2c3d00529 100644 --- a/app/controllers/competitions/competitions_controller.rb +++ b/app/controllers/competitions/competitions_controller.rb @@ -69,7 +69,7 @@ class Competitions::CompetitionsController < Competitions::BaseController end def update_md_content - tip_exception("标题和内容不能为空") if params[:name].blank? || params[:content].blank? + tip_exception("内容不能为空") if params[:content].blank? tip_exception("缺少competition_module_id") if params[:competition_module_id].blank? ActiveRecord::Base.transaction do com_module = current_competition.competition_modules.find_by!(id: params[:competition_module_id]) diff --git a/app/views/admins/competition_settings/index.html.erb b/app/views/admins/competition_settings/index.html.erb index c06dc0000..97784ef79 100644 --- a/app/views/admins/competition_settings/index.html.erb +++ b/app/views/admins/competition_settings/index.html.erb @@ -324,7 +324,7 @@
<% if @competition.competition_stages.count > 0 %> - <% @competition.competition_stages.each do |stage| %> + <% @competition.competition_stages.each_with_index do |stage, index| %> <%= form_tag(admins_competition_competition_stage_path(competition_id: @competition.id, id: stage.id), method: :put, class: 'stage_update_form flex-1', remote: true) do %>
@@ -345,42 +345,44 @@ 保存
-
-
- 第1阶段 -
-
- 有效时间: -
- -
- ~ -
- -
- 任务完成要求: -
- -
- / -
- -
- (总任务) - 成绩来源: -
- +
+ <% stage.competition_stage_sections.each_with_index do |section, j| %> +
+ 第<%= j + 1 %>阶段 +
+
+ 有效时间: +
+ <%= text_field_tag 'stage[][start_time]', section.start_time&.strftime('%Y-%m-%d %H:%M'), autocomplete: 'off', class: 'section_start_time form-control', placeholder: '有效开始时间' %> +
+ ~ +
+ <%= text_field_tag 'stage[][end_time]', section.end_time&.strftime('%Y-%m-%d %H:%M'), autocomplete: 'off', class: 'section_end_time form-control', placeholder: '有效结束时间' %> +
+ 任务完成要求: +
+ +
+ / +
+ +
+ (总任务) + 成绩来源: +
+ +
+
-
-
- + 删除 -
+
+ <% end %>
<% end %> diff --git a/db/migrate/20191023103633_add_column_to_stage_sections.rb b/db/migrate/20191023103633_add_column_to_stage_sections.rb deleted file mode 100644 index baa1754fa..000000000 --- a/db/migrate/20191023103633_add_column_to_stage_sections.rb +++ /dev/null @@ -1,10 +0,0 @@ -class AddColumnToStageSections < ActiveRecord::Migration[5.2] - def change - def change - add_column :competition_stage_sections, :mission_count, :integer, default: 0 - add_column :competition_stage_sections, :score_source, :integer, default: 0 - - add_column :competition_entries, :shixun_identifier, :string - end - end -end diff --git a/db/migrate/20191025012950_add_column_to_stage_sections.rb b/db/migrate/20191025012950_add_column_to_stage_sections.rb new file mode 100644 index 000000000..5eb96aea9 --- /dev/null +++ b/db/migrate/20191025012950_add_column_to_stage_sections.rb @@ -0,0 +1,8 @@ +class AddColumnToStageSections < ActiveRecord::Migration[5.2] + def change + add_column :competition_stage_sections, :mission_count, :integer, default: 0 + add_column :competition_stage_sections, :score_source, :integer, default: 0 + + add_column :competition_entries, :shixun_identifier, :string + end +end From b59cfd52e8a59237892b8cf1998700beb3cfe8c5 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Fri, 25 Oct 2019 09:53:18 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E4=B8=BB=E5=8A=9E=E6=96=B9=E5=92=8C?= =?UTF-8?q?=E5=BC=80=E6=94=BE=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admins/competition_settings/index.js | 13 +++++++++ .../admins/competition_settings.scss | 27 +++++++++++++++++++ app/assets/stylesheets/common.scss | 1 + .../competition_settings/index.html.erb | 23 ++++++++++++++-- 4 files changed, 62 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/admins/competition_settings/index.js b/app/assets/javascripts/admins/competition_settings/index.js index cc56c8641..6568ab43f 100644 --- a/app/assets/javascripts/admins/competition_settings/index.js +++ b/app/assets/javascripts/admins/competition_settings/index.js @@ -107,6 +107,19 @@ $(document).on('turbolinks:load', function(){ } }); +//添加主办方或者开放范围 +function addSponsor(item){ + var html=''; + $(item).parents(".sponsorPanel").append(html); +} +//删除 +function del_sponsor(item){ + $(item).parents(".sponsor_label").remove(); +} $(function () { //MD编辑 diff --git a/app/assets/stylesheets/admins/competition_settings.scss b/app/assets/stylesheets/admins/competition_settings.scss index 690cc2207..cef12cae3 100644 --- a/app/assets/stylesheets/admins/competition_settings.scss +++ b/app/assets/stylesheets/admins/competition_settings.scss @@ -40,6 +40,33 @@ line-height: 20px; } + .sponsor_label{ + border:1px solid #4CACFF; + border-radius: 5px; + background-color: rgba(76,172,255,0.3); + color: #333; + padding:0px 4px; + height: 30px; + line-height: 30px; + float: left; + margin: 4px 5px; + + span{ + display: block; + float: left; + height: 28px; + line-height: 28px; + margin-right: 5px; + } + + a{ + font-size: 18px; + float: left; + height: 28px; + line-height: 28px; + } + } + .large_panel{ padding:0px 15px; diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 90cdef268..19df03619 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -29,6 +29,7 @@ input.form-control { .flex-1 { flex: 1; } +.fl{float: left} .no_padding{padding: 0px!important;} .font-12 { font-size: 12px !important; } .font-14 { font-size: 14px !important; } diff --git a/app/views/admins/competition_settings/index.html.erb b/app/views/admins/competition_settings/index.html.erb index 34a326dee..580b9b585 100644 --- a/app/views/admins/competition_settings/index.html.erb +++ b/app/views/admins/competition_settings/index.html.erb @@ -93,12 +93,31 @@
-
+
主办方
-
+
+ + + +
+
+
+
+ 开放范围 +
+
+ + +
From 11df2d33362c24d0be218c083990647f941c7a75 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 25 Oct 2019 09:55:18 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/competitions/competitions/common_header.json.jbuilder | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/competitions/competitions/common_header.json.jbuilder b/app/views/competitions/competitions/common_header.json.jbuilder index 0ecf6cfd5..2a1e0a92d 100644 --- a/app/views/competitions/competitions/common_header.json.jbuilder +++ b/app/views/competitions/competitions/common_header.json.jbuilder @@ -21,6 +21,7 @@ json.stages if @competition.mode == 2 json.course_id @competition.competition_mode_setting&.course_id + json.invite_code @competition.competition_mode_setting&.course&.invite_code json.member_of_course @user.member_of_course?(@competition.competition_mode_setting&.course) end From 380f2a62d7ebb0108ad1459a53270d87ede1fab8 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 25 Oct 2019 09:58:26 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/competition_module.rb | 2 +- app/views/competitions/competition_modules/show.json.jbuilder | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/competition_module.rb b/app/models/competition_module.rb index 3fdab6b37..3b1bfddda 100644 --- a/app/models/competition_module.rb +++ b/app/models/competition_module.rb @@ -3,7 +3,7 @@ class CompetitionModule < ApplicationRecord belongs_to :competition - has_one :competition_module_md_content, dependent: :destroy + has_many :competition_module_md_contents, dependent: :destroy def module_url result_url = url.present? ? url : case module_type diff --git a/app/views/competitions/competition_modules/show.json.jbuilder b/app/views/competitions/competition_modules/show.json.jbuilder index 116934ee8..14c3c0f57 100644 --- a/app/views/competitions/competition_modules/show.json.jbuilder +++ b/app/views/competitions/competition_modules/show.json.jbuilder @@ -1,6 +1,6 @@ json.extract! @module, :id, :name, :position, :url -md = @module.competition_module_md_content +md = @module.competition_module_md_contents.take if md.present? json.md_id md.id json.md_name md.name