lecture-attendance-manager/app/controllers/lecture_controller.rb
Joshua Coles 4b3204d2f4
All checks were successful
Build and Publish Docker Container / build (push) Successful in 5m29s
Implement catch-up tracking feature
This update enhances tracking functionality. It adds the ability to track time spent 'catching up' on lectures, with distinctions made within the controllers and views to handle these new 'catch-up' entries. Also implemented a flexible match for lecture titles to include various forms such as 'Lecture 1', 'Lecture 1: Prep' and the 'Catch-up'.
2024-02-07 10:46:47 +00:00

56 lines
1.3 KiB
Ruby

class LectureController < ApplicationController
# TODO: Pass the CSRF token to Pushcut
skip_before_action :verify_authenticity_token, only: [:checkin]
def checkin
lecture = Lecture.find(params[:id])
Toggl::start_time_entry(
description: lecture.title,
project_id: lecture.course.toggl_project,
)
end
def start
lecture = Lecture.find(params[:id])
catch_up = params[:catch_up].present?
description = if catch_up
"#{lecture.title}: Catch-up"
else
lecture.title
end
Toggl::start_time_entry(
description:,
project_id: lecture.course.toggl_project,
)
if lecture.is_live?
redirect_to lecture.live_video_url, allow_other_host: true
end
if lecture.recording.present?
redirect_to lecture.recording.recording_url, allow_other_host: true
end
end
def start_preparation
lecture = Lecture.find(params[:id])
Toggl::start_time_entry(
description: "#{lecture.title}: Prep",
project_id: lecture.course.toggl_project,
)
end
def start_review
lecture = Lecture.find(params[:id])
Toggl::start_time_entry(
description: "#{lecture.title}: Review",
project_id: lecture.course.toggl_project,
)
end
end