|
|
|
@ -2,7 +2,7 @@ class ExaminationBanksController < ApplicationController
|
|
|
|
|
include PaginateHelper
|
|
|
|
|
before_action :require_login
|
|
|
|
|
before_action :find_exam, except: [:index, :create]
|
|
|
|
|
before_action :edit_auth, only: [:update, :destroy, :set_public]
|
|
|
|
|
before_action :edit_auth, only: [:update, :destroy, :set_public, :revoke_item]
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
|
exams = ExaminationBankQuery.call(params)
|
|
|
|
@ -62,6 +62,15 @@ class ExaminationBanksController < ApplicationController
|
|
|
|
|
render_ok
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def revoke_item
|
|
|
|
|
item = @exam.examination_items.find_by!(item_bank_id: params[:item_id])
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
@exam.examination_items.where(item_type: item.item_type).where("position > #{item.position}").update_all("position = position -1")
|
|
|
|
|
item.destroy!
|
|
|
|
|
end
|
|
|
|
|
render_ok
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def form_params
|
|
|
|
|