Make it a little generic, time to step away for now
All checks were successful
Build and Publish Docker Container / build (push) Successful in 5m55s
All checks were successful
Build and Publish Docker Container / build (push) Successful in 5m55s
This commit is contained in:
parent
8fd4072af3
commit
7344ac3d67
@ -6,6 +6,10 @@ class Course < ApplicationRecord
|
|||||||
# we them independently to avoid re-importing lectures.
|
# we them independently to avoid re-importing lectures.
|
||||||
has_many :recordings, dependent: :destroy
|
has_many :recordings, dependent: :destroy
|
||||||
|
|
||||||
|
def lectures_and_work_items
|
||||||
|
(lectures + work_items).sort_by(&:start_time)
|
||||||
|
end
|
||||||
|
|
||||||
def import_from_calendar!
|
def import_from_calendar!
|
||||||
ics_file = HTTParty.get("https://mytimetable.bath.ac.uk/ical?6519757b&group=false&timetable=!MjAyMyFzdHVkZW50c2V0ITRDRjQ5MjlGRTg1M0Q4N0MyMDZENTVDNUQ3QTJFNzk0&eu=amMzMDkxQGJhdGguYWMudWs=&h=MiuDbRiudE_Yf7B25v2SfEuFCtmYGkFb5sAUI3yGmtY=")
|
ics_file = HTTParty.get("https://mytimetable.bath.ac.uk/ical?6519757b&group=false&timetable=!MjAyMyFzdHVkZW50c2V0ITRDRjQ5MjlGRTg1M0Q4N0MyMDZENTVDNUQ3QTJFNzk0&eu=amMzMDkxQGJhdGguYWMudWs=&h=MiuDbRiudE_Yf7B25v2SfEuFCtmYGkFb5sAUI3yGmtY=")
|
||||||
calendars = Icalendar::Calendar.parse(ics_file)
|
calendars = Icalendar::Calendar.parse(ics_file)
|
||||||
|
|||||||
@ -1,4 +1,8 @@
|
|||||||
class WorkItem < ApplicationRecord
|
class WorkItem < ApplicationRecord
|
||||||
belongs_to :course
|
belongs_to :course
|
||||||
has_many :tracked_time_entries, dependent: :destroy, as: :subject
|
has_many :tracked_time_entries, dependent: :destroy, as: :subject
|
||||||
|
|
||||||
|
def week_number
|
||||||
|
((start_time.beginning_of_week - course.semester_start_date.to_time) / 1.week).floor + 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody class="divide-y divide-gray-200 bg-white">
|
<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)| %>
|
<% course.lectures_and_work_items.group_by { |lecture| lecture.week_number }.each do |(week_number, lectures)| %>
|
||||||
<tr class="border-t border-gray-200">
|
<tr class="border-t border-gray-200">
|
||||||
<th colspan="5" scope="colgroup" class="bg-gray-50 py-2 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">
|
<th colspan="5" scope="colgroup" class="bg-gray-50 py-2 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">
|
||||||
<div class="flex flex-row justify-between">
|
<div class="flex flex-row justify-between">
|
||||||
@ -41,98 +41,7 @@
|
|||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<% lectures.reject(&:cancelled).each do |lecture| %>
|
<%= render lectures %>
|
||||||
<tr class="<%= class_names({
|
|
||||||
'lecture-future': lecture.start_time.future?,
|
|
||||||
'bg-green-100': lecture.attended?,
|
|
||||||
}) %>">
|
|
||||||
<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.cancelled %>
|
|
||||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" colspan="3">
|
|
||||||
<div class="flex justify-center">
|
|
||||||
Cancelled
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<% else %>
|
|
||||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" data-controller="popover" data-action="mouseenter->popover#show mouseleave->popover#hide">
|
|
||||||
<div class="flex flex-row gap-2">
|
|
||||||
<% prep_icon_class = if lecture.prepared?
|
|
||||||
'text-green-700'
|
|
||||||
else
|
|
||||||
'text-slate-300'
|
|
||||||
end %>
|
|
||||||
<i class="fa fa-hourglass-start <%= prep_icon_class %>"></i>
|
|
||||||
|
|
||||||
<% if lecture.attended? %>
|
|
||||||
<i class="fa fa-chalkboard-user text-green-700"></i>
|
|
||||||
<% elsif lecture.start_time.past? %>
|
|
||||||
<i class="fa fa-times text-red-700"></i>
|
|
||||||
<% else %>
|
|
||||||
<div class="flex-grow"></div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% reviewed_icon_class = if lecture.start_time.future?
|
|
||||||
'invisible'
|
|
||||||
elsif lecture.reviewed?
|
|
||||||
'text-green-700'
|
|
||||||
else
|
|
||||||
'text-slate-300'
|
|
||||||
end %>
|
|
||||||
<i class="fa fa-hourglass-end <%= reviewed_icon_class %>"></i>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<template data-popover-target="content">
|
|
||||||
<% unless lecture.tracked_time_entries.empty? %>
|
|
||||||
<div class="absolute p-1 w-max whitespace-normal break-words rounded-lg border border-blue-gray-50 bg-white text-blue-gray-500 shadow-lg shadow-blue-gray-500/10 focus:outline-none" data-popover-target="card">
|
|
||||||
<div>
|
|
||||||
Preparation: <%= humanise_duration(lecture.total_preparation_time) %>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
In lecture: <%= humanise_duration(lecture.total_attendance_time) %>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
Review: <%= humanise_duration(lecture.total_review_time) %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
</template>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
|
||||||
<% 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 %>
|
|
||||||
<div class="flex justify-center">
|
|
||||||
<%= button_to "Review",
|
|
||||||
lecture_start_review_path(id: lecture.id),
|
|
||||||
class: 'action-button'
|
|
||||||
%>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
|
||||||
<% if lecture.recording %>
|
|
||||||
<%= link_to "Open recording", lecture.recording&.recording_url %>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
<% end %>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
90
app/views/lectures/_lecture.html.erb
Normal file
90
app/views/lectures/_lecture.html.erb
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
<tr class="<%= class_names({
|
||||||
|
'lecture-future': lecture.start_time.future?,
|
||||||
|
'bg-green-100': lecture.attended?,
|
||||||
|
}) %>">
|
||||||
|
<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.cancelled %>
|
||||||
|
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" colspan="3">
|
||||||
|
<div class="flex justify-center">
|
||||||
|
Cancelled
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<% else %>
|
||||||
|
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" data-controller="popover" data-action="mouseenter->popover#show mouseleave->popover#hide">
|
||||||
|
<div class="flex flex-row gap-2">
|
||||||
|
<% prep_icon_class = if lecture.prepared?
|
||||||
|
'text-green-700'
|
||||||
|
else
|
||||||
|
'text-slate-300'
|
||||||
|
end %>
|
||||||
|
<i class="fa fa-hourglass-start <%= prep_icon_class %>"></i>
|
||||||
|
|
||||||
|
<% if lecture.attended? %>
|
||||||
|
<i class="fa fa-chalkboard-user text-green-700"></i>
|
||||||
|
<% elsif lecture.start_time.past? %>
|
||||||
|
<i class="fa fa-times text-red-700"></i>
|
||||||
|
<% else %>
|
||||||
|
<div class="flex-grow"></div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% reviewed_icon_class = if lecture.start_time.future?
|
||||||
|
'invisible'
|
||||||
|
elsif lecture.reviewed?
|
||||||
|
'text-green-700'
|
||||||
|
else
|
||||||
|
'text-slate-300'
|
||||||
|
end %>
|
||||||
|
<i class="fa fa-hourglass-end <%= reviewed_icon_class %>"></i>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template data-popover-target="content">
|
||||||
|
<% unless lecture.tracked_time_entries.empty? %>
|
||||||
|
<div class="absolute p-1 w-max whitespace-normal break-words rounded-lg border border-blue-gray-50 bg-white text-blue-gray-500 shadow-lg shadow-blue-gray-500/10 focus:outline-none" data-popover-target="card">
|
||||||
|
<div>
|
||||||
|
Preparation: <%= humanise_duration(lecture.total_preparation_time) %>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
In lecture: <%= humanise_duration(lecture.total_attendance_time) %>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
Review: <%= humanise_duration(lecture.total_review_time) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</template>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
||||||
|
<% 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 %>
|
||||||
|
<div class="flex justify-center">
|
||||||
|
<%= button_to "Review",
|
||||||
|
lecture_start_review_path(id: lecture.id),
|
||||||
|
class: 'action-button'
|
||||||
|
%>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
||||||
|
<% if lecture.recording %>
|
||||||
|
<%= link_to "Open recording", lecture.recording&.recording_url %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
Loading…
Reference in New Issue
Block a user