主办方和开放范围

dev_sync_trustie
caishi 5 years ago
commit 8b05d1d20d

@ -262,7 +262,8 @@ $(function () {
}
})
})
});
//新增子阶段
function add_task_sub(item){
var index = $(item).parents(".large_panel_part").attr("attr_line");
@ -368,7 +369,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 = '<div class="large_panel_part" attr_line="'+count+'"><div class="row d-flex mt-3">\n' +
' <span class="col-1 mt-2">tab标题</span>\n' +

@ -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])

@ -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'])

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

@ -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
@ -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
# 是否禁止教师报名

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

@ -229,7 +229,7 @@
<div class="row mt-2 mb-4 requireForm_item">
<div class="col-1 text-right">&nbsp;&nbsp;</div>
<div class="col-1 text-left mt-1">
<input type="text" class="form-control" name="competition_staffs[][minimum]" value="<%= staff.minimum %>" />
<input type="text" class="form-control" name="competition_staffs[][minimum]" value="<%= staff.minimum %>" />
</div>
<span class="mt-2">~</span>
<div class="col-1 mt-1">
@ -331,74 +331,145 @@
</div>
<% if @competition.mode == 1 %>
<div class="card mb-5">
<div class="card-header d-flex justify-content-between align-items-center">
<span>排行榜设置</span>
<a href="javascript:void(0)" class="btn btn-primary btn-custom waves-effect waves-light ml20" onclick="addNewTab();">+ 新增tab</a>
<span class="flex-1 text-right color-orange">实训ID填写示例实训地址为https://www.educoder.net/shixuns/u5plmgka/challenges则填写“u5plmgka”</span>
</div>
<div class="card-body">
<div id="large_panel" class="large_panel">
<% if @competition.competition_stages.count > 0 %>
<% @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 %>
<div class="large_panel_part" attr_line="1">
<div class="row d-flex">
<span class="col-1 mt-2">tab标题</span>
<div class="col-2 no_padding">
<input type="text" class="form-control" name="stage_name" value="<%= stage.name %>" />
</div>
<span class="col-1 text-right mt-2 no_padding">总排行榜占比:</span>
<div class="col-1 no_padding">
<input type="number" class="form-control" name="score_rate" value="<%= (stage.score_rate * 100).to_i %>"/>
</div><span class=" mt-2">%</span>
<div class="flex-1">
<a href="javascript:void(0)"class="btn btn-outline-primary export-action ml20 add_task_sub" onclick="add_task_sub(this)">新增子阶段</a>
<a href="javascript:void(0)" class="btn btn-outline-primary export-action ml20">发送短信提醒</a>
<a href="javascript:void(0)" class="btn btn-outline-primary export-action ml20">计算成绩</a>
</div>
<a href="javascript:void(0)" class="btn btn-default ml20" onclick="Del_tab(this)">删除</a>
<a href="javascript:void(0)" class="btn btn-outline-primary export-action ml20">保存</a>
</div>
<div class="card mb-5">
<div class="card-header d-flex justify-content-between align-items-center">
<span>排行榜设置</span>
<a href="javascript:void(0)" class="btn btn-primary btn-custom waves-effect waves-light ml20" onclick="addNewTab();">+ 新增tab</a>
<div id="small_panel_<%= index + 1 %>" class="small_panel">
<% stage.competition_stage_sections.each_with_index do |section, j| %>
<div class="row d-flex small_panel_item" attr_line="sub_1_1" count="<%= j + 1 %>">
<span class="col-1 mt-2 subName">第<%= j + 1 %>阶段</span>
<div class="flex-1">
<div class="row">
<span class="mt-2 ml20">有效时间:</span>
<div class="col-2 no_padding input_middle">
<%= text_field_tag 'stage[][start_time]', section.start_time&.strftime('%Y-%m-%d %H:%M'), autocomplete: 'off', class: 'section_start_time form-control', placeholder: '有效开始时间' %>
</div>
<span class="mt-2">~</span>
<div class="col-2 no_padding input_middle">
<%= text_field_tag 'stage[][end_time]', section.end_time&.strftime('%Y-%m-%d %H:%M'), autocomplete: 'off', class: 'section_end_time form-control', placeholder: '有效结束时间' %>
</div>
<span class="col-2 text-right mt-2 no_padding">任务完成要求:</span>
<div class="col-1 no_padding input_small">
<input type="number" class="form-control" name="stage[][end_time]"/>
</div>
<span class="mt-2 ml10 mr10">/</span>
<div class="col-1 no_padding input_small">
<input type="number" class="form-control task_all" onchange="change_total(this)" name="task_require_all_1_1"/>
</div>
<span class=" mt-2">(总任务)</span>
<span class="col-1 text-right mt-2 no_padding">成绩来源:</span>
<div class="col-2 no_padding input_middle">
<select class="form-control" name="source_1_1">
<option>经验值</option>
<option>预测准确率</option>
</select>
</div>
</div>
<div class="row mt-2" id="task_Input_sub_1_1"></div>
</div>
<span>
<a href="javascript:void(0)" class="btn btn-default ml20 small_panel_item_del">删除</a>
</span>
</div>
<% end %>
</div>
</div>
<% end %>
<% end %>
<% else %>
<% end %>
</div>
</div>
<span class="flex-1 text-right color-orange">实训ID填写示例实训地址为https://www.educoder.net/shixuns/u5plmgka/challenges则填写“u5plmgka”</span>
</div>
<div class="card-body">
<div id="large_panel" class="large_panel">
<div class="large_panel_part" attr_line="1">
<div class="row d-flex">
<span class="col-1 mt-2">tab标题</span>
<div class="col-2 no_padding">
<input type="text" class="form-control" name="tab_title_1"/>
</div>
<span class="col-1 text-right mt-2 no_padding">总排行榜占比:</span>
<div class="col-1 no_padding">
<input type="number" class="form-control" name="tab_percent_1"/>
</div><span class=" mt-2">%</span>
<div class="flex-1">
<a href="javascript:void(0)"class="btn btn-outline-primary export-action ml20 add_task_sub" onclick="add_task_sub(this)">新增子阶段</a>
<a href="javascript:void(0)" class="btn btn-outline-primary export-action ml20">发送短信提醒</a>
<a href="javascript:void(0)" class="btn btn-outline-primary export-action ml20">计算成绩</a>
</div>
<a href="javascript:void(0)" class="btn btn-default ml20" onclick="Del_tab(this)">删除</a>
<a href="javascript:void(0)" class="btn btn-outline-primary export-action ml20">保存</a>
</div>
<div id="small_panel_1" class="small_panel">
<div class="row d-flex small_panel_item" attr_line="sub_1_1" count="1">
<span class="col-1 mt-2 subName">第1阶段</span>
<div class="card-body">
<div id="large_panel" class="large_panel">
<div class="large_panel_part" attr_line="1">
<div class="row d-flex">
<span class="col-1 mt-2">tab标题</span>
<div class="col-2 no_padding">
<input type="text" class="form-control" name="tab_title_1"/>
</div>
<span class="col-1 text-right mt-2 no_padding">总排行榜占比:</span>
<div class="col-1 no_padding">
<input type="number" class="form-control" name="tab_percent_1"/>
</div><span class=" mt-2">%</span>
<div class="flex-1">
<div class="row">
<span class="mt-2 ml20">有效时间:</span>
<div class="col-2 no_padding input_middle">
<input class="use_time_begin_1_1 form-control" placeholder="有效开始时间"/>
</div>
<span class="mt-2">~</span>
<div class="col-2 no_padding input_middle">
<input class="use_time_end_1_1 form-control" placeholder="有效结束时间"/>
</div>
<span class="col-2 text-right mt-2 no_padding">任务完成要求:</span>
<div class="col-1 no_padding input_small">
<input type="number" class="form-control" name="task_require_small_1_1"/>
</div>
<span class="mt-2 ml10 mr10">/</span>
<div class="col-1 no_padding input_small">
<input type="number" class="form-control task_all" onchange="change_total(this)" name="task_require_all_1_1"/>
</div>
<span class=" mt-2">(总任务)</span>
<span class="col-1 text-right mt-2 no_padding">成绩来源:</span>
<div class="col-2 no_padding input_middle">
<select class="form-control" name="source_1_1">
<option>经验值</option>
<option>预测准确率</option>
</select>
<a href="javascript:void(0)"class="btn btn-outline-primary export-action ml20 add_task_sub" onclick="add_task_sub(this)">新增子阶段</a>
<a href="javascript:void(0)" class="btn btn-outline-primary export-action ml20">发送短信提醒</a>
<a href="javascript:void(0)" class="btn btn-outline-primary export-action ml20">计算成绩</a>
</div>
<a href="javascript:void(0)" class="btn btn-default ml20" onclick="Del_tab(this)">删除</a>
<a href="javascript:void(0)" class="btn btn-outline-primary export-action ml20">保存</a>
</div>
<div id="small_panel_1" class="small_panel">
<div class="row d-flex small_panel_item" attr_line="sub_1_1" count="1">
<span class="col-1 mt-2 subName">第1阶段</span>
<div class="flex-1">
<div class="row">
<span class="mt-2 ml20">有效时间:</span>
<div class="col-2 no_padding input_middle">
<input class="use_time_begin_1_1 form-control" placeholder="有效开始时间"/>
</div>
<span class="mt-2">~</span>
<div class="col-2 no_padding input_middle">
<input class="use_time_end_1_1 form-control" placeholder="有效结束时间"/>
</div>
<span class="col-2 text-right mt-2 no_padding">任务完成要求:</span>
<div class="col-1 no_padding input_small">
<input type="number" class="form-control" name="task_require_small_1_1"/>
</div>
<span class="mt-2 ml10 mr10">/</span>
<div class="col-1 no_padding input_small">
<input type="number" class="form-control task_all" onchange="change_total(this)" name="task_require_all_1_1"/>
</div>
<span class=" mt-2">(总任务)</span>
<span class="col-1 text-right mt-2 no_padding">成绩来源:</span>
<div class="col-2 no_padding input_middle">
<select class="form-control" name="source_1_1">
<option>经验值</option>
<option>预测准确率</option>
</select>
</div>
</div>
<div class="row mt-2" id="task_Input_sub_1_1"></div>
</div>
<div class="row mt-2" id="task_Input_sub_1_1"></div>
</div>
<span>
<span>
<a href="javascript:void(0)" class="btn btn-default ml20 small_panel_item_del">删除</a>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<% end %>

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

@ -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
Loading…
Cancel
Save