Ajout d'un bouton suivant et précédent pour les énigmes.

Corrections traductions.
Corrections ordres des énigmes.
Corrections CSS.
Corrections DB.
This commit is contained in:
antux18 2024-03-31 16:27:00 +02:00
parent f655529f31
commit d0a515df65
8 changed files with 56 additions and 23 deletions

View File

@ -5,6 +5,7 @@
$solved = false; $solved = false;
$team_id = -1; $team_id = -1;
$art_id = -1; $art_id = -1;
$art_index = -1; // Index de l'article dans la liste pzorder assignée à l'équipe
$database = new Database(); $database = new Database();
@ -27,6 +28,30 @@
} }
else { else {
// On cherche l'index de l'article dans la liste pzorder assignée à l'équipe :
$stmt = $database->pdo_teams->prepare("SELECT pzorder FROM teams WHERE id == :id");
$stmt->bindValue(":id", $team_id);
$stmt->execute();
$result = $stmt->fetch();
$order = $result["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 (is_null($order)) {
$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();
}
$pzo_arr = $pzorder[$order];
$art_index = array_search($art_id, $pzo_arr);
$prev_art = $pzo_arr[$art_index - 1];
if ($art_index == 0) {
$prev_art = $pzo_arr[$max_art - 1];
}
$next_art = $pzo_arr[($art_index + 1) % $max_art];
// On indique si l'énigme est résolue : // 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 = $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(":team_id", $team_id);
@ -59,15 +84,18 @@
</header> </header>
<main> <main>
<header> <header>
<h1><?= $tr["page_title"]["article"] . $art_id . " : " . $article["title"] ?></h1> <h1><?= $tr["page_title"]["article"] . $art_id ?></h1>
<h2><?= $article["text"] ?></h2> <h2><?= $article["text"] ?></h2>
<section> <section>
<a href="article.php?team=<?= $team_id ?>&id=<?= $prev_art ?>">
<button><?= $tr["article"]["prev_but"] ?></button>
</a>
<a href="puzzles.php?team=<?= $team_id ?>"> <a href="puzzles.php?team=<?= $team_id ?>">
<button><?= $tr["article"]["back_but"] ?></button> <button><?= $tr["article"]["back_but"] ?></button>
</a> </a>
<!-- <a href="article.php?team=<?= $team_id ?>&id=<?= ($art_id % $max_art) + 1 ?>"> <a href="article.php?team=<?= $team_id ?>&id=<?= $next_art ?>">
<button><?= $tr["article"]["next_but"] ?></button> <button><?= $tr["article"]["next_but"] ?></button>
</a> --> </a>
</section> </section>
<?php if ($solved) : ?> <?php if ($solved) : ?>
<p><?= $tr["article"]["success"] ?></p> <p><?= $tr["article"]["success"] ?></p>

Binary file not shown.

View File

@ -85,7 +85,7 @@
<?php foreach ($pzorder[$order] as $pzid) : ?> <?php foreach ($pzorder[$order] as $pzid) : ?>
<?php foreach ($puzzles as $puzzle) : ?> <?php foreach ($puzzles as $puzzle) : ?>
<?php if ($puzzle["id"] == $pzid) : ?> <?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> <li><a href="article.php?team=<?= $team_id ?>&id=<?= $puzzle["id"] ?>"><?= $tr["page_title"]["article"] . $puzzle["id"] ?></a></li>
<?php endif; ?> <?php endif; ?>
<?php endforeach; ?> <?php endforeach; ?>
<?php endforeach; ?> <?php endforeach; ?>

View File

@ -17,6 +17,7 @@
"answer" TEXT NOT NULL, "answer" TEXT NOT NULL,
"location" TEXT NOT NULL, "location" TEXT NOT NULL,
"code" TEXT NOT NULL, "code" TEXT NOT NULL,
"reward" TEXT NOT NULL,
PRIMARY KEY("id" AUTOINCREMENT) PRIMARY KEY("id" AUTOINCREMENT)
)'); )');
@ -24,6 +25,7 @@
$this->pdo_teams = new PDO("sqlite:" . dirname(__FILE__) . $data_path . "teams.db"); $this->pdo_teams = new PDO("sqlite:" . dirname(__FILE__) . $data_path . "teams.db");
$this->pdo_teams->query('CREATE TABLE IF NOT EXISTS "teams" ( $this->pdo_teams->query('CREATE TABLE IF NOT EXISTS "teams" (
"id" INTEGER NOT NULL UNIQUE, "id" INTEGER NOT NULL UNIQUE,
"pzorder" INTEGER,
PRIMARY KEY("id" AUTOINCREMENT) PRIMARY KEY("id" AUTOINCREMENT)
)'); )');

View File

