1
0
Fork 0
app.sixfold.org/lib/partials/assignments.php
2024-11-14 04:30:20 -05:00

86 lines
3 KiB
PHP

<?php
$assignments = new stdClass();
$assignments->params = [
"game_id" => $game->id,
"member_id" => 30436 ?? $_SESSION["account"]->id,
"round" => 1,
];
$stmt_assignments = $db["data"]->prepare(
"SELECT submissions.id, title, hash, score FROM assignments
JOIN submissions ON submissions.id = assignments.submission_id
WHERE assignments.game_id = :game_id AND assignments.member_id = :member_id
AND round_number = :round"
);
$stmt_assignments->execute($assignments->params);
$assignments->round_1 = $stmt_assignments->fetchAll(PDO::FETCH_OBJ);
$assignments->params["round"] = 2;
$stmt_assignments->execute($assignments->params);
$assignments->round_2 = $stmt_assignments->fetchAll(PDO::FETCH_OBJ);
$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>
<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>
<thead>
<tr>
<th scope="col">Title</th>
<th scope="col">Score</th>
</tr>
</thead>
<tbody>
<?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>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<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>
<thead>
<tr>
<th scope="col">Title</th>
<th scope="col">Score</th>
</tr>
</thead>
<tbody>
<?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>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<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>
<thead>
<tr>
<th scope="col">Title</th>
<th scope="col">Score</th>
</tr>
</thead>
<tbody>
<?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>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</section>