Class: CourseExam
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- CourseExam
- 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
-
.active ⇒ ActiveRecord::Relation<CourseExam>
A relation of CourseExams that are active.
-
.passed ⇒ ActiveRecord::Relation<CourseExam>
A relation of CourseExams that are passed.
-
.sorted ⇒ ActiveRecord::Relation<CourseExam>
A relation of CourseExams that are sorted.
Instance Method Summary collapse
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Models::EventPublishable
Class Method Details
.active ⇒ ActiveRecord::Relation<CourseExam>
A relation of CourseExams that are active. Active Record Scope
33 |
# File 'app/models/course_exam.rb', line 33 scope :active, -> { where(state: 'in_progress') } |
.passed ⇒ ActiveRecord::Relation<CourseExam>
A relation of CourseExams that are passed. Active Record Scope
32 |
# File 'app/models/course_exam.rb', line 32 scope :passed, -> { where(state: 'passed')} |
.sorted ⇒ ActiveRecord::Relation<CourseExam>
A relation of CourseExams that are sorted. Active Record Scope
34 |
# File 'app/models/course_exam.rb', line 34 scope :sorted, -> { order(:position) } |
Instance Method Details
#course_enrollment ⇒ CourseEnrollment
25 |
# File 'app/models/course_exam.rb', line 25 belongs_to :course_enrollment, optional: true |
#customer_topics ⇒ ActiveRecord::Relation<CustomerTopic>
28 |
# File 'app/models/course_exam.rb', line 28 has_many :customer_topics, -> { order(:position) }, inverse_of: :course_exam |
#cutoff_mark ⇒ Object
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
71 72 73 |
# File 'app/models/course_exam.rb', line 71 def failed? return state == 'failed' end |
#in_progress? ⇒ Boolean
67 68 69 |
# File 'app/models/course_exam.rb', line 67 def in_progress? return state == 'in_progress' end |
#passed? ⇒ Boolean
75 76 77 |
# File 'app/models/course_exam.rb', line 75 def passed? return state == 'passed' end |
#topic_exam ⇒ TopicExam
26 |
# File 'app/models/course_exam.rb', line 26 belongs_to :topic_exam, optional: true |