Update Lecture-Recording relationship and add Lecture cancellation status

The commit introduces notable changes to the Lecture-Recording model relationship in our application and adds a new cancellation status to Lecture model.

Models Lecture and Recording previously had a belongs_to :recording and belongs_to :lecture relationship respectively. However, this setup was not reflecting the correct relationship between these two entities in the actual educational setup where a lecture can have a recording but a recording is always of a lecture. Thus, the relationship has been revised to has_one :recording in Lecture and belongs_to :lecture in Recording models.

Also, added the ability to mark a lecture as "cancelled". This addresses the requirement of representing real-world scenarios where lectures are sometimes cancelled. This cancellation status is then reflected in the Attendance Tracker view and is also handled in the ScrapePanoptoJob.

Additionally, new changes are reflected in the application's schema, migration files, admin dashboard, and stylesheets (for displaying cancelled lectures).
This commit is contained in:
2023-10-02 09:47:46 +01:00
parent d8a6f27734
commit 58c1280309
10 changed files with 45 additions and 10 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
class Lecture < ApplicationRecord
belongs_to :course
has_one :attendance
belongs_to :recording, optional: true
has_one :recording
def week_number
((start_time.beginning_of_week - course.semester_start_date.to_time) / 1.week).floor + 1
+9
View File
@@ -1,6 +1,7 @@
# This is a Foreign Object Reference Table, keyed to the external data source by #recording_uuid
class Recording < ApplicationRecord
belongs_to :course
belongs_to :lecture, optional: true
def recording_url
return nil if recording_uuid.nil?
@@ -17,4 +18,12 @@ class Recording < ApplicationRecord
title
end
def create_lecture!(fixup_time: false)
Lecture.create!(
title: nice_title,
course: course,
recording: self
)
end
end