diff --git a/app/controllers/attendance_tracker_controller.rb b/app/controllers/attendance_tracker_controller.rb index 23ea906..9f4dab9 100644 --- a/app/controllers/attendance_tracker_controller.rb +++ b/app/controllers/attendance_tracker_controller.rb @@ -6,5 +6,7 @@ class AttendanceTrackerController < ApplicationController def today @courses = Course.all.sort_by(&:title) @date = Date.today + + @lectures = @courses.flat_map { |course| course.lectures.filter { |a| a.start_time.today? } }.sort_by { |l| l.start_time } end end diff --git a/app/views/attendance_tracker/today.html.erb b/app/views/attendance_tracker/today.html.erb index ecc54c7..fee392b 100644 --- a/app/views/attendance_tracker/today.html.erb +++ b/app/views/attendance_tracker/today.html.erb @@ -1,63 +1,132 @@

Attendance Tracker

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

- <%= course.title %> -

- - <% if course.homepage.present? %> - - - - <% end %> -
- - - - - - - - - - - - - - <% course.lectures_and_work_items.group_by { |lecture| lecture.week_number }.each do |(week_number, lectures)| %> - - - - - <%= render lectures %> - <% end %> - -
LectureDateStatusAction
-
-
- Week <%= week_number %> -
- -
- <% total_for_week = lectures.sum { |lecture| lecture.total_overall_time }.seconds %> - <%# 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) %> - <% if total_for_week > 0 %> - (Total <%= humanise_duration(lectures.sum { |lecture| lecture.total_overall_time }.seconds) %> - ) - <% end %> -
-
-
+
+
+
+
+
+

+ Today +

+ + + + + + + + + + + + + + + <% @lectures.each do |lecture| %> + + + + + + + + + + + + <% end %> + +
CourseLectureDateStatusAction
+ <%= lecture.course.title %> + + <%= lecture.title %> + + <%= lecture.start_time.to_fs(:dmy) %> + +
+ <% prep_icon_class = if lecture.prepared? + 'text-green-700' + else + 'text-slate-300' + end %> + + + <% if lecture.attended? %> + <% if lecture.entirely_attended_in_person? %> + + <% else %> + + <% end %> + <% elsif lecture.is_live? %> + + <% 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 %> + +
+ + +
+ <% 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 %> +
+ <% if lecture.recording %> + <%= link_to "Open recording", lecture.recording&.recording_url %> + <% end %> +
- <% end %> +
diff --git a/app/views/lecture/start.html.erb b/app/views/lecture/start.html.erb deleted file mode 100644 index 914aa7d..0000000 --- a/app/views/lecture/start.html.erb +++ /dev/null @@ -1,4 +0,0 @@ -
-

Lecture#start

-

Find me in app/views/lecture/start.html.erb

-
diff --git a/app/views/work_item/complete.html.erb b/app/views/work_item/complete.html.erb deleted file mode 100644 index 5fa51ca..0000000 --- a/app/views/work_item/complete.html.erb +++ /dev/null @@ -1,4 +0,0 @@ -
-

WorkItem#complete

-

Find me in app/views/work_item/complete.html.erb

-
diff --git a/app/views/work_item/start_time_entry.html.erb b/app/views/work_item/start_time_entry.html.erb deleted file mode 100644 index 0db09d3..0000000 --- a/app/views/work_item/start_time_entry.html.erb +++ /dev/null @@ -1,4 +0,0 @@ -
-

WorkItem#start_time_entry

-

Find me in app/views/work_item/start_time_entry.html.erb

-
diff --git a/config/routes.rb b/config/routes.rb index 4abb673..819356c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,6 +10,7 @@ Rails.application.routes.draw do end root controller: :attendance_tracker, action: :index + get '/today', controller: :attendance_tracker, action: :today post '/lectures/:id/start', to: 'lecture#start', as: :lectures_start post '/lectures/:id/start_preparation', to: 'lecture#start_preparation', as: :lecture_start_preparation