Continue adding problem sheets
This commit is contained in:
@@ -9,6 +9,8 @@ class Lecture < ApplicationRecord
|
||||
:problems_class,
|
||||
], default: :lecture
|
||||
|
||||
include Trackable
|
||||
|
||||
def prepared?
|
||||
tracked_time_entries.where(kind: [:preparation]).any?
|
||||
end
|
||||
@@ -25,10 +27,6 @@ class Lecture < ApplicationRecord
|
||||
tracked_time_entries.preparation.sum(&:duration).seconds
|
||||
end
|
||||
|
||||
def total_overall_time
|
||||
tracked_time_entries.sum(&:duration).seconds
|
||||
end
|
||||
|
||||
def total_attendance_time
|
||||
tracked_time_entries.where(kind: [:concurrent, :catchup]).sum(&:duration).seconds
|
||||
end
|
||||
|
||||
@@ -6,7 +6,9 @@ class TrackedTimeEntry < ApplicationRecord
|
||||
:catchup,
|
||||
|
||||
:preparation,
|
||||
:review
|
||||
:review,
|
||||
|
||||
:generic
|
||||
]
|
||||
|
||||
def duration
|
||||
|
||||
@@ -2,6 +2,16 @@ class WorkItem < ApplicationRecord
|
||||
belongs_to :course
|
||||
has_many :tracked_time_entries, dependent: :destroy, as: :subject
|
||||
|
||||
validate :due_date_after_start_date
|
||||
|
||||
include Trackable
|
||||
|
||||
def due_date_after_start_date
|
||||
if due_date.present? && start_time.present? && due_date < start_time
|
||||
errors.add(:due_date, "can't be before start date")
|
||||
end
|
||||
end
|
||||
|
||||
def week_number
|
||||
((start_time.beginning_of_week - course.semester_start_date.to_time) / 1.week).floor + 1
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user