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).
79 lines
4.0 KiB
Plaintext
79 lines
4.0 KiB
Plaintext
<h1 class="text-3xl font-medium">Attendance Tracker</h1>
|
|
|
|
<div class="px-4 sm:px-6 lg:px-8">
|
|
<% @courses.each do |course| %>
|
|
<div class="mt-8 flow-root">
|
|
<div class="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
|
|
<div class="inline-block py-2 align-middle sm:px-6 lg:px-8">
|
|
<div class="overflow-hidden shadow ring-1 ring-black ring-opacity-5 sm:rounded-lg">
|
|
<h2 class="text-2xl p-2 px-4"><%= course.title %></h2>
|
|
|
|
<table class="border-t-2 divide-y divide-gray-300">
|
|
<thead class="bg-gray-50">
|
|
<tr>
|
|
<th scope="col" class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">Lecture</th>
|
|
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Date</th>
|
|
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Status</th>
|
|
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Action</th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody class="divide-y divide-gray-200 bg-white">
|
|
<% course.lectures.order(:start_time).group_by { |lecture| lecture.week_number }.each do |(week_number, lectures)| %>
|
|
<tr class="border-t border-gray-200">
|
|
<th colspan="4" scope="colgroup" class="bg-gray-50 py-2 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">Week <%= week_number %></th>
|
|
</tr>
|
|
|
|
<% lectures.each do |lecture| %>
|
|
<tr class="<%= class_names({
|
|
'lecture-future': lecture.start_time.future?,
|
|
'lecture-cancelled': lecture.cancelled,
|
|
}) %>">
|
|
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6">
|
|
<%= lecture.title %>
|
|
</td>
|
|
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
|
<%= lecture.start_time.to_fs(:dmy) %>
|
|
</td>
|
|
|
|
<% if lecture.start_time.future? || lecture.cancelled %>
|
|
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
|
</td>
|
|
|
|
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
|
</td>
|
|
<% else %>
|
|
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
|
<% if lecture.attendance.nil? %>
|
|
<i class="fa fa-times text-red-700"></i>
|
|
<% elsif lecture.attendance.kind == 'concurrent' %>
|
|
<i class="fa fa-chalkboard-user fa-green-700"></i>
|
|
<% elsif lecture.attendance.kind == 'catchup' %>
|
|
<i class="fa fa-video fa-green-700"></i>
|
|
<% else %>
|
|
<% lecture.attendance.kind %>
|
|
<% end %>
|
|
</td>
|
|
|
|
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
|
<% if lecture.attendance.nil? %>
|
|
<button type="button" class="rounded bg-indigo-600 px-2 py-1 font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">
|
|
Start
|
|
</button>
|
|
<% else %>
|
|
<%= link_to "Open recording", lecture.recording.recording_url %>
|
|
<% end %>
|
|
</td>
|
|
<% end %>
|
|
</tr>
|
|
<% end %>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
</div>
|