Class: CourseExam

Inherits:
ApplicationRecord show all
Defined in:
app/models/course_exam.rb

Overview

== Schema Information

Table name: course_exams
Database name: primary

id :bigint not null, primary key
position :integer
score :integer
state :string
created_at :datetime not null
updated_at :datetime not null
course_enrollment_id :integer
topic_exam_id :integer

Indexes

index_course_exams_on_course_enrollment_id (course_enrollment_id)

Foreign Keys

fk_rails_... (course_enrollment_id => course_enrollments.id)

Belongs to collapse

Has many collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::EventPublishable

#publish_event

Class Method Details

.activeActiveRecord::Relation<CourseExam>

A relation of CourseExams that are active. Active Record Scope

Returns:

See Also:



33
# File 'app/models/course_exam.rb', line 33

scope :active, -> { where(state: 'in_progress') }

.passedActiveRecord::Relation<CourseExam>

A relation of CourseExams that are passed. Active Record Scope

Returns:

See Also:



32
# File 'app/models/course_exam.rb', line 32

scope :passed, -> { where(state: 'passed')}

.sortedActiveRecord::Relation<CourseExam>

A relation of CourseExams that are sorted. Active Record Scope

Returns:

See Also:



34
# File 'app/models/course_exam.rb', line 34

scope :sorted, -> { order(:position) }

Instance Method Details

#course_enrollmentCourseEnrollment



25
# File 'app/models/course_exam.rb', line 25

belongs_to :course_enrollment, optional: true

#customer_topicsActiveRecord::Relation<CustomerTopic>

Returns:

See Also:



28
# File 'app/models/course_exam.rb', line 28

has_many :customer_topics, -> { order(:position) }, inverse_of: :course_exam

#cutoff_markObject



79
80
81
# File 'app/models/course_exam.rb', line 79

def cutoff_mark
  topic_exam.min_score_to_pass.to_i
end

#failed?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'app/models/course_exam.rb', line 71

def failed?
  return state == 'failed'
end

#in_progress?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'app/models/course_exam.rb', line 67

def in_progress?
  return state == 'in_progress'
end

#passed?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'app/models/course_exam.rb', line 75

def passed?
  return state == 'passed'
end

#topic_examTopicExam

Returns:

See Also:



26
# File 'app/models/course_exam.rb', line 26

belongs_to :topic_exam, optional: true