diff --git a/web/models/Result.model.php b/web/models/Result.model.php new file mode 100644 index 0000000..e0ba892 --- /dev/null +++ b/web/models/Result.model.php @@ -0,0 +1,27 @@ + ['type' => 'text', 'required'], //tournament ID + 'run' => ['type' => 'text', 'required'], //run ID + 'user' => ['type' => 'text', 'required'], //user ID + + 'disqualified' => ['type' => 'bool'], + 'refusals' => ['type' => 'int','default'=>0], + 'errors' => ['type' => 'int','default'=>0], + 'timefaults' => ['type' => 'int','default'=>0], + 'runtime' => ['type' => 'int','default'=>0], + 'penalties' => ['type' => 'int','default'=>0], + 'rating' => ['type' => 'text'], + 'points' => ['type' => 'int','default'=>0], + 'speed' => ['type' => 'int','default'=>0], //in m/sec + 'ranking' => ['type' => 'int','default'=>0], + 'photos' => ['type' => 'array','default'=>[]], + 'videos' => ['type' => 'array','default'=>[]], + 'memo' => ['type' => 'text'], + + ); + +} diff --git a/web/pages/runs/controller.php b/web/pages/runs/controller.php index 6290c71..e36dfe1 100644 --- a/web/pages/runs/controller.php +++ b/web/pages/runs/controller.php @@ -27,6 +27,52 @@ class Runs extends Page { $this->set('template', 'run.html'); } + function addresults() + { + $rid = $this->params[0]; + $run = new Run(); + if(!$run->exists($rid)) + return partial('error.html', ['errorMessage' => 'Dieser Lauf existiert nicht']); + $run->load($rid); + $t = new Tournament(); + $tid = $run->data['tournament']; + $t->load($tid); + if(!$t->amIAdmin() && !$t->isMyEvent($tid)) + return partial('error.html', ['errorMessage' => 'Du bist in diesem Turnier nicht angemeldet']); + else + { + $this->set('tournament', $t->data); + $this->set('tournament_id', $tid); + $this->set('run', $run->data); + $this->set('run_id', $rid); + $this->set('template', 'edit_result.html'); + } + } + + function validateResults() + { + $rid = $_REQUEST['run_id']; + $run = new Run(); + if(!$run->exists($rid)) + return partial('error.html', ['errorMessage' => 'Dieser Lauf existiert nicht']); + $run->load($rid); + $t = new Tournament(); + $tid = $run->data['tournament']; + $t->load($tid); + 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']; + $run->data['results']['comment'] = $_REQUEST['comment']; + $run->data['results']['referee'] = $_REQUEST['referee']; + $run->data['results']['judge'] = $_REQUEST['judge']; + } + } + function add() { $tournament = $this->params[0]; @@ -69,7 +115,7 @@ class Runs extends Page { function validate() { - if($_REQUEST['submit']=='true') + if($_REQUEST['submit']) { $t = new Tournament(); @@ -116,7 +162,12 @@ class Runs extends Page { $t->save(); } - $this->redirect('/tournaments/event/'.$t->id); + if($_REQUEST['submit']=='forward') + { + $this->redirect('/runs/addresults/'.$runid); + } + else + $this->redirect('/tournaments/event/'.$t->id); } else return partial('error.html', ['errorMessage' => 'Fehler beim Speichern des Laufs']); } diff --git a/web/pages/runs/edit_result.html b/web/pages/runs/edit_result.html index c732183..b8a61e0 100644 --- a/web/pages/runs/edit_result.html +++ b/web/pages/runs/edit_result.html @@ -1,58 +1,81 @@ -
- -
+ + + + +Platz | +Disqualifiziert | +Verweigerungen | +Fehler | +Zeitfehler | +Zeit | +Gesamtfehler | +m/Sek | +Bewertung | +Teilnehmer | +
---|---|---|---|---|---|---|---|---|---|
= escape($result['place']); ?> | += escape($result['eliminated']); ?> | += escape($result['refusals']); ?> | += escape($result['faults']); ?> | += escape($result['time_faults']); ?> | += escape($result['time']); ?> | += escape($result['penalties']); ?> | += escape($result['time_speed']); ?> | += escape($result['bewertung']); ?> | += escape($result['member']); ?> | +