Class: Course::Video

Inherits:
ApplicationRecord show all
Includes:
ClosingReminderConcern, UrlConcern
Defined in:
app/models/course/video.rb

Defined Under Namespace

Modules: UrlConcern, VideosHelper Classes: ClosingReminderJob, Controller, Event, ReminderService, Session, Submission, Tab, Topic, TopicsController, VideosController

Constant Summary

Constants included from UrlConcern

UrlConcern::YOUTUBE_FORMAT

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.ordered_by_date_and_titleObject

Orders the videos by the starting date and title.


23
24
25
26
27
# File 'app/models/course/video.rb', line 23

scope :ordered_by_date_and_title, (lambda do
  select('course_videos.*, course_lesson_plan_items.start_at, course_lesson_plan_items.title').
    joins(:lesson_plan_item).
    merge(Course::LessonPlan::Item.ordered_by_date_and_title)
end)

.use_relative_model_naming?Boolean


66
67
68
# File 'app/models/course/video.rb', line 66

def self.use_relative_model_naming?
  true
end

Instance Method Details

#include_in_consolidated_email?(event) ⇒ Boolean


84
85
86
# File 'app/models/course/video.rb', line 84

def include_in_consolidated_email?(event)
  Course::Settings::VideosComponent.email_enabled?(course, "video_#{event}".to_sym)
end

#initialize_duplicate(duplicator, other) ⇒ Object


78
79
80
81
82
# File 'app/models/course/video.rb', line 78

def initialize_duplicate(duplicator, other)
  copy_attributes(other, duplicator)
  self.course = duplicator.options[:destination_course]
  initialize_duplicate_tab(duplicator, other)
end

#next_videoObject


70
71
72
# File 'app/models/course/video.rb', line 70

def next_video
  Course::Video.video_after(self).first
end

#to_partial_pathObject


74
75
76
# File 'app/models/course/video.rb', line 74

def to_partial_path
  'course/video/videos/video'
end

#with_submissions_by(creator) ⇒ Object

Includes the submissions by the provided user.


32
33
34
35
36
37
38
39
40
# File 'app/models/course/video.rb', line 32

scope :with_submissions_by, (lambda do |user|
  submissions = Course::Video::Submission.by_user(user).
    where(video: distinct(false).pluck(:id))

  all.to_a.tap do |result|
    preloader = ActiveRecord::Associations::Preloader::ManualPreloader.new
    preloader.preload(result, :submissions, submissions)
  end
end)