You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
803 B
15 lines
803 B
6 years ago
|
class ExerciseGroupSetting < ApplicationRecord
|
||
|
belongs_to :exercise,optional:true
|
||
|
belongs_to :course_group,optional:true
|
||
|
belongs_to :course,optional:true
|
||
|
# attr_accessible :end_time, :publish_time
|
||
|
# scope :find_by_exercise_course,lambda{|k,v| where("#{k} =?",v)}
|
||
|
scope :end_time_no_null, -> { where("end_time is NOT NULL")}
|
||
|
scope :publish_time_no_null, -> { where("publish_time is NOT NULL")}
|
||
|
scope :exercise_group_not_published, -> {where("publish_time is NULL OR publish_time > ?",Time.now)}
|
||
|
scope :exercise_group_published, -> {where("publish_time IS NOT NULL AND publish_time <= ?",Time.now)}
|
||
|
scope :exercise_group_ended, -> {where("end_time is NOT NULL AND end_time <= ?",Time.now)}
|
||
|
|
||
|
scope :find_in_exercise_group, lambda { |name,ids| where("#{name}": ids)}
|
||
|
|
||
|
end
|