Attendance Tracker

<% @courses.each do |course| %>

<%= course.title %>

<% course.lectures.order(:start_time).group_by { |lecture| lecture.week_number }.each do |(week_number, lectures)| %> <% lectures.reject(&:cancelled).each do |lecture| %> <% if lecture.cancelled %> <% else %> <% end %> <% end %> <% end %>
Lecture Date Status Action Recording
Week <%= week_number %>
<%# TODO: Improve this figure, atm it is for lectures in week, not time spent in week (ie prepping for lecture next week will count in next week not current week) %> (Total <%= humanise_duration(lectures.sum { |lecture| lecture.total_overall_time }.seconds) %>)
<%= lecture.title %> <%= lecture.start_time.to_fs(:dmy) %>
Cancelled
<% prep_icon_class = if lecture.prepared? 'text-green-700' else 'text-slate-300' end %> <% if lecture.attended? %> <% elsif lecture.start_time.past? %> <% else %>
<% end %> <% reviewed_icon_class = if lecture.start_time.future? 'invisible' elsif lecture.reviewed? 'text-green-700' else 'text-slate-300' end %>
<% if lecture.start_time.future? %> <%= button_to "Prepare", lecture_start_preparation_path(id: lecture.id), class: 'action-button' %> <% elsif lecture.start_time.past? && !lecture.attended? %> <%= button_to "Start", lectures_start_path(id: lecture.id), class: 'action-button' %> <% else %>
<%= button_to "Review", lecture_start_review_path(id: lecture.id), class: 'action-button' %>
<% end %>
<% if lecture.recording %> <%= link_to "Open recording", lecture.recording&.recording_url %> <% end %>
<% end %>