module Sis module Core class Exam < ApplicationRecord belongs_to :exam_setup validates :title, :start, :finish, :pass_point, :points, presence: true before_validation :set_pass_point def set_pass_point self.pass_point = points / 2 unless pass_point || !points end delegate(:name, to: :exam_setup, prefix: true, allow_nil: false) end end end