|
|
|
@ -287,22 +287,35 @@ class ChallengesController < ApplicationController
|
|
|
|
|
def index_down
|
|
|
|
|
next_challenge = @challenge.next_challenge
|
|
|
|
|
position = @challenge.position
|
|
|
|
|
@challenge.update_attribute(:position, (position + 1))
|
|
|
|
|
next_challenge.update_attribute(:position, next_challenge.position - 1)
|
|
|
|
|
begin
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
@challenge.update_attributes!(position: (position + 1))
|
|
|
|
|
next_challenge.update_attributes!(position: next_challenge.position - 1)
|
|
|
|
|
# 关卡位置被修改,需要修改脚本
|
|
|
|
|
script = modify_shixun_script @shixun, @shixun.evaluate_script
|
|
|
|
|
@shixun.shixun_info.update_column(:evaluate_script, script)
|
|
|
|
|
@shixun.shixun_info.update_attributes!(evaluate_script: script)
|
|
|
|
|
end
|
|
|
|
|
rescue => e
|
|
|
|
|
tip_exception("下移失败: #{e.message}")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def index_up
|
|
|
|
|
position = @challenge.position
|
|
|
|
|
last_challenge = @challenge.last_challenge
|
|
|
|
|
begin
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
@challenge.update_attribute(:position, (position - 1))
|
|
|
|
|
last_challenge.update_attribute(:position, last_challenge.position + 1)
|
|
|
|
|
# 关卡位置被修改,需要修改脚本
|
|
|
|
|
script = modify_shixun_script @shixun, @shixun.evaluate_script
|
|
|
|
|
@shixun.shixun_info.update_column(:evaluate_script, script)
|
|
|
|
|
end
|
|
|
|
|
rescue => e
|
|
|
|
|
tip_exception("上移失败: #{e.message}")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
|
next_challenges = @shixun.challenges.where("position > #{@challenge.position}")
|
|
|
|
|