Add course_focus view
All checks were successful
Build and Publish Docker Container / build (push) Successful in 5m13s

This commit is contained in:
Joshua Coles 2023-10-26 12:03:37 +01:00
parent fa9d9d8936
commit 9b57b7a646
4 changed files with 80 additions and 6 deletions

View File

@ -9,4 +9,8 @@ class AttendanceTrackerController < ApplicationController
@lectures = @courses.flat_map { |course| course.lectures.filter { |a| a.start_time.today? } }.sort_by { |l| l.start_time }
end
def course_focus
@course = Course.find(params[:id])
end
end

View File

@ -0,0 +1,75 @@
<h1 class="text-3xl font-medium"><%= @course.title %></h1>
<div class="flex flex-col gap-4">
<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 px-6 lg:px-8 w-full">
<div class="overflow-hidden shadow ring-1 ring-black ring-opacity-5 rounded-lg">
<div class="divide-y divide-gray-300 w-full">
<div class="py-3.5 justify-between bg-gray-50 text-left text-sm font-semibold text-gray-900 px-6 grid grid-cols-4">
<div>Lecture</div>
<div>Status</div>
<div>Action</div>
<div>Recording</div>
</div>
<% @course.lectures.sort_by(&:start_time).group_by(&:week_number).each do |(week_number, lectures)| %>
<div class="py-3.5 bg-gray-50 text-left text-sm font-semibold text-gray-900 px-6 grid grid-cols-4">
Week <%= week_number %>
</div>
<% lectures.each do |lecture| %>
<% status_classes = class_names({
'lecture-future': lecture.start_time.future?,
'bg-green-100': lecture.attended?,
}) %>
<div class="<%= status_classes %> px-6 py-4 flex justify-between bg-white items-center grid grid-cols-4">
<div class="whitespace-nowrap text-sm font-medium text-gray-900">
<%= lecture.title %>
</div>
<div class="whitespace-nowrap text-sm font-medium text-gray-900" data-controller="popover" data-action="mouseenter->popover#show mouseleave->popover#hide">
<%= render partial: 'lecture_status_icons', locals: { lecture: } %>
</div>
<div class="whitespace-nowrap text-sm font-medium text-gray-900">
<% joinable_time = lecture.start_time - 5.minutes %>
<% if joinable_time.future? %>
<%= button_to "Prepare",
lecture_start_preparation_path(id: lecture.id),
class: 'action-button'
%>
<% elsif joinable_time.past? && !lecture.attended? %>
<% start_label = if lecture.is_live? then
"Join"
else
"Start"
end %>
<%= button_to start_label,
lectures_start_path(id: lecture.id),
class: 'action-button'
%>
<% else %>
<%= button_to "Review",
lecture_start_review_path(id: lecture.id),
class: 'action-button'
%>
<% end %>
</div>
<div class="whitespace-nowrap text-sm font-medium text-gray-900">
<% if lecture.recording %>
<%= link_to "Open recording", lecture.recording&.recording_url %>
<% end %>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -58,12 +58,6 @@
</div>
<% end %>
</div>
<div class="whitespace-nowrap text-sm font-medium text-gray-900 sm:pl-6">
<% if lecture.recording %>
<%= link_to "Open recording", lecture.recording&.recording_url %>
<% end %>
</div>
</div>
<% end %>
</div>

View File

@ -11,6 +11,7 @@ Rails.application.routes.draw do
root controller: :attendance_tracker, action: :index
get '/today', controller: :attendance_tracker, action: :today
get '/courses/:id', controller: :attendance_tracker, action: :course_focus
post '/lectures/:id/start', to: 'lecture#start', as: :lectures_start
post '/lectures/:id/start_preparation', to: 'lecture#start_preparation', as: :lecture_start_preparation