删除关卡问题

courseware
daiao 5 years ago
parent 5ae1597bcb
commit eb67724fc5

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

Loading…
Cancel
Save