lecture-attendance-manager/app/models/lecture.rb
Joshua Coles c8b688ce57
All checks were successful
Build and Publish Docker Container / build (push) Successful in 5m43s
Flesh out work items in the UI
2023-10-08 16:06:07 +01:00

42 lines
866 B
Ruby

class Lecture < ApplicationRecord
belongs_to :course
has_one :recording, dependent: :nullify
has_many :tracked_time_entries, dependent: :destroy, as: :subject
enum :kind, [
:lecture,
:problems_class,
], default: :lecture
include Trackable, CourseItem
def prepared?
tracked_time_entries.where(kind: [:preparation]).any?
end
def attended?
tracked_time_entries.where(kind: [:concurrent, :catchup]).any?
end
def reviewed?
tracked_time_entries.where(kind: [:review]).any?
end
def total_preparation_time
tracked_time_entries.preparation.sum(&:duration).seconds
end
def total_attendance_time
tracked_time_entries.where(kind: [:concurrent, :catchup]).sum(&:duration).seconds
end
def total_review_time
tracked_time_entries.review.sum(&:duration).seconds
end
def live_video_url
nil
end
end