diff --git a/article.php b/article.php index f1c9ba6..dec6fca 100644 --- a/article.php +++ b/article.php @@ -8,6 +8,8 @@ $database = new Database(); + $max_art = $database->getArticleNb(); + if (isset($_GET["id"]) && isset($_GET["team"])) { $art_id = htmlspecialchars($_GET["id"]); $team_id = htmlspecialchars($_GET["team"]); @@ -18,19 +20,26 @@ $stmt->execute(); $article = $stmt->fetch(); - // Recherche de l'équipe dans la base : - $stmt = $database->pdo_teams->prepare("SELECT * FROM teams WHERE id == :id"); - $stmt->bindValue(":id", $team_id); - $stmt->execute(); - // Vérification de l'existence du groupe et de l'énigme : - if (empty($article) || empty($stmt->fetch())) { + if (empty($article) || !$database->checkTeamExists($team_id)) { header("Location: index.php"); die(); } else { - // On vérifie si l'énigme est résolue : + // On vérifie si l'énigme bonus n'est pas débloquée : + if (!$database->checkTeamBonus($team_id)) { + // Si c'est celle qui est sélectionnée, on retourne à la liste des énigmes : + if ($art_id == $max_art) { + header("Location: puzzles.php?team=" . $team_id); + die(); + } + + // On retire l'énigme bonus du total : + $max_art--; + } + + // On indique si l'énigme est résolue : $stmt = $database->pdo_teams->prepare("SELECT * FROM solved WHERE (team_id == :team_id AND puzzle_id == :puzzle_id)"); $stmt->bindValue(":team_id", $team_id); $stmt->bindValue(":puzzle_id", $art_id); @@ -66,6 +75,14 @@

+
+ + + + + + +

diff --git a/require/database.php b/require/database.php index 0b294f7..aa04737 100644 --- a/require/database.php +++ b/require/database.php @@ -52,10 +52,16 @@ return !empty($stmt->fetch()); } - // public function getArticleNb() { - // $query = $this->pdo_article->query("SELECT COUNT(*) FROM puzzles"); - // return $query->fetch()["COUNT(*)"]; - // } + public function getArticleNb() { + $query = $this->pdo_article->query("SELECT COUNT(*) FROM puzzles"); + return $query->fetch()["COUNT(*)"]; + } + + function checkTeamBonus(int $team) { + // $team doit être une équipe existante : + $query = $this->pdo_teams->query("SELECT bonus FROM teams WHERE id = " . $team); + return $query->fetch()[0] == 1; + } // public function getTeamsNb() { // $query = $this->pdo_teams->query("SELECT COUNT(*) FROM teams"); diff --git a/require/locales/en.php b/require/locales/en.php index 1832e63..66727d1 100644 --- a/require/locales/en.php +++ b/require/locales/en.php @@ -26,6 +26,8 @@ "article" => [ "message" => "This puzzle describes a specific place. Head to that place, then scan the QR code you'll find there.", "success" => "Well done ! Your team solved this puzzle !", + "back_but" => "Puzzle list", + "next_but" => "Next puzzle", "qr_but" => "Scan QR code", "cam_sel" => "Selected camera :", "f_cam" => "Front camera", diff --git a/require/locales/fr.php b/require/locales/fr.php index 0e5759b..bd457a8 100644 --- a/require/locales/fr.php +++ b/require/locales/fr.php @@ -26,6 +26,8 @@ "article" => [ "message" => "Cette énigme décrit un endroit précis. Dirigez-vous vers cet endroit, puis scannez le QR code que vous-y trouverez.", "success" => "Bien joué ! Votre équipe a résolu cette énigme !", + "back_but" => "Liste des énigmes", + "next_but" => "Énigme suivante", "qr_but" => "Scanner le QR code", "cam_sel" => "Caméra sélectionnée :", "f_cam" => "Caméra avant", diff --git a/style.css b/style.css index c8bbb4f..3d1dda4 100644 --- a/style.css +++ b/style.css @@ -59,6 +59,7 @@ input { } input[type="submit"], button { + font-size: 14px; background: var(--hl); border-style: none; padding: 20px; @@ -250,6 +251,13 @@ main > article img { width: 45%; } +main > article div { + display: flex; + flex-direction: row; + align-self: center; + gap: 15px; +} + nav article { background-color: var(--bg-dark); border-style: solid; @@ -321,6 +329,11 @@ video { main > article img { width: 100%; + max-height: 100px; + } + + main > article div { + flex-direction: row; } video { diff --git a/todo.md b/todo.md index 1b6ade5..6467494 100644 --- a/todo.md +++ b/todo.md @@ -3,8 +3,8 @@ [x] Ajouter pages avec nom des membres équipe [x] Empêcher retour à la liste d'équipe une fois sélectionnée [x] Input au lieu de liste équipe -[ ] Bouton retour aux énigmes -[ ] Bouton énigme suivante +[x] Bouton retour aux énigmes +[x] Bouton énigme suivante [ ] Carte avec toutes les énigmes [ ] Ordre énigmes aléatoire [ ] CSS du cadre QR Code \ No newline at end of file