Show offline contestants in dashboard
Some checks failed
CI / scan_ruby (push) Failing after 18s
CI / scan_js (push) Successful in 13s
CI / lint (push) Successful in 17s
CI / test (push) Failing after 53s

This commit is contained in:
sto
2025-11-05 17:18:47 +01:00
parent d62b46b7df
commit 5348574ea4
11 changed files with 73 additions and 36 deletions

View File

@@ -1,4 +1,6 @@
class ContestsController < ApplicationController
include CompletionsConcern
before_action :set_contest, only: %i[ destroy edit show update ]
before_action :offline_setup, only: %i[ offline_new offline_create offline_edit offline_update offline_completed ]
skip_before_action :require_authentication, only: %i[ scoreboard offline_new offline_create offline_edit offline_update offline_completed ]
@@ -139,8 +141,18 @@ class ContestsController < ApplicationController
end
@offline.completed = true
@offline.end_time = Time.now()
@offline.images.attach(params[:offline][:end_image])
if @offline.save
if @contest.puzzles.length > 0
dp = display_time(@offline.end_time.to_i - @offline.start_time.to_i)
contestant = Contestant.create(contest: @contest, name: @offline.name, offline: @offline)
Completion.create(contest: @contest,
contestant: contestant,
puzzle: @contest.puzzles[0],
display_time_from_start: dp)
extend_completions!(contestant)
end
redirect_to "/public/#{@contest.friendly_id}/offline/#{@offline.generate_token_for(:token)}/completed"
else
render :offline_edit, status: :unprocessable_entity