master #1

Merged
antux18 merged 9 commits from Antux/JeuPistesSarreguemines:master into jeu-pistes-sarreguemines 2024-09-01 15:37:45 +02:00
4 changed files with 34 additions and 2 deletions
Showing only changes of commit a0e3ba8c09 - Show all commits

Binary file not shown.

View File

@ -2,6 +2,7 @@
require_once "require/base.php"; require_once "require/base.php";
$puzzles = array(); $puzzles = array();
$order = 0;
$team_id = -1; $team_id = -1;
$database = new Database(); $database = new Database();
@ -35,6 +36,23 @@
$stmt->execute(); $stmt->execute();
$puzzles = $stmt->fetchAll(); $puzzles = $stmt->fetchAll();
// Recherche de l'ordre des énigmes :
$stmt = $database->pdo_teams->prepare("SELECT pzorder FROM teams WHERE id == :id");
$stmt->bindValue(":id", $team_id);
$stmt->execute();
$order = $stmt->fetch();
echo (string) $order["pzorder"];
// Si un ordre d'énigmes n'a pas été défini au préalable pour cette équipe, on en choisit un au hasard :
if ($order == NULL) {
$order = rand(0, sizeof($pzorder));
$stmt = $database->pdo_teams->prepare("UPDATE teams SET pzorder = :order WHERE id == :id");
$stmt->bindValue(":id", $team_id);
$stmt->bindValue(":order", $order);
$stmt->execute();
}
} }
} }
@ -65,8 +83,12 @@
<article> <article>
<p><?= $tr["puzzles"]["message"]?></p> <p><?= $tr["puzzles"]["message"]?></p>
<ul> <ul>
<?php foreach ($puzzles as $puzzle) : ?> <?php foreach ($pzorder[$order["pzorder"]] as $pzid) : ?>
<li><a href="article.php?team=<?= $team_id ?>&id=<?= $puzzle["id"] ?>"><?= $tr["page_title"]["article"] . $puzzle["id"] . " : " . $puzzle["title"] ?></a></li> <?php foreach ($puzzles as $puzzle) : ?>
<?php if ($puzzle["id"] == $pzid) : ?>
<li><a href="article.php?team=<?= $team_id ?>&id=<?= $puzzle["id"] ?>"><?= $tr["page_title"]["article"] . $puzzle["id"] . " : " . $puzzle["title"] ?></a></li>
<?php endif; ?>
<?php endforeach; ?>
<?php endforeach; ?> <?php endforeach; ?>
</ul> </ul>
</article> </article>

View File

@ -1,5 +1,6 @@
<?php <?php
require_once "database.php"; require_once "database.php";
require_once "puzzles_order.php";
$rq_path = "require/"; $rq_path = "require/";

View File

@ -0,0 +1,9 @@
<?php
$pzorder = [
[7,4,3,2,5,8,9,6,10,1],
[10,6,8,5,2,7,4,3,1],
[5,2,7,4,3,6,8,10,1],
[3,6,8,10,9,4,7,5,8,2,1],
[9,6,10,4,7,8,5,3,2,1]
]
?>