diff --git a/app/controllers/lecture_controller.rb b/app/controllers/lecture_controller.rb index 45ad7cf..84a0b45 100644 --- a/app/controllers/lecture_controller.rb +++ b/app/controllers/lecture_controller.rb @@ -11,4 +11,22 @@ class LectureController < ApplicationController 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 diff --git a/app/lib/toggl.rb b/app/lib/toggl.rb index 7f43956..6c0aabe 100644 --- a/app/lib/toggl.rb +++ b/app/lib/toggl.rb @@ -17,6 +17,7 @@ module Toggl body: { "created_with": "Attendance Tracker", "description": description, + "start": Time.now.utc.iso8601, "duration": -1, "project_id": project_id, }.to_json, diff --git a/app/views/attendance_tracker/index.html.erb b/app/views/attendance_tracker/index.html.erb index 024d4a3..fe3c1bf 100644 --- a/app/views/attendance_tracker/index.html.erb +++ b/app/views/attendance_tracker/index.html.erb @@ -48,6 +48,12 @@ +
+ <%= button_to "Prepare", + lecture_start_preparation_path(id: lecture.id), + class: 'action-button' + %> +
<% else %> @@ -71,6 +77,13 @@ class: 'action-button' %> <% else %> +
+ <%= button_to "Review", + lecture_start_review_path(id: lecture.id), + class: 'action-button' + %> +
+ <% if lecture.recording %> <%= link_to "Open recording", lecture.recording&.recording_url %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index bd11a95..f40dfe5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,4 +11,6 @@ Rails.application.routes.draw do root controller: :attendance_tracker, action: :index post '/lectures/:id/start', to: 'lecture#start', as: :lectures_start + post '/lectures/:id/start_preparation', to: 'lecture#start_preparation', as: :lecture_start_preparation + post '/lectures/:id/start_review', to: 'lecture#start_review', as: :lecture_start_review end