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.
educoder/app/models/examination_bank.rb

22 lines
560 B

5 years ago
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
5 years ago
has_many :examination_items, -> {order(position: :asc)}, dependent: :destroy
5 years ago
def apply?
!public && ApplyAction.where(container_type: "ExaminationBank", container_id: id, status: 0).exists?
end
5 years ago
def question_count
examination_items.size
end
def total_score
examination_items.pluck(:score).sum
end
end