@ -1,19 +1,19 @@
<?php <?php
$tr = [ $tr = [
"tab_title" => [ "tab_title" => [
"home" => "Home - Citizenship Code Hunt", "home" => "Home - Citizen's journey",
"team_confirm" => "Team confirmation - Citizenship Code Hunt", "team_confirm" => "Team confirmation - Citizen's journey",
"puzzles" => "Puzzles list - Citizenship Code Hunt", "puzzles" => "Puzzles list - Citizen's journey",
"article" => "Puzzle - Citizenship Code Hunt" "article" => "Puzzle - Citizen's journey"
], ],
"page_title" => [ "page_title" => [
"home" => "Citizenship Code Hunt", "home" => "Citizen's journey",
"team_confirm" => "Team confirmation", "team_confirm" => "Team confirmation",
"puzzles" => "Puzzles list for team n°", "puzzles" => "Puzzles list for team n°",
"article" => "Puzzle n°" "article" => "Puzzle n°"
], ],
"home" => [ "home" => [
"subtitle" => "Welcome to the Citizenship Code Hunt !", "subtitle" => "Welcome to the Citizen's journey !",
"message" => "Enter your team number to begin :", "message" => "Enter your team number to begin :",
"team" => "Team number...", "team" => "Team number...",
"button" => "OK" "button" => "OK"
@ -27,7 +27,8 @@
"message" => "This puzzle describes a specific place. Head to that place, then scan the QR code you'll find there.", "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 !", "success" => "Well done ! Your team solved this puzzle !",
"back_but" => "Puzzle list", "back_but" => "Puzzle list",
"next_but" => "Next puzzle", "prev_but" => "🡰 Prev.",
"next_but" => "Next 🡲",
"qr_but" => "Scan QR code", "qr_but" => "Scan QR code",
"cam_sel" => "Selected camera :", "cam_sel" => "Selected camera :",
"f_cam" => "Front camera", "f_cam" => "Front camera",
@ -38,7 +39,7 @@
"map_desc" => "Here is a map showing the location of the puzzles you already solved :" "map_desc" => "Here is a map showing the location of the puzzles you already solved :"
], ],
"nav" => [ "nav" => [
"title" => "Citizenship Code Hunt", "title" => "Citizen's journey",
"home" => "Home" "home" => "Home"
], ],
"footer" => [ "footer" => [

View File

@ -1,19 +1,19 @@
<?php <?php
$tr = [ $tr = [
"tab_title" => [ "tab_title" => [
"home" => "Accueil - Jeu de Pistes de la Citoyenneté", "home" => "Accueil - Parcours du citoyen",
"team_confirm" => "Confirmation du choix d'équipe - Jeu de Pistes de la Citoyenneté", "team_confirm" => "Confirmation du choix d'équipe - Parcours du citoyen",
"puzzles" => "Liste des énigmes - Jeu de Pistes de la Citoyenneté", "puzzles" => "Liste des énigmes - Parcours du citoyen",
"article" => "Énigme - Jeu de Pistes de la Citoyenneté" "article" => "Énigme - Parcours du citoyen"
], ],
"page_title" => [ "page_title" => [
"home" => "Jeu de Pistes de la Citoyenneté", "home" => "Parcours du citoyen",
"team_confirm" => "Confirmation du choix d'équipe", "team_confirm" => "Confirmation du choix d'équipe",
"puzzles" => "Liste des puzzles pour l'équipe n°", "puzzles" => "Liste des puzzles pour l'équipe n°",
"article" => "Énigme n°" "article" => "Énigme n°"
], ],
"home" => [ "home" => [
"subtitle" => "Bienvenue dans le Jeu de Pistes de la Citoyenneté !", "subtitle" => "Bienvenue dans le Parcours du citoyen !",
"message" => "Pour commencer, veuillez entrer le numéro de votre équipe :", "message" => "Pour commencer, veuillez entrer le numéro de votre équipe :",
"team" => "Numéro d'équipe...", "team" => "Numéro d'équipe...",
"button" => "Valider" "button" => "Valider"
@ -27,7 +27,8 @@
"message" => "Cette énigme décrit un endroit précis. Dirigez-vous vers cet endroit, puis scannez le QR code que vous-y trouverez.", "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 !", "success" => "Bien joué ! Votre équipe a résolu cette énigme !",
"back_but" => "Liste des énigmes", "back_but" => "Liste des énigmes",
"next_but" => "Énigme suivante", "prev_but" => "🡰 Préc.",
"next_but" => "Suiv. 🡲",
"qr_but" => "Scanner le QR code", "qr_but" => "Scanner le QR code",
"cam_sel" => "Caméra sélectionnée :", "cam_sel" => "Caméra sélectionnée :",
"f_cam" => "Caméra avant", "f_cam" => "Caméra avant",
@ -38,7 +39,7 @@
"map_desc" => "Voici la carte des emplacements des énigmes que vous avez résolues :" "map_desc" => "Voici la carte des emplacements des énigmes que vous avez résolues :"
], ],
"nav" => [ "nav" => [
"title" => "Jeu de Pistes de la Citoyenneté", "title" => "Parcours du citoyen",
"home" => "Accueil" "home" => "Accueil"
], ],
"footer" => [ "footer" => [

View File

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

View File

@ -149,6 +149,7 @@ main header section {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: center; justify-content: center;
align-items: center;
gap: 15px; gap: 15px;
} }