You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
560 B
22 lines
560 B
class ExaminationBank < ApplicationRecord
|
|
belongs_to :user
|
|
belongs_to :sub_discipline
|
|
|
|
has_many :tag_discipline_containers, as: :container, dependent: :destroy
|
|
has_many :tag_disciplines, through: :tag_discipline_containers
|
|
|
|
has_many :examination_items, -> {order(position: :asc)}, dependent: :destroy
|
|
|
|
def apply?
|
|
!public && ApplyAction.where(container_type: "ExaminationBank", container_id: id, status: 0).exists?
|
|
end
|
|
|
|
def question_count
|
|
examination_items.size
|
|
end
|
|
|
|
def total_score
|
|
examination_items.pluck(:score).sum
|
|
end
|
|
end
|