diff --git a/app/Http/Controllers/RegistrationController.php b/app/Http/Controllers/RegistrationController.php
index b7d5a38..8e486a4 100644
--- a/app/Http/Controllers/RegistrationController.php
+++ b/app/Http/Controllers/RegistrationController.php
@@ -310,6 +310,42 @@ class RegistrationController extends Controller
]);
}
+ public function correctShot(Request $request)
+ {
+ $request->validate([
+ 'session_id' => 'required|exists:game_sessions,id',
+ 'shot_number' => 'required|integer|in:1,2,3',
+ 'result' => 'required|boolean',
+ ]);
+
+ $session = GameSession::with('registration')->findOrFail($request->session_id);
+
+ $shot = $session->shots()->where('shot_number', $request->shot_number)->first();
+
+ if ($shot) {
+ $shot->update(['result' => $request->result]);
+ } else {
+ GameShot::create([
+ 'game_session_id' => $session->id,
+ 'shot_number' => $request->shot_number,
+ 'result' => $request->result,
+ ]);
+ }
+
+ $sessionScore = $session->calculateScore();
+ $session->update(['score' => $sessionScore]);
+
+ $registration = $session->registration;
+ $registration->update([
+ 'total_score' => $registration->sessions()->sum('score')
+ ]);
+
+ return response()->json([
+ 'status' => 'ok',
+ 'total_score' => $registration->fresh()->total_score,
+ ]);
+ }
+
//Leaderboard
public function leaderboard()
{
diff --git a/resources/views/dashboard/admin.blade.php b/resources/views/dashboard/admin.blade.php
index f8e7a7b..bcdd261 100644
--- a/resources/views/dashboard/admin.blade.php
+++ b/resources/views/dashboard/admin.blade.php
@@ -7,7 +7,7 @@
{{ $total }}
-
Total Registrations
+
Total Students
@@ -95,7 +95,7 @@
- Today's Sessions
+ All Registrations
{{ $total }} students
@@ -106,7 +106,6 @@
Name |
Phone |
Email |
- Country |
Today's Shots |
Total Score |
Actions |
@@ -134,19 +133,6 @@
{{ $reg['phone'] }} |
{{ $reg['email'] }} |
-
-
- |
@if(is_null($reg['today_goals']))
@@ -280,6 +266,7 @@
|