fast kann man schon ergebnisse eintragne
All checks were successful
Build and push / Pulling repo on server (push) Successful in 2s

This commit is contained in:
Chris 2023-10-31 11:26:54 +01:00
parent 9b6e3080c2
commit d96dc2fae3
5 changed files with 166 additions and 31 deletions

View File

@ -0,0 +1,27 @@
<?php
class Result extends Model
{
protected $dbTable = "result";
protected $dbFields = array(
'tournament' => ['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'],
);
}

View File

@ -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']);
}

View File

@ -1,58 +1,81 @@
<h2>Ergebnis <?= $run_id?'Bearbeiten':'Eintragen'; ?></h2>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="/tournaments/event/<?= $tournament_id; ?>" hx-push-url="/tournaments/event/<?= $tournament_id; ?>" hx-get="/tournaments/event/<?= $tournament_id; ?>" hx-target="#main">
<?= escape($tournament['name']); ?>
</a>
</li>
<li class="breadcrumb-item">
<a href="/runs/overview/<?= $run_id; ?>" hx-push-url="/runs/overview/<?= $run_id; ?>" hx-get="/runs/overview/<?= $run_id; ?>" hx-target="#main">
<?= escape($run['name']); ?>
</a>
</li>
<li class="breadcrumb-item active" aria-current="page">
<?= $result_id?'Bearbeiten':'Eintragen'; ?>
</li>
</ol>
</nav>
<h2>Ergebnis
<?= $result_id?'Bearbeiten':'Eintragen'; ?>
</h2>
<form>
<input type="hidden" name="run_id" value="<?= $run_id; ?>">
<div>
<label for="eliminated" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Disqualifiziert</label>
<input type="number" value="<?= $run['eliminated']; ?>" id="eliminated" name="eliminated" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Flowbite">
<input type="number" value="<?= $result['eliminated']; ?>" id="eliminated" name="eliminated" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Flowbite">
</div>
<div>
<label for="refusals" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Verweigerungen</label>
<input type="number" value="<?= $run['refusals']; ?>" id="refusals" name="refusals" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Flowbite">
<label for="refusals" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Verweigeresultgen</label>
<input type="number" value="<?= $result['refusals']; ?>" id="refusals" name="refusals" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Flowbite">
</div>
<div>
<label for="faults" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Fehler</label>
<input type="number" value="<?= $run['faults']; ?>" id="faults" name="faults" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Flowbite">
<input type="number" value="<?= $result['faults']; ?>" id="faults" name="faults" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Flowbite">
</div>
<div>
<label for="time_faults" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Zeitfehler</label>
<input type="number" value="<?= $run['time_faults']; ?>" id="time_faults" name="time_faults" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Flowbite">
<input type="number" value="<?= $result['time_faults']; ?>" id="time_faults" name="time_faults" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Flowbite">
</div>
<div>
<label for="time" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Zeit</label>
<input type="number" value="<?= $run['time']; ?>" id="time" name="time" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Flowbite">
<input type="number" value="<?= $result['time']; ?>" id="time" name="time" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Flowbite">
</div>
<div>
<label for="penalties" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Gesamtfehler</label>
<input type="number" value="<?= $run['penalties']; ?>" id="penalties" name="penalties" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Flowbite">
<input type="number" value="<?= $result['penalties']; ?>" id="penalties" name="penalties" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Flowbite">
</div>
<div>
<label for="time_speed" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">m/Sek</label>
<input type="number" value="<?= $run['time_speed']; ?>" id="time_speed" name="time_speed" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Flowbite">
<input type="number" value="<?= $result['time_speed']; ?>" id="time_speed" name="time_speed" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Flowbite">
</div>
<div>
<label for="bewertung" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Bewertung</label>
<select id="bewertung" name="bewertung" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
<option value="V" <?= $rundata['bewertung']=='V'?'selected':''; ?>>V</option>
<option value="SG" <?= $rundata['bewertung']=='SG'?'selected':''; ?>>SG</option>
<option value="G" <?= $rundata['bewertung']=='G'?'selected':''; ?>>G</option>
<option Galue="B" <?= $rundata['bewertung']=='B'?'selected':''; ?>>B</option>
</select>
<label for="bewertung" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Bewertung</label>
<select id="bewertung" name="bewertung" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
<option value="V" <?=$result['bewertung']=='V' ?'selected':''; ?>>V</option>
<option value="SG" <?=$result['bewertung']=='SG' ?'selected':''; ?>>SG</option>
<option value="G" <?=$result['bewertung']=='G' ?'selected':''; ?>>G</option>
<option Galue="B" <?=$result['bewertung']=='B' ?'selected':''; ?>>B</option>
</select>
</div>
<div>
<label for="points" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Punkte</label>
<input type="number" value="<?= $run['points']; ?>" id="points" name="points" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Flowbite">
<input type="number" value="<?= $result['points']; ?>" id="points" name="points" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Flowbite">
</div>
<div>
<label for="rank" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Platz</label>
<input type="number" value="<?= $run['rank']; ?>" id="rank" name="rank" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Flowbite">
<input type="number" value="<?= $result['rank']; ?>" id="rank" name="rank" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Flowbite">
</div>
<div>
<label for="uploads" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Uploads</label>
<input type="file" accept="image/png, image/jpeg, image/gif" id="uploads" name="uploads">
<label for="uploads" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Uploads</label>
<input type="file" accept="image/png, image/jpeg, image/gif" id="uploads" name="uploads">
</div>
<div>
<label for="video-url" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Video Url</label>
<input type="text" value="<?= $run['video-url']; ?>" class="form-control" id="video-url" aria-describedby="basic-addon3">
<label for="video-url" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Video Url</label>
<input type="text" value="<?= $result['video-url']; ?>" class="form-control" id="video-url" aria-describedby="basic-addon3">
</div>
<div>
<label for="memo" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Memo</label>
<textarea value="<?= $run['memo']; ?>" id="memo" name="memo" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Deine Gedankengänge"></textarea>
</div>
<label for="memo" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Memo</label>
<textarea value="<?= $result['memo']; ?>" id="memo" name="memo" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Deine Gedankengänge"></textarea>
</div>
<button type="submit" name="submit" value="true" class="btn btn-primary">Speichern</button>
</form>

