@ -12,7 +12,7 @@ class Admins::ExaminationAuthenticationsController < Admins::BaseController
ActiveRecord::Base.transaction do
exam = ExaminationBank.find current_apply.container_id
current_apply.update!(status: 1)
exam.update!(public: 0)
exam.update!(public: 1)
end
render_success_js
@ -16,7 +16,7 @@ class Admins::ItemAuthenticationsController < Admins::BaseController
item = ItemBank.find current_apply.container_id
item.update!(public: 0)
item.update!(public: 1)
@ -50,9 +50,12 @@ class ExaminationBanksController < ApplicationController
def destroy
ApplyAction.where(container_type: "ExaminationBank", container_id: @exam.id).destroy_all
@exam.destroy!
render_ok
def set_public
tip_exception(-1, "该试卷已公开") if @exam.public?
@ -39,9 +39,12 @@ class ItemBanksController < ApplicationController
ApplyAction.where(container_type: "ItemBank", container_id: @item.id).destroy_all
@item.destroy!
tip_exception(-1, "该试题已公开") if @item.public?
@ -7,6 +7,10 @@ class ExaminationBank < ApplicationRecord
has_many :examination_items, -> {order(position: :asc)}, dependent: :destroy
def apply?
!public && ApplyAction.where(container_type: "ExaminationBank", container_id: id, status: 0).exists?
def question_count
examination_items.size
@ -18,6 +18,10 @@ class ItemBank < ApplicationRecord
item_analysis&.analysis
!public && ApplyAction.where(container_type: "ItemBank", container_id: id, status: 0).exists?
def type_string
result = case item_type
when "SINGLE"
@ -1,8 +1,9 @@
json.exams @exams.each do |exam|
json.(exam, :id, :name, :difficulty, :quotes)
json.(exam, :id, :name, :difficulty, :quotes, :public)
json.question_count exam.question_count
json.total_score exam.total_score
json.update_time exam.updated_at&.strftime("%Y-%m-%d %H:%M")
json.apply exam.apply?
json.author do
json.login exam.user&.login
json.name exam.user&.full_name
@ -3,6 +3,7 @@ json.items @items.each do |item|
json.partial! "item_banks/item", locals: {item: item}
json.update_time item.updated_at&.strftime("%Y-%m-%d %H:%M")
json.choosed @item_basket_ids.include?(item.id)
json.apply item.apply?
json.login item.user&.login
json.name item.user&.full_name