删除关卡问题

courseware
daiao 5 years ago
parent 5ae1597bcb
commit eb67724fc5

@ -313,19 +313,27 @@ class ChallengesController < ApplicationController
end
rescue => e
tip_exception("上移失败: #{e.message}")
raise ActiveRecord::Rollback
end
end
def destroy
next_challenges = @shixun.challenges.where("position > #{@challenge.position}")
next_challenges.update_all("position = position - 1")
# Todo: 实训修改后,关卡需要重置
# shixun_modify_status_without_publish(@shixun, 1)
@challenge.destroy
# 关卡位置被删除,需要修改脚本
script = modify_shixun_script @shixun, @shixun.evaluate_script
@shixun.shixun_info.update_column(:evaluate_script, script)
begin
ActiveRecord::Base.transaction do
next_challenges.update_all("position = position - 1")
# Todo: 实训修改后,关卡需要重置
# shixun_modify_status_without_publish(@shixun, 1)
@challenge.destroy
# 关卡位置被删除,需要修改脚本
script = modify_shixun_script @shixun, @shixun.evaluate_script
@shixun.shixun_info.update_column(:evaluate_script, script)
end
rescue => e
tip_exception("删除关卡失败: #{e.message}")
raise ActiveRecord::Rollback
end
end

Loading…
Cancel
Save