|
|
|
@ -1,5 +1,8 @@
|
|
|
|
|
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]
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
|
exams = ExaminationBankQuery.call(params)
|
|
|
|
@ -43,9 +46,32 @@ class ExaminationBanksController < ApplicationController
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def update
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
|
@exam.destroy!
|
|
|
|
|
render_ok
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def set_public
|
|
|
|
|
tip_exception(-1, "该试卷已公开") if @exam.public?
|
|
|
|
|
@exam.update_attributes!(public: 1)
|
|
|
|
|
render_ok
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def form_params
|
|
|
|
|
params.permit(:discipline_id, :sub_discipline_id, :difficulty, :name, :duration, tag_discipline_id: [])
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def find_exam
|
|
|
|
|
@exam = ExaminationBank.find_by!(id: params[:id])
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def edit_auth
|
|
|
|
|
current_user.admin_or_business? || @exam.user == current_user
|
|
|
|
|
end
|
|
|
|
|
end
|