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 = self.points / 2 unless self.pass_point || !self.points end end end end