Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/models/marking_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ def duration_minutes

def update_session_details
now = DateTime.now
update(end_time: now)
if start_time.present?
duration = ((now.to_f - start_time.to_f) / 60).to_i
update(
end_time: now,
duration_minutes: duration
)
else
update(end_time: now, duration_minutes: 0)
end
end
end
4 changes: 2 additions & 2 deletions app/services/session_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ def self.record_assessment_activity(action:, user:, project:, ip_address:, task:
project_id: project.id,
task_id: task&.id,
task_definition_id: task&.task_definition_id,
created_at: Time.zone.now
created_at: DateTime.now
)

session.update_session_details
session.update_session_details if action == 'assessing'

activity
end
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20250922103033_create_marking_sessions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def change
t.string :ip_address
t.datetime :start_time
t.datetime :end_time
t.integer :duration_minutes, default: 0
t.boolean :during_tutorial

t.timestamps
Expand Down
1 change: 1 addition & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
t.string "ip_address"
t.datetime "start_time"
t.datetime "end_time"
t.integer "duration_minutes", default: 0
t.boolean "during_tutorial"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
Expand Down
Loading