Break game details page into partials, improve semantics
This commit is contained in:
parent
b2813881b7
commit
101ad2a54f
8 changed files with 206 additions and 184 deletions
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
require_once __DIR__ . "/Enums/SubmissionStatus.php";
|
||||
|
||||
session_set_cookie_params([
|
||||
"lifetime" => 0,
|
||||
"path" => "/",
|
||||
|
|
|
|||
|
|
@ -24,8 +24,15 @@ $assignments->params["round"] = 3;
|
|||
$stmt_assignments->execute($assignments->params);
|
||||
$assignments->round_3 = $stmt_assignments->fetchAll(PDO::FETCH_OBJ);
|
||||
?>
|
||||
<section class="flow">
|
||||
<h2>Your Assignments</h2>
|
||||
<section class="flow" aria-labelledby="assignments">
|
||||
<h2 id="assignments">Your Assignments</h2>
|
||||
<?php if (in_array($game->status_id, [
|
||||
STATUS_ENROLLING,
|
||||
STATUS_REVIEW,
|
||||
])) { ?>
|
||||
<p>The manuscripts to which you've been assigned to provide feedback will appear here.</p>
|
||||
<?php } ?>
|
||||
<?php if ($assignments->round_1): ?>
|
||||
<div role="region" aria-labelledby="round-1-assignments-caption" tabindex="0">
|
||||
<table>
|
||||
<caption id="round-1-assignments-caption">Round One Assignments for <?= $game->name ?></caption>
|
||||
|
|
@ -39,12 +46,14 @@ $assignments->round_3 = $stmt_assignments->fetchAll(PDO::FETCH_OBJ);
|
|||
<?php foreach ($assignments->round_1 as $item): ?>
|
||||
<tr>
|
||||
<th scope="row"><a href="/docs/<?= $item->hash ?>"><?= $item->title ?></a></th>
|
||||
<td><?= $item->score ?? 'N/A' ?></td>
|
||||
<td><?= $item->score ?? "N/A" ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($assignments->round_2): ?>
|
||||
<div role="region" aria-labelledby="round-2-assignments-caption" tabindex="0">
|
||||
<table>
|
||||
<caption id="round-2-assignments-caption">Round Two Assignments for <?= $game->name ?></caption>
|
||||
|
|
@ -58,12 +67,14 @@ $assignments->round_3 = $stmt_assignments->fetchAll(PDO::FETCH_OBJ);
|
|||
<?php foreach ($assignments->round_2 as $item): ?>
|
||||
<tr>
|
||||
<th scope="row"><a href="/docs/<?= $item->hash ?>"><?= $item->title ?></a></th>
|
||||
<td><?= $item->score ?? 'N/A' ?></td>
|
||||
<td><?= $item->score ?? "N/A" ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($assignments->round_3): ?>
|
||||
<div role="region" aria-labelledby="round-3-assignments-caption" tabindex="0">
|
||||
<table>
|
||||
<caption id="round-3-assignments-caption">Round Three Assignments for <?= $game->name ?></caption>
|
||||
|
|
@ -77,10 +88,11 @@ $assignments->round_3 = $stmt_assignments->fetchAll(PDO::FETCH_OBJ);
|
|||
<?php foreach ($assignments->round_3 as $item): ?>
|
||||
<tr>
|
||||
<th scope="row"><a href="/docs/<?= $item->hash ?>"><?= $item->title ?></a></th>
|
||||
<td><?= $item->score ?? 'N/A' ?></td>
|
||||
<td><?= $item->score ?? "N/A" ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
|
|
|
|||
94
lib/partials/contest-schedule.php
Normal file
94
lib/partials/contest-schedule.php
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
<section aria-labelledby="schedule">
|
||||
<h2 id="schedule">Schedule</h2>
|
||||
<?php $dates = [
|
||||
"submitstart" => DateTimeImmutable::createFromFormat(
|
||||
"U",
|
||||
$game->submitstart
|
||||
)->setTimezone($time_zone),
|
||||
"submitend" => DateTimeImmutable::createFromFormat(
|
||||
"U",
|
||||
$game->submitend
|
||||
)->setTimezone($time_zone),
|
||||
"onestart" => DateTimeImmutable::createFromFormat(
|
||||
"U",
|
||||
$game->onestart
|
||||
)->setTimezone($time_zone),
|
||||
"twostart" => DateTimeImmutable::createFromFormat(
|
||||
"U",
|
||||
$game->twostart
|
||||
)->setTimezone($time_zone),
|
||||
"threestart" => DateTimeImmutable::createFromFormat(
|
||||
"U",
|
||||
$game->threestart
|
||||
)->setTimezone($time_zone),
|
||||
"gameend" => DateTimeImmutable::createFromFormat(
|
||||
"U",
|
||||
$game->gameend
|
||||
)->setTimezone($time_zone),
|
||||
]; ?>
|
||||
<dl class="flow" data-game-status="<?= $game->status_id ?>">
|
||||
<div data-status="<?= STATUS_ENROLLING ?>">
|
||||
<dt>Submissions</dt>
|
||||
<dd><span>Open: </span><time datetime="<?= $dates["submitstart"]->format(
|
||||
"c"
|
||||
) ?>"><?= $dates["submitstart"]->format(
|
||||
'l, j F, o \a\t h:i A T'
|
||||
) ?></time></dd>
|
||||
<dd><span>Close: </span><time datetime="<?= $dates["submitend"]->format(
|
||||
"c"
|
||||
) ?>"><?= $dates["submitend"]->format(
|
||||
'l, j F, o \a\t h:i A T'
|
||||
) ?></time></dd>
|
||||
</div>
|
||||
<div data-status="<?= STATUS_REVIEW ?>">
|
||||
<dt>Document Review</dt>
|
||||
<dd><span>Start: </span><time datetime="<?= $dates["submitend"]
|
||||
->add($one_second)
|
||||
->format("c") ?>"><?= $dates["submitend"]
|
||||
->add($one_second)
|
||||
->format('l, j F, o \a\t h:i A T') ?></time></dd>
|
||||
<dd><span>End: </span><time datetime="<?= $dates["onestart"]
|
||||
->sub($one_second)
|
||||
->format("c") ?>"><?= $dates["onestart"]
|
||||
->sub($one_second)
|
||||
->format('l, j F, o \a\t h:i A T') ?></time></dd>
|
||||
</div>
|
||||
<div data-status="<?= STATUS_ROUND_ONE ?>">
|
||||
<dt>Round One</dt>
|
||||
<dd><span>Start: </span><time datetime="<?= $dates["onestart"]->format(
|
||||
"c"
|
||||
) ?>"><?= $dates["onestart"]->format(
|
||||
'l, j F, o \a\t h:i A T'
|
||||
) ?></time></dd>
|
||||
<dd><span>End: </span><time datetime="<?= $dates["twostart"]
|
||||
->sub($one_second)
|
||||
->format("c") ?>"><?= $dates["twostart"]
|
||||
->sub($one_second)
|
||||
->format('l, j F, o \a\t h:i A T') ?></time></dd>
|
||||
</div>
|
||||
<div data-status="<?= STATUS_ROUND_TWO ?>">
|
||||
<dt>Round Two</dt>
|
||||
<dd><span>Start: </span><time datetime="<?= $dates["twostart"]->format(
|
||||
"c"
|
||||
) ?>"><?= $dates["twostart"]->format(
|
||||
'l, j F, o \a\t h:i A T'
|
||||
) ?></time></dd>
|
||||
<dd><span>End: </span><time datetime="<?= $dates["threestart"]
|
||||
->sub($one_second)
|
||||
->format("c") ?>"><?= $dates["threestart"]
|
||||
->sub($one_second)
|
||||
->format('l, j F, o \a\t h:i A T') ?></time></dd>
|
||||
</div>
|
||||
<div data-status="<?= STATUS_ROUND_THREE ?>">
|
||||
<dt>Round Three</dt>
|
||||
<dd><span>Start: </span><time datetime="<?= $dates["threestart"]->format(
|
||||
"c"
|
||||
) ?>"><?= $dates["threestart"]->format(
|
||||
'l, j F, o \a\t h:i A T'
|
||||
) ?></time></dd>
|
||||
<dd><span>End: </span><time datetime="<?= $dates["gameend"]->format(
|
||||
"c"
|
||||
) ?>"><?= $dates["gameend"]->format('l, j F, o \a\t h:i A T') ?></time></dd>
|
||||
</div>
|
||||
</dl>
|
||||
</section>
|
||||
|
|
@ -7,8 +7,9 @@ $stmt_fdbck->execute([
|
|||
]);
|
||||
$feedback = $stmt_fdbck->fetchAll(PDO::FETCH_OBJ);
|
||||
?>
|
||||
<div>
|
||||
<h3>Feedback</h3>
|
||||
<section aria-labelledby="feedback" class="flow">
|
||||
<h3 id="feedback">Feedback</h3>
|
||||
<?php if ($feedback): ?>
|
||||
<div role="region" aria-labelledby="feedback-caption" tabindex="0">
|
||||
<table>
|
||||
<caption id="feedback-caption">Feedback for "<?= $submission->title ?>"</caption>
|
||||
|
|
@ -28,4 +29,7 @@ $feedback = $stmt_fdbck->fetchAll(PDO::FETCH_OBJ);
|
|||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<p>The feedback you receive from other writers will appear here.</p>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
|
|
|
|||
37
lib/partials/submission-details.php
Normal file
37
lib/partials/submission-details.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php use Enums\SubmissionStatus; ?>
|
||||
|
||||
<div role="region" aria-labelledby="details-caption" tabindex="0">
|
||||
<table>
|
||||
<caption id="details-caption">Submission Details</caption>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row" colspan="2">ID</th>
|
||||
<td><?= $submission->id ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" colspan="2">Title</th>
|
||||
<td><a href="/docs/<?= $submission->hash ?>"><?= $submission->title ?></a></td>
|
||||
</tr>
|
||||
<?php if ($game->status_id === STATUS_REVIEW) { ?>
|
||||
<tr>
|
||||
<th scope="row" colspan="2">Review Status</th>
|
||||
<td><?= SubmissionStatus::tryFrom($submission->status)->name ??
|
||||
"N/A" ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<th scope="row" rowspan="3">Rankings</th>
|
||||
<th scope="row">Round One</th>
|
||||
<td><?= $submission->rank_round_1 ?? "N/A" ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Round Two</th>
|
||||
<td><?= $submission->rank_round_2 ?? "N/A" ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Round Three</th>
|
||||
<td><?= $submission->rank_round_3 ?? "N/A" ?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
$stmt_fdbck = $db["data"]->prepare(
|
||||
"SELECT round_number, score, comment FROM assignments WHERE completed IS NOT NULL AND submission_id = :submission_id"
|
||||
);
|
||||
$stmt_fdbck->execute([
|
||||
"submission_id" => $submission->id,
|
||||
]);
|
||||
$feedback = $stmt_fdbck->fetchAll(PDO::FETCH_OBJ);
|
||||
?>
|
||||
<div role="region" aria-labelledby="details-caption" tabindex="0">
|
||||
<table>
|
||||
<caption id="details-caption">Submission details</caption>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">Title</th>
|
||||
<td><a href="/docs/<?= $submission->hash ?>"><?= $submission->title ?></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" rowspan="3">Ranking</th>
|
||||
<th scope="row">Round One</th>
|
||||
<td><?= $submission->rank_round_1 ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Round Two</th>
|
||||
<td><?= $submission->rank_round_2 ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Round Three</th>
|
||||
<td><?= $submission->rank_round_3 ?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
header {
|
||||
main > header {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
|
@ -93,3 +93,7 @@ form mark {
|
|||
border-radius: 0.5em;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.single-game ul {
|
||||
padding: 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
|
||||
$title = "Games";
|
||||
$description = "View previous games.";
|
||||
|
||||
|
|
@ -40,6 +39,7 @@ include "partials/head.php";
|
|||
<?php if (!LOGGED_IN) {
|
||||
include "partials/login-form.php";
|
||||
} else {
|
||||
|
||||
$stmt = $db["data"]->prepare(
|
||||
"SELECT * FROM assignments WHERE assignments.game_id = :game_id"
|
||||
);
|
||||
|
|
@ -57,155 +57,57 @@ include "partials/head.php";
|
|||
]);
|
||||
$submission = $stmt->fetch(PDO::FETCH_OBJ);
|
||||
unset($stmt);
|
||||
|
||||
if ($game->status_id === STATUS_ENROLLING && $submission) {
|
||||
$participant_state = 'GAME_OPEN_WITH_SUBMISSION';
|
||||
} elseif ($game->status_id === STATUS_ENROLLING && !$submission) {
|
||||
$participant_state = 'GAME_OPEN_WITHOUT_SUBMISSION';
|
||||
} elseif ($submission && in_array($game->status_id, [
|
||||
STATUS_ROUND_ONE,
|
||||
STATUS_ROUND_TWO,
|
||||
STATUS_ROUND_THREE,
|
||||
STATUS_DONE,
|
||||
])) {
|
||||
$participant_state = 'GAME_CLOSED_WITH_SUBMISSION';
|
||||
} else {
|
||||
$participant_state = 'GAME_CLOSED_WITHOUT_SUBMISSION';
|
||||
}
|
||||
|
||||
$dates = [
|
||||
"submitstart" => DateTimeImmutable::createFromFormat(
|
||||
"U",
|
||||
$game->submitstart
|
||||
)->setTimezone($time_zone),
|
||||
"submitend" => DateTimeImmutable::createFromFormat(
|
||||
"U",
|
||||
$game->submitend
|
||||
)->setTimezone($time_zone),
|
||||
"onestart" => DateTimeImmutable::createFromFormat(
|
||||
"U",
|
||||
$game->onestart
|
||||
)->setTimezone($time_zone),
|
||||
"twostart" => DateTimeImmutable::createFromFormat(
|
||||
"U",
|
||||
$game->twostart
|
||||
)->setTimezone($time_zone),
|
||||
"threestart" => DateTimeImmutable::createFromFormat(
|
||||
"U",
|
||||
$game->threestart
|
||||
)->setTimezone($time_zone),
|
||||
"gameend" => DateTimeImmutable::createFromFormat(
|
||||
"U",
|
||||
$game->gameend
|
||||
)->setTimezone($time_zone),
|
||||
];
|
||||
?>
|
||||
<article>
|
||||
<article class="single-game">
|
||||
<div class="flow">
|
||||
<h2>Your Submission</h2>
|
||||
<?php
|
||||
$IS_PAID = $submission->transaction_id !== NULL;
|
||||
switch ($participant_state) {
|
||||
case 'GAME_OPEN_WITH_SUBMISSION': ?>
|
||||
<p><a href='/docs/<?= $submission->hash ?>'><?= $submission->title ?></a></p>
|
||||
<?php if (!$IS_PAID) { ?><p>You have not yet paid for your submission.</p><?php } ?>
|
||||
<p><a href="/games/<?= $game->id ?>/update" class='call-to-action'>Update submission</a></p>
|
||||
<?php if (!$IS_PAID) { ?>
|
||||
<p><a href="/games/<?= $game->id ?>/submit" class='call-to-action'>Pay submission fee</a></p>
|
||||
<?php } ?>
|
||||
<?php break;
|
||||
case 'GAME_OPEN_WITHOUT_SUBMISSION': ?>
|
||||
$IS_PAID = $submission && $submission->transaction_id !== null;
|
||||
if (
|
||||
in_array($game->status_id, [
|
||||
STATUS_ENROLLING,
|
||||
STATUS_REVIEW,
|
||||
]) &&
|
||||
$submission &&
|
||||
!$IS_PAID
|
||||
) { ?>
|
||||
<aside class="alert"><p>You have not yet paid for your submission.</p></aside>
|
||||
<?php }
|
||||
if ($submission) {
|
||||
include "partials/submission-details.php"; ?>
|
||||
<ul role="list" class="flow">
|
||||
<?php if (
|
||||
!$IS_PAID &&
|
||||
in_array($game->status_id, [
|
||||
STATUS_ENROLLING,
|
||||
STATUS_REVIEW,
|
||||
])
|
||||
) { ?><li><a href="/games/<?= $game->id ?>/submit" class='call-to-action'>Pay submission fee</a></li><?php } ?>
|
||||
<li><a href="/games/<?= $game->id ?>/update" class='call-to-action'>Update submission<?php !in_array(
|
||||
$game->status_id,
|
||||
[STATUS_ENROLLING, STATUS_REVIEW]
|
||||
)
|
||||
? " visibility"
|
||||
: ""; ?></a></li>
|
||||
</ul>
|
||||
<?php include "partials/feedback.php"; ?>
|
||||
<?php include "partials/assignments.php"; ?>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php if (
|
||||
$game->status_id === STATUS_ENROLLING &&
|
||||
!$submission
|
||||
) { ?>
|
||||
<p>You haven't submitted work to this contest.</p>
|
||||
<p><a href="/games/<?= $game->id ?>/submit" class='call-to-action'>Submit to <?= $game->name ?></a></p>
|
||||
<?php break;
|
||||
case 'GAME_CLOSED_WITH_SUBMISSION': ?>
|
||||
<?php include "partials/submission-info.php"; ?>
|
||||
<p><a href='/games/<?= $game->id ?>/update' class='call-to-action'>Update submission visibility</a></p>
|
||||
<?php include "partials/feedback.php"; ?>
|
||||
<?php include "partials/assignments.php"; ?>
|
||||
<?php break;
|
||||
case 'GAME_CLOSED_WITHOUT_SUBMISSION': ?>
|
||||
<p>You didn't submit a work to this contest.</p>
|
||||
<?php break;
|
||||
default: ?>
|
||||
<?php break;
|
||||
} ?>
|
||||
<?php } ?>
|
||||
<?php if ($game->status_id !== STATUS_DONE && !$submission) { ?>
|
||||
<p>You didn't submit a work to this contest.</p>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<hr/>
|
||||
<div>
|
||||
<h2>Schedule</h2>
|
||||
<dl class="flow" data-game-status="<?= $game->status_id ?>">
|
||||
<div data-status="<?= STATUS_ENROLLING ?>">
|
||||
<dt>Submissions</dt>
|
||||
<dd><span>Open: </span><time datetime="<?= $dates[
|
||||
"submitstart"
|
||||
]->format("c") ?>"><?= $dates["submitstart"]->format(
|
||||
'l, j F, o \a\t h:i A T'
|
||||
) ?></time></dd>
|
||||
<dd><span>Close: </span><time datetime="<?= $dates[
|
||||
"submitend"
|
||||
]->format("c") ?>"><?= $dates["submitend"]->format(
|
||||
'l, j F, o \a\t h:i A T'
|
||||
) ?></time></dd>
|
||||
</div>
|
||||
<div data-status="<?= STATUS_REVIEW ?>">
|
||||
<dt>Document Review</dt>
|
||||
<dd><span>Start: </span><time datetime="<?= $dates[
|
||||
"submitend"
|
||||
]
|
||||
->add($one_second)
|
||||
->format("c") ?>"><?= $dates["submitend"]
|
||||
->add($one_second)
|
||||
->format('l, j F, o \a\t h:i A T') ?></time></dd>
|
||||
<dd><span>End: </span><time datetime="<?= $dates["onestart"]
|
||||
->sub($one_second)
|
||||
->format("c") ?>"><?= $dates["onestart"]
|
||||
->sub($one_second)
|
||||
->format('l, j F, o \a\t h:i A T') ?></time></dd>
|
||||
</div>
|
||||
<div data-status="<?= STATUS_ROUND_ONE ?>">
|
||||
<dt>Round One</dt>
|
||||
<dd><span>Start: </span><time datetime="<?= $dates[
|
||||
"onestart"
|
||||
]->format("c") ?>"><?= $dates["onestart"]->format(
|
||||
'l, j F, o \a\t h:i A T'
|
||||
) ?></time></dd>
|
||||
<dd><span>End: </span><time datetime="<?= $dates["twostart"]
|
||||
->sub($one_second)
|
||||
->format("c") ?>"><?= $dates["twostart"]
|
||||
->sub($one_second)
|
||||
->format('l, j F, o \a\t h:i A T') ?></time></dd>
|
||||
</div>
|
||||
<div data-status="<?= STATUS_ROUND_TWO ?>">
|
||||
<dt>Round Two</dt>
|
||||
<dd><span>Start: </span><time datetime="<?= $dates[
|
||||
"twostart"
|
||||
]->format("c") ?>"><?= $dates["twostart"]->format(
|
||||
'l, j F, o \a\t h:i A T'
|
||||
) ?></time></dd>
|
||||
<dd><span>End: </span><time datetime="<?= $dates[
|
||||
"threestart"
|
||||
]
|
||||
->sub($one_second)
|
||||
->format("c") ?>"><?= $dates["threestart"]
|
||||
->sub($one_second)
|
||||
->format('l, j F, o \a\t h:i A T') ?></time></dd>
|
||||
</div>
|
||||
<div data-status="<?= STATUS_ROUND_THREE ?>">
|
||||
<dt>Round Three</dt>
|
||||
<dd><span>Start: </span><time datetime="<?= $dates[
|
||||
"threestart"
|
||||
]->format("c") ?>"><?= $dates["threestart"]->format(
|
||||
'l, j F, o \a\t h:i A T'
|
||||
) ?></time></dd>
|
||||
<dd><span>End: </span><time datetime="<?= $dates[
|
||||
"gameend"
|
||||
]->format("c") ?>"><?= $dates["gameend"]->format(
|
||||
'l, j F, o \a\t h:i A T'
|
||||
) ?></time></dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
<?php include "partials/contest-schedule.php"; ?>
|
||||
</article>
|
||||
<?php
|
||||
} ?>
|
||||
|
|
|
|||
Loading…
Reference in a new issue