Continue adding problem sheets

This commit is contained in:
2023-10-08 15:46:19 +01:00
parent 7344ac3d67
commit f9f4762450
8 changed files with 82 additions and 7 deletions
+2 -4
View File
@@ -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
+3 -1
View File
@@ -6,7 +6,9 @@ class TrackedTimeEntry < ApplicationRecord
:catchup,
:preparation,
:review
:review,
:generic
]
def duration
+10
View File
@@ -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