Flesh out work items in the UI
Build and Publish Docker Container / build (push) Successful in 5m43s

This commit is contained in:
2023-10-08 16:06:07 +01:00
parent f9f4762450
commit c8b688ce57
14 changed files with 123 additions and 36 deletions
+5
View File
@@ -0,0 +1,5 @@
module Trackable
def total_overall_time
tracked_time_entries.sum(&:duration)
end
end
+7
View File
@@ -0,0 +1,7 @@
# frozen_string_literal: true
module CourseItem
def week_number
((start_time.beginning_of_week - course.semester_start_date.to_time) / 1.week).floor + 1
end
end
+1 -5
View File
@@ -9,7 +9,7 @@ class Lecture < ApplicationRecord
:problems_class,
], default: :lecture
include Trackable
include Trackable, CourseItem
def prepared?
tracked_time_entries.where(kind: [:preparation]).any?
@@ -35,10 +35,6 @@ class Lecture < ApplicationRecord
tracked_time_entries.review.sum(&:duration).seconds
end
def week_number
((start_time.beginning_of_week - course.semester_start_date.to_time) / 1.week).floor + 1
end
def live_video_url
nil
end
+30 -9
View File
@@ -2,17 +2,38 @@ class WorkItem < ApplicationRecord
belongs_to :course
has_many :tracked_time_entries, dependent: :destroy, as: :subject
validate :due_date_after_start_date
validate :date_orderings
include Trackable, CourseItem
include Trackable
def start_time
available_from
end
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")
def completed?
completed_at.present?
end
def complete!
update(completed_at: Time.now)
end
def workable?
available_from.past? && !completed?
end
def started?
!tracked_time_entries.empty?
end
private
def date_orderings
if due_at.present? && available_from.present? && due_at < available_from
errors.add(:due_at, "can't be before date work item is available")
end
if completed_at.present? && available_from.present? && completed_at < available_from
errors.add(:completed_at, "can't be before date work item is available")
end
end
def week_number
((start_time.beginning_of_week - course.semester_start_date.to_time) / 1.week).floor + 1
end
end