In the attendance tracker view, the total times for preparation, in lecture, and review have been humanized for better readability. Also, total time spent on lectures for each week has been included for a quicker overview. A helper method 'humanise_duration' has been added in application helper to convert time into a more readable format. Changes have been done in 'lecture' model for calculation of total time.
20 lines
465 B
Ruby
20 lines
465 B
Ruby
module ApplicationHelper
|
|
def humanise_duration(duration)
|
|
raise ArgumentError, "Duration must be a number" unless duration.is_a? ActiveSupport::Duration
|
|
|
|
seconds = duration.in_seconds
|
|
minutes = seconds / 60
|
|
hours = minutes / 60
|
|
|
|
remaining_minutes = minutes % 60
|
|
|
|
if hours > 0
|
|
"#{hours.floor}h #{remaining_minutes.floor}m"
|
|
elsif minutes > 0
|
|
"#{remaining_minutes.floor} minutes"
|
|
else
|
|
"#{seconds}s"
|
|
end
|
|
end
|
|
end
|