destroy
This commit is contained in:
parent
a8045f54d3
commit
71f6bbf2c4
|
@ -2,7 +2,7 @@
|
|||
class ChallengesController < ApplicationController
|
||||
layout "base_shixun"
|
||||
before_filter :find_shixun, :only => [:index, :new, :create, :destroy, :challenge_build]
|
||||
before_filter :find_challenge, :only => [:show, :edit, :update, :challenge_build, :index_up, :index_down]
|
||||
before_filter :find_challenge, :only => [:show, :edit, :update, :challenge_build, :index_up, :index_down, :destroy]
|
||||
before_filter :authorize_tpi, :only => [:new, :create]
|
||||
before_filter :build_challege_from_params, :only => [:new, :create]
|
||||
before_filter :tpi_manager_allowed, :only => [:challenge_build]
|
||||
|
@ -79,6 +79,10 @@ class ChallengesController < ApplicationController
|
|||
def edit
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @challenge.update_attributes(params[:challenge])
|
||||
|
@ -153,40 +157,40 @@ class ChallengesController < ApplicationController
|
|||
end
|
||||
|
||||
def game_build_result
|
||||
status = params[:status].to_i
|
||||
task_id = params[:taskId]
|
||||
message = Base64.decode64(params[:msg]) unless params[:msg].blank?
|
||||
begin
|
||||
@training_task = TrainingTask.find(task_id)
|
||||
# 如果已经执行成功过,则不重复执行
|
||||
return if @training_task.status == 1
|
||||
original_project_id = Project.find(@training_task.project_id).try(:forked_from_project_id)
|
||||
original_project = Project.find(original_project_id)
|
||||
rescue
|
||||
return
|
||||
end
|
||||
original_tasks_count = original_project.training_tasks.count
|
||||
position = @training_task.try(:position)
|
||||
# 测试,默认成功
|
||||
if status == 0
|
||||
ActiveRecord::Base.transaction do
|
||||
if position < original_tasks_count
|
||||
# 继续发布下一个任务
|
||||
publish_training_tasks original_project_id, @training_task.project_id, position + 1, original_project.user_id
|
||||
end
|
||||
@training_task.update_attribute(:status, 1)
|
||||
@training_task.update_attribute(:result, 1)
|
||||
# 创建一条回复提醒
|
||||
content = (position == original_tasks_count) ? "恭喜您,您已经完成了实训项目的所有任务" : "恭喜您,您已经完成了本任务,请继续下一任务"
|
||||
add_training_task_journal(content, original_project.user_id)
|
||||
end
|
||||
else
|
||||
content = "很抱歉,您的任务未通过,请继续加油,错误信息如下:#{message}"
|
||||
add_training_task_journal(content, original_project.user_id)
|
||||
# 失败的时候可以继续提交
|
||||
@training_task.update_attribute(:status, 0)
|
||||
@training_task.update_attribute(:result, 2)
|
||||
end
|
||||
# status = params[:status].to_i
|
||||
# task_id = params[:taskId]
|
||||
# message = Base64.decode64(params[:msg]) unless params[:msg].blank?
|
||||
# begin
|
||||
# @training_task = TrainingTask.find(task_id)
|
||||
# # 如果已经执行成功过,则不重复执行
|
||||
# return if @training_task.status == 1
|
||||
# original_project_id = Project.find(@training_task.project_id).try(:forked_from_project_id)
|
||||
# original_project = Project.find(original_project_id)
|
||||
# rescue
|
||||
# return
|
||||
# end
|
||||
# original_tasks_count = original_project.training_tasks.count
|
||||
# position = @training_task.try(:position)
|
||||
# # 测试,默认成功
|
||||
# if status == 0
|
||||
# ActiveRecord::Base.transaction do
|
||||
# if position < original_tasks_count
|
||||
# # 继续发布下一个任务
|
||||
# publish_training_tasks original_project_id, @training_task.project_id, position + 1, original_project.user_id
|
||||
# end
|
||||
# @training_task.update_attribute(:status, 1)
|
||||
# @training_task.update_attribute(:result, 1)
|
||||
# # 创建一条回复提醒
|
||||
# content = (position == original_tasks_count) ? "恭喜您,您已经完成了实训项目的所有任务" : "恭喜您,您已经完成了本任务,请继续下一任务"
|
||||
# add_training_task_journal(content, original_project.user_id)
|
||||
# end
|
||||
# else
|
||||
# content = "很抱歉,您的任务未通过,请继续加油,错误信息如下:#{message}"
|
||||
# add_training_task_journal(content, original_project.user_id)
|
||||
# # 失败的时候可以继续提交
|
||||
# @training_task.update_attribute(:status, 0)
|
||||
# @training_task.update_attribute(:result, 2)
|
||||
# end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,10 +1,3 @@
|
|||
<%= content_for(:header_tags) do %>
|
||||
<%= import_ke(enable_at: true) %>
|
||||
<%= javascript_include_tag 'create_kindeditor'%>
|
||||
<% end %>
|
||||
<script>
|
||||
sd_create_editor_from_data(<%= @challenge.id %>, null, "100%", "<%= @challenge.class.name %>");
|
||||
</script>
|
||||
<div class="task-pm-content mb20">
|
||||
<div class="task-pm-box mt20">
|
||||
<div class="panel-header clearfix">
|
||||
|
|
Loading…
Reference in New Issue