competition modify

dev_aliyun
p31729568 5 years ago
parent d3aed91b41
commit 68d8f10482

@ -1133,6 +1133,12 @@ end
render :json => {:status => 1}
end
def update_competition_text
text = CompetitionTextConfig.find(params[:id])
text.update_attributes(name: params[:name], description: params[:description])
render :json => {:status => 1}
end
def delete_competition_text
ctc = CompetitionTextConfig.find params[:id]
ctc.destroy

@ -1,4 +1,4 @@
class CompetitionTextConfig < ActiveRecord::Base
# attr_accessible :title, :body
attr_accessible :name, :description, :competition_id
belongs_to :competition
end

@ -4,71 +4,59 @@
<div class="openSource_2" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<% index += 1 %>
<div class="openSource_3" style="background: url('') no-repeat top center;">
<div class="openSource_3" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;">
<div class="enter_panel" style="height: 300px">
<p class="desc_game">
为推动我国基于开源的开放创新生态环境建设,加快面向自主创新的高校信息技术新工科人才培养模式变革,大力培养实践能力强、创新能力强、具备国际竞争力的信息技术领域高素质人才,教育部高等学校计算机类专业教学指导委员会、教育部高等学校软件工程专业教学指导委员会、全国高等学校计算机教育研究会。
创新能力强、具备国际竞争力的信息技术领域高素质人才,教育部高等学校计算机类专业教学指导委员会、教育部高等学校软件工程专业教学指导委员会、全国高等学校计算机教育研究会、信息技术新工科产学研联盟、中国计算机学会软件工程专委会、中国计算机学会系统软件专委会、绿色计算产业联盟等共同研究,决定举办第二届全国高校绿色计算创新大赛。
<%= @competition.competition_text_configs.first.try(:description) %>
</p>
</div>
</div>
<% index += 1 %>
<div class="openSource_4" style="background: url('') no-repeat top center;">
<div class="educontent">
<a href="javascript:void(0)" style="float:right;height:282px;width:50%"></a>
</div>
</div>
<% @competition.competition_stages.each_with_index do |stage, i| %>
<div class="openSource_<%= index + 1 %>" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;">
<%
first_section = stage.competition_stage_sections[0]
second_section = stage.competition_stage_sections[1]
%>
<div class="enter_panel" style="height: 285px">
<ul>
<p class="font-22 enter_title padding30 clearfix">
<span class="fl ml30">
<span class="mr20 font-bd"><%= first_section.try(:name) %></span>
<span><%= first_section.start_time.try(:strftime, '%Y年%m月%d日') %>~<%= first_section.end_time.try(:strftime, '%Y年%m月%d日') %></span>
</span>
<span class="fr mr30">
<span class="mr20 font-bd"><%= second_section.try(:name) %></span>
<span><%= second_section.try(:start_time).try(:strftime, '%Y年%m月%d日') %>~<%= second_section.try(:end_time).try(:strftime, '%Y年%m月%d日') %></span>
</span>
</p>
<li class="inline enter_btn mt20">
<% is_start = Time.now > first_section.start_time %>
<% first_section.competition_entries.each_with_index do |entry, j| %>
<%
competition_url = User.current.logged? ? "#{entry.url}?eid=#{User.current.id}" : "#{entry.url}"
first_stage = @competition.competition_stages.first
first_section = first_stage.competition_stage_sections.first
first_entry = first_section.competition_entries.first
is_start = Time.now > first_section.start_time
competition_url = User.current.logged? ? "#{first_entry.url}?eid=#{User.current.id}" : "#{first_entry.url}"
btn_url = is_start ? "#{competition_url}" : "javascript:void(0);"
%>
<a class="li-1 <%= is_start ? 'active' : '' %>"
href="javascript:void(0);"
data-url="<%= btn_url %>"><%= entry.name %></a>
<% end %>
</li>
</ul>
<div class="openSource_4" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;">
<div class="educontent">
<a href="javascript:void(0)" data-url="<%= btn_url %>" class="enroll-btn <%= is_start ? 'active' : '' %>" style="float:right;height:282px;width:50%"></a>
</div>
</div>
<% index += 1 %>
<% end %>
<div class="openSource_5" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<% index += 1 %>
<div class="openSource_6" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<% index += 1 %>
<div class="openSource_7" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<% index += 1 %>
<div class="openSource_7" style="background: url('<%= named_attachment_path(@images[index], @images[index].try(:filename)) %>') no-repeat top center;"></div>
<script>
$(function(){
var userLogged = <%= @user.present? && @user.logged? %>;
var userEnrolled = <%= @enrolled %>;
<%
course_id = nil
user_enrolled = false
invite_code = nil
if first_entry.url.present?
course_id = first_entry.url.split('/')[-2, 1]
course = Course.find_by_id(course_id)
if course.present? && @user && @user.logged?
user_enrolled = @user.member_of_course?(course)
invite_code = course.invite_code
end
end
%>
var userEnrolled = <%= user_enrolled %>;
$(".enter_btn .li-1.active").on("click", function(){
$(".enroll-btn.active").on("click", function(){
var url = $(this).data("url");
if (!userLogged) {
@ -77,7 +65,20 @@
}
if (!userEnrolled) {
sure_box_redirect_without_newtab_btn("<%= enroll_competition_path(id: params[:id]) %>", "完成报名后即可参赛", "我要报名");
$.ajax({
url: "/api/courses/apply_to_join_course.json",
type: "post",
dataType: 'json',
data: {
student: 1,
invite_code: "<%= invite_code %>"
},
success: function(){
var newTab = window.open("_blank");
newTab.location = url;
window.location.reload()
}
})
return;
}

@ -3,7 +3,7 @@
<div class="bor-grey-e mb20" id="homePagePara">
<p class="clearfix bor-bottom-greyE pr20 pt5 pb5">
<input type="text" value="首页文字说明" name="config_name" class="panel-box-sizing childcenter_title_input"/>
<a href="javascript:void(0)" class="fr color-blue" onclick="create_submit_data(this);">保存</a>
<a href="javascript:void(0)" class="fr color-blue" onclick="save_submit_data(null, this);">保存</a>
<a href="javascript:void(0)" class="fr mr20" onclick="removePanel();">删除</a>
</p>
<div class="padding15">
@ -130,7 +130,7 @@
<div class="bor-grey-e mb20" id="homePagePara_<%= text.id %>">
<p class="clearfix bor-bottom-greyE pr20 pt5 pb5">
<input type="text" value="<%= text.name %>" name="config_name" class="panel-box-sizing childcenter_title_input">
<a href="javascript:void(0)" class="fr color-blue" onclick="create_submit_data(this);">保存</a>
<a href="javascript:void(0)" class="fr color-blue" onclick="save_submit_data(<%= text.id %>, this);">保存</a>
<a href="javascript:void(0)" class="fr mr20" onclick="removePanel(<%= text.id %>);">删除</a>
</p>
<div class="padding15">
@ -563,6 +563,27 @@
})
}
function save_submit_data(id, nThis){
if (!id) {
create_submit_data(nThis);
return;
}
var textContainer = $('#homePagePara_' + id);
var name = textContainer.find('input[name="config_name"]').val();
var description = textContainer.find('textarea[name="config_description"]').val();
$.ajax({
url: "<%= update_competition_text_managements_path %>",
data: {id: id, name: name, description: description},
type: "post",
success: function (data) {
if(data.status == 1) {
notice_box("保存成功!");
}
}
});
}
$(function(){
$('.add-competition-staff-btn').on('click', function(){
$('.competition-staff-settings').append($('.competition-staff-row-example').html());

@ -265,6 +265,7 @@ RedmineApp::Application.routes.draw do ## oauth相关
get 'export_chart_score'
post 'competition_images'
post 'publish'
post 'join_course'
end
collection do
post 'new_competition'
@ -730,6 +731,7 @@ RedmineApp::Application.routes.draw do ## oauth相关
get 'graduation_standard'
post 'create_standard'
post 'create_competition_text'
post 'update_competition_text'
delete 'delete_competition_text'
post 'add_contents_for_school'
post 'add_course_info_for_school'

@ -0,0 +1,8 @@
class ChangeCompetitionTextConfigs < ActiveRecord::Migration
def up
change_column :competition_text_configs, :description, :text
end
def down
end
end
Loading…
Cancel
Save