Sha256: a812a46a8624304f744887cb542ebac32a370748954dad4ccd3cbeb5eb2cc1eb

Contents?: true

Size: 538 Bytes

Versions: 4

Compression:

Stored size: 538 Bytes

Contents

module Sis
  module Core
    class ExamResult < ApplicationRecord
      PASS = 'Pass'.freeze
      FAIL = 'Fail'.freeze

      belongs_to :exam
      belongs_to :application

      validates :points, presence: true
      validates_uniqueness_of :application_id, scope: %i[exam_id]

      before_validation :set_status

      def set_status
        self.status = if exam && exam.pass_point >= points
                        PASS
                      else
                        FAIL
                      end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sis_core-1.0.20 app/models/sis/core/exam_result.rb
sis_core-1.0.19 app/models/sis/core/exam_result.rb
sis_core-1.0.18 app/models/sis/core/exam_result.rb
sis_core-1.0.17 app/models/sis/core/exam_result.rb