View File

@ -34,7 +34,8 @@
<label for="referee">Richter</label>
<input type="text" value="<?= $run['referee']; ?>" id="referee" name="referee" placeholder="Franz Ferdinand" class="form-control">
</div>
<button type="submit" name="submit" value="true" class="btn btn-primary">Submit</button> <!-- Submit Button führt auf eine neue Seite wo man die Laufinfo eingibt -->
<button type="submit" name="submit" value="true" class="btn btn-primary">Speichern</button>
<button type="submit" name="submit" value="forward" class="btn btn-primary">Speichern und Ergebnisse eintragen</button>
</form>
<progress id='progress' value='0' max='100'></progress>
<div id="response"></div>

View File

@ -33,12 +33,45 @@
</div>
</div>
</div>
<div class="col-6" id="sitemain">
<div class="col" id="sitemain">
<div class="card p-2">
<h4>Ergebnisse</h4>
<p class="card-text">
</p>
<button hx-get="/runs/addresults/<?= $run_id; ?>" hx-push-url="/runs/addresults/<?= $run_id; ?>" hx-target="#main" class="btn btn-primary"><i class="fas fa-plus-circle"></i> Ergebnis Eintragen</button>
</p>
<table class="table">
<thead>
<tr>
<th>Platz</th>
<th>Disqualifiziert</th>
<th>Verweigerungen</th>
<th>Fehler</th>
<th>Zeitfehler</th>
<th>Zeit</th>
<th>Gesamtfehler</th>
<th>m/Sek</th>
<th>Bewertung</th>
<th>Teilnehmer</th>
</tr>
</thead>
<tbody>
<?php foreach($results as $result) : ?>
<tr>
<td><?= escape($result['place']); ?></td>
<td><?= escape($result['eliminated']); ?></td>
<td><?= escape($result['refusals']); ?></td>
<td><?= escape($result['faults']); ?></td>
<td><?= escape($result['time_faults']); ?></td>
<td><?= escape($result['time']); ?></td>
<td><?= escape($result['penalties']); ?></td>
<td><?= escape($result['time_speed']); ?></td>
<td><?= escape($result['bewertung']); ?></td>
<td><?= escape($result['member']); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</div>
</div>