From a19cc42d694f9b0d594c73b1a5f2b1279ff439ec Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 31 Oct 2023 11:49:20 +0000 Subject: [PATCH] ergebnisformular fast fertig --- web/models/Result.model.php | 3 ++- web/pages/runs/controller.php | 12 ++++++++++- web/pages/runs/edit_result.html | 37 +++++++++++++++++++-------------- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/web/models/Result.model.php b/web/models/Result.model.php index e0ba892..1aab238 100644 --- a/web/models/Result.model.php +++ b/web/models/Result.model.php @@ -8,7 +8,7 @@ class Result extends Model 'run' => ['type' => 'text', 'required'], //run ID 'user' => ['type' => 'text', 'required'], //user ID - 'disqualified' => ['type' => 'bool'], + 'disqualified' => ['type' => 'bool','default'=>0], 'refusals' => ['type' => 'int','default'=>0], 'errors' => ['type' => 'int','default'=>0], 'timefaults' => ['type' => 'int','default'=>0], @@ -21,6 +21,7 @@ class Result extends Model 'photos' => ['type' => 'array','default'=>[]], 'videos' => ['type' => 'array','default'=>[]], 'memo' => ['type' => 'text'], + 'public' => ['type' => 'bool','default'=>1], ); diff --git a/web/pages/runs/controller.php b/web/pages/runs/controller.php index e36dfe1..be44b17 100644 --- a/web/pages/runs/controller.php +++ b/web/pages/runs/controller.php @@ -59,11 +59,21 @@ class Runs extends Page { $t = new Tournament(); $tid = $run->data['tournament']; $t->load($tid); + $res = new Result(); + if($_REQUEST['result_id']) + { + if(!$res->exists($_REQUEST['result_id'])) + return partial('error.html', ['errorMessage' => 'Dieses Ergebnis existiert nicht']); + $res->load($_REQUEST['result_id']); + if(!$res->data['run']==$rid) + return partial('error.html', ['errorMessage' => 'Dieses Ergebnis gehört nicht zu diesem Lauf']); + } + else + $res->id = gen_ulid(); if(!$t->amIAdmin() && !$t->isMyEvent($tid)) return partial('error.html', ['errorMessage' => 'Du bist in diesem Turnier nicht angemeldet']); else { - $run->data['results'] = []; $run->data['results']['time'] = $_REQUEST['time']; $run->data['results']['penalty'] = $_REQUEST['penalty']; $run->data['results']['disq'] = $_REQUEST['disq']; diff --git a/web/pages/runs/edit_result.html b/web/pages/runs/edit_result.html index b8a61e0..509dc9b 100644 --- a/web/pages/runs/edit_result.html +++ b/web/pages/runs/edit_result.html @@ -7,7 +7,7 @@