试题预览页的删除单个试题

dev_jupyter
cxt 5 years ago
parent 452d713f00
commit 1e670b56cd

@ -56,6 +56,7 @@ class ExaminationBanksController < ApplicationController
def set_public def set_public
tip_exception(-1, "该试卷已公开") if @exam.public? tip_exception(-1, "该试卷已公开") if @exam.public?
@exam.update_attributes!(public: 1) @exam.update_attributes!(public: 1)
render_ok render_ok
end end

@ -29,10 +29,9 @@ class ItemBasketsController < ApplicationController
end end
def destroy def destroy
item = current_user.item_baskets.find_by!(item_bank_id: params[:id])
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
current_user.item_baskets.where(item_type: item.item_type).where("position > #{item.position}").update_all("position = position -1") current_user.item_baskets.where(item_type: current_basket.item_type).where("position > #{current_basket.position}").update_all("position = position -1")
item.destroy! current_basket.destroy!
end end
render_ok render_ok
end end

Loading…
Cancel
Save