Nouvelle branche pour le mode énigme aléatoire :
- La page des énigmes n'affiche plus toutes les énigmes, seulement celles résolues. - La page des énigmes contient un bouton pour résoudre une énigme (choisie aléatoirement parmi celles qui ne sont pas résolues). - Un message s'affiche sur la page des énigmes quand toutes sont résolues. Divers : - Définition de fonctions pour les tâches les plus courantes.
This commit is contained in:
parent
bd8275f7ae
commit
cd84b319e7
@ -1,7 +1,9 @@
|
|||||||
# Jeu de pistes Sarreguemines
|
# Chasse au trésor Lycée Pange
|
||||||
|
|
||||||
**Auteur :** Antoine WAEHREN
|
**Auteur :** Antoine WAEHREN
|
||||||
|
|
||||||
|
Sur cette version, la liste des énigmes n'affiche pas immédiatement toutes les énigmes, uniquement celles qui ont été résolues. L'énigme suivante est choisie aléatoirement.
|
||||||
|
|
||||||
## Crédits
|
## Crédits
|
||||||
|
|
||||||
Ce projet utilise le module QR Scanner de NIMIQ : https://github.com/nimiq/qr-scanner
|
Ce projet utilise le module QR Scanner de NIMIQ : https://github.com/nimiq/qr-scanner
|
||||||
|
45
answer.php
45
answer.php
@ -1,30 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once "require/base.php";
|
require_once "require/base.php";
|
||||||
|
|
||||||
$team_id = -1;
|
|
||||||
$art_id = -1;
|
|
||||||
$article = array();
|
|
||||||
|
|
||||||
$database = new Database();
|
$database = new Database();
|
||||||
|
$bonus = $database->getArticleNb(); // L'énigme bonus est la dernière
|
||||||
|
|
||||||
if (isset($_GET["code"]) && isset($_GET["team"]) && isset($_GET["id"])) {
|
if (isset($_GET["code"]) && isset($_GET["team"]) && isset($_GET["id"])) {
|
||||||
$team_id = htmlspecialchars($_GET["team"]);
|
$team_id = htmlspecialchars($_GET["team"]);
|
||||||
|
|
||||||
// Recherche du groupe :
|
|
||||||
$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 :
|
// Vérification de l'existence du groupe :
|
||||||
if (!empty($stmt->fetch())) {
|
if ($database->checkTeamExists($team_id)) {
|
||||||
$art_id = htmlspecialchars($_GET["id"]);
|
$art_id = htmlspecialchars($_GET["id"]);
|
||||||
|
$code = htmlspecialchars($_GET["code"]);
|
||||||
// Recherche de l'énigme avec son code :
|
$article = $database->getArticle($art_id);
|
||||||
$stmt = $database->pdo_article->prepare("SELECT * FROM puzzles WHERE (id == :id AND code == :code)");
|
|
||||||
$stmt->bindValue(":id", $art_id);
|
|
||||||
$stmt->bindValue(":code", htmlspecialchars($_GET["code"]));
|
|
||||||
$stmt->execute();
|
|
||||||
$article = $stmt->fetch();
|
|
||||||
|
|
||||||
// Données renvoyées :
|
// Données renvoyées :
|
||||||
$data = [
|
$data = [
|
||||||
@ -33,27 +20,25 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Vérification de la combinaison ID énigme + code :
|
// Vérification de la combinaison ID énigme + code :
|
||||||
if (empty($article)) {
|
if (!$database->checkPuzzle($art_id, $code)) {
|
||||||
// Si la combinaison ne fonctionne pas, affichage de l'indice :
|
|
||||||
$stmt = $database->pdo_article->prepare("SELECT * FROM puzzles WHERE id == :id");
|
|
||||||
$stmt->bindValue(":id", $art_id);
|
|
||||||
$stmt->execute();
|
|
||||||
$article = $stmt->fetch();
|
|
||||||
$data["hint"] = $article["hint"];
|
$data["hint"] = $article["hint"];
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
// On enregistre la réussite dans la table :
|
// On enregistre la réussite dans la table :
|
||||||
// Vérification que ce n'est pas déjà enregistré :
|
// Vérification que ce n'est pas déjà enregistré
|
||||||
$stmt = $database->pdo_teams->prepare("SELECT * FROM solved WHERE (puzzle_id == :puzzle_id AND team_id == :team_id)");
|
// Si ce n'est pas le cas, on enregistre :
|
||||||
$stmt->bindValue(":puzzle_id", $art_id);
|
if (!$database->isPuzzleSolved($art_id, $team_id)) {
|
||||||
|
$database->solvePuzzle($art_id, $team_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// On ajoute l'énigme bonus si toutes les autres sont résolues :
|
||||||
|
$stmt = $database->pdo_teams->prepare("SELECT COUNT(*) FROM solved WHERE team_id == :team_id");
|
||||||
$stmt->bindValue(":team_id", $team_id);
|
$stmt->bindValue(":team_id", $team_id);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
// Si ce n'est pas le cas, on enregistre :
|
if ($stmt->fetchAll()[0]["COUNT(*)"] == $bonus - 1) {
|
||||||
if (empty($stmt->fetch())) {
|
$stmt = $database->pdo_teams->prepare("UPDATE teams SET bonus = 1 WHERE id = :team_id");
|
||||||
$stmt = $database->pdo_teams->prepare("INSERT INTO solved VALUES (:puzzle_id, :team_id)");
|
|
||||||
$stmt->bindValue(":puzzle_id", $art_id);
|
|
||||||
$stmt->bindValue(":team_id", $team_id);
|
$stmt->bindValue(":team_id", $team_id);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
83
article.php
83
article.php
@ -1,63 +1,42 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once "require/base.php";
|
require_once "require/base.php";
|
||||||
|
|
||||||
$article = array();
|
|
||||||
$solved = false;
|
|
||||||
$team_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();
|
||||||
|
$bonus = $database->getArticleNb(); // L'énigme bonus est la dernière
|
||||||
$max_art = $database->getArticleNb();
|
|
||||||
|
|
||||||
if (isset($_GET["id"]) && isset($_GET["team"])) {
|
if (isset($_GET["id"]) && isset($_GET["team"])) {
|
||||||
$art_id = htmlspecialchars($_GET["id"]);
|
$art_id = htmlspecialchars($_GET["id"]);
|
||||||
$team_id = htmlspecialchars($_GET["team"]);
|
$team_id = htmlspecialchars($_GET["team"]);
|
||||||
|
|
||||||
// Recherche de l'énigme indiquée dans la base :
|
|
||||||
$stmt = $database->pdo_article->prepare("SELECT * FROM puzzles WHERE id == :id");
|
|
||||||
$stmt->bindValue(":id", $art_id);
|
|
||||||
$stmt->execute();
|
|
||||||
$article = $stmt->fetch();
|
|
||||||
|
|
||||||
// Vérification de l'existence du groupe et de l'énigme :
|
// Vérification de l'existence du groupe et de l'énigme :
|
||||||
if (empty($article) || !$database->checkTeamExists($team_id)) {
|
if (!$database->checkArticleExists($art_id)) {
|
||||||
header("Location: index.php");
|
if (!$database->checkTeamExists($team_id)) {
|
||||||
die();
|
header("Location: index.php");
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
else if ($art_id == -1) {
|
||||||
|
header("Location: puzzles.php?team=" . $team_id);
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
header("Location: index.php");
|
||||||
|
die();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
// On cherche l'index de l'article dans la liste pzorder assignée à l'équipe :
|
// On vérifie si l'énigme bonus n'est pas débloquée :
|
||||||
$stmt = $database->pdo_teams->prepare("SELECT pzorder FROM teams WHERE id == :id");
|
if (!$database->checkTeamBonus($team_id)) {
|
||||||
$stmt->bindValue(":id", $team_id);
|
// Si c'est celle qui est sélectionnée, on retourne à la page d'accueil :
|
||||||
$stmt->execute();
|
if ($art_id == $bonus) {
|
||||||
$result = $stmt->fetch();
|
header("Location: index.php");
|
||||||
$order = $result["pzorder"];
|
die();
|
||||||
|
}
|
||||||
// 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];
|
$article = $database->getArticle($art_id);
|
||||||
$art_index = array_search($art_id, $pzo_arr);
|
$next_art = $database->getNextPuzzle($team_id);
|
||||||
$prev_art = $pzo_arr[$art_index - 1];
|
$solved = $database->isPuzzleSolved($art_id, $team_id);
|
||||||
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 :
|
|
||||||
$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);
|
|
||||||
$stmt->execute();
|
|
||||||
$solved = !empty($stmt->fetch());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,20 +63,12 @@
|
|||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
<header>
|
<header>
|
||||||
<h1><?= $tr["page_title"]["article"] . $art_id ?></h1>
|
<h1><?= $tr["page_title"]["article"] . $art_id . " : " . $article["title"] ?></h1>
|
||||||
<h2><?= $article["text"] ?></h2>
|
<h2><?= $article["text"] ?></h2>
|
||||||
<section>
|
<?php if ($solved) : ?>
|
||||||
<a href="article.php?team=<?= $team_id ?>&id=<?= $prev_art ?>">
|
|
||||||
<button><?= $tr["article"]["prev_but"] ?></button>
|
|
||||||
</a>
|
|
||||||
<a href="puzzles.php?team=<?= $team_id ?>">
|
|
||||||
<button><?= $tr["article"]["back_but"] ?></button>
|
|
||||||
</a>
|
|
||||||
<a href="article.php?team=<?= $team_id ?>&id=<?= $next_art ?>">
|
<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>
|
|
||||||
<?php if ($solved) : ?>
|
|
||||||
<p><?= $tr["article"]["success"] ?></p>
|
<p><?= $tr["article"]["success"] ?></p>
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<p><?= $tr["article"]["message"] ?></p>
|
<p><?= $tr["article"]["message"] ?></p>
|
||||||
@ -106,7 +77,7 @@
|
|||||||
<article>
|
<article>
|
||||||
<?php if ($solved) : ?>
|
<?php if ($solved) : ?>
|
||||||
<p><?= $article["answer"] ?></p>
|
<p><?= $article["answer"] ?></p>
|
||||||
<h1><?= $article["reward"] ?></h1>
|
<img src="images/map/puzzles/<?= $article["id"] ?>.png"/>
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<button><?= $tr["article"]["qr_but"] ?></button>
|
<button><?= $tr["article"]["qr_but"] ?></button>
|
||||||
<p></p> <!-- Emplacement du message d'erreur JS concernant la caméra. !-->
|
<p></p> <!-- Emplacement du message d'erreur JS concernant la caméra. !-->
|
||||||
|
BIN
data/article.db
BIN
data/article.db
Binary file not shown.
BIN
data/teams.db
BIN
data/teams.db
Binary file not shown.
16
index.php
16
index.php
@ -2,8 +2,9 @@
|
|||||||
require_once "require/base.php";
|
require_once "require/base.php";
|
||||||
|
|
||||||
$database = new Database();
|
$database = new Database();
|
||||||
|
$teams = $database->getTeams();
|
||||||
|
|
||||||
// Si l'appareil a déjà choisi une équipe, on le redirige vers la bonne page :
|
// Si l'appareil a déjà choisi une équipe, on le redirige vers une énigme :
|
||||||
if (isset($_COOKIE["team"])) {
|
if (isset($_COOKIE["team"])) {
|
||||||
$team_id = htmlspecialchars($_COOKIE["team"]);
|
$team_id = htmlspecialchars($_COOKIE["team"]);
|
||||||
|
|
||||||
@ -11,19 +12,6 @@
|
|||||||
header("Location: puzzles.php?team=" . $team_id);
|
header("Location: puzzles.php?team=" . $team_id);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
|
||||||
$stmt = $database->pdo_teams->prepare("SELECT * FROM teams");
|
|
||||||
$stmt->execute();
|
|
||||||
$teams = $stmt->fetchAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sinon, on affiche la liste des équipes :
|
|
||||||
else {
|
|
||||||
$stmt = $database->pdo_teams->prepare("SELECT * FROM teams");
|
|
||||||
$stmt->execute();
|
|
||||||
$teams = $stmt->fetchAll();
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
82
puzzles.php
82
puzzles.php
@ -1,57 +1,36 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once "require/base.php";
|
require_once "require/base.php";
|
||||||
|
|
||||||
$puzzles = array();
|
|
||||||
$order = 0;
|
|
||||||
$team_id = -1;
|
|
||||||
|
|
||||||
$database = new Database();
|
$database = new Database();
|
||||||
|
|
||||||
if (isset($_GET["team"])) {
|
if (isset($_GET["team"])) {
|
||||||
$team_id = htmlspecialchars($_GET["team"]);
|
$team_id = htmlspecialchars($_GET["team"]);
|
||||||
|
|
||||||
// Vérification de l'existence du groupe :
|
if (!$database->checkTeamExists($team_id)) {
|
||||||
$stmt = $database->pdo_teams->prepare("SELECT * FROM teams WHERE id == :id");
|
|
||||||
$stmt->bindValue(":id", $team_id);
|
|
||||||
$stmt->execute();
|
|
||||||
|
|
||||||
if (empty($stmt->fetch())) {
|
|
||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
// On crée un cookie pour enregistrer l'équipe sélectionnée :
|
if (!isset($_COOKIE["team"])) {
|
||||||
setcookie(
|
// On crée un cookie pour enregistrer l'équipe sélectionnée :
|
||||||
"team",
|
setcookie(
|
||||||
$team_id,
|
"team",
|
||||||
time() + (365 * 24 * 60 * 60),
|
$team_id,
|
||||||
"/",
|
time() + (365 * 24 * 60 * 60),
|
||||||
"",
|
"/",
|
||||||
false,
|
"",
|
||||||
false
|
false,
|
||||||
);
|
false
|
||||||
|
);
|
||||||
$stmt = $database->pdo_article->prepare("SELECT * FROM puzzles");
|
|
||||||
|
|
||||||
$stmt->execute();
|
|
||||||
$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();
|
|
||||||
$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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$solved = $database->getSolvedPuzzles($team_id);
|
||||||
|
$puzzles = [];
|
||||||
|
foreach ($solved as $p) {
|
||||||
|
array_push($puzzles, $database->getArticle($p));
|
||||||
|
}
|
||||||
|
$next_art = $database->getNextPuzzle($team_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,16 +59,23 @@
|
|||||||
<h1><?= $tr["page_title"]["puzzles"] . $team_id ?></h1>
|
<h1><?= $tr["page_title"]["puzzles"] . $team_id ?></h1>
|
||||||
</header>
|
</header>
|
||||||
<article>
|
<article>
|
||||||
<p><?= $tr["puzzles"]["message"]?></p>
|
<?php if ($next_art != -1) : ?>
|
||||||
<ul>
|
<a href="article.php?team=<?= $team_id ?>&id=<?= $next_art ?>">
|
||||||
<?php foreach ($pzorder[$order] as $pzid) : ?>
|
<button><?= $tr["puzzles"]["pz_but"] ?></button>
|
||||||
|
</a>
|
||||||
|
<?php if (!empty($puzzles)) : ?>
|
||||||
|
<p><?= $tr["puzzles"]["message"]?></p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php else : ?>
|
||||||
|
<p><?= $tr["puzzles"]["success"]?></p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (!empty($puzzles)) : ?>
|
||||||
|
<ul>
|
||||||
<?php foreach ($puzzles as $puzzle) : ?>
|
<?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>
|
||||||
<li><a href="article.php?team=<?= $team_id ?>&id=<?= $puzzle["id"] ?>"><?= $tr["page_title"]["article"] . $puzzle["id"] ?></a></li>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php endforeach; ?>
|
</ul>
|
||||||
</ul>
|
<?php endif; ?>
|
||||||
</article>
|
</article>
|
||||||
</main>
|
</main>
|
||||||
<footer>
|
<footer>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once "database.php";
|
require_once "database.php";
|
||||||
require_once "puzzles_order.php";
|
|
||||||
|
|
||||||
$rq_path = "require/";
|
$rq_path = "require/";
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
"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)
|
||||||
)');
|
)');
|
||||||
|
|
||||||
@ -25,7 +24,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,
|
"bonus" INTEGER NOT NULL,
|
||||||
PRIMARY KEY("id" AUTOINCREMENT)
|
PRIMARY KEY("id" AUTOINCREMENT)
|
||||||
)');
|
)');
|
||||||
|
|
||||||
@ -46,6 +45,18 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getArticle(int $id) {
|
||||||
|
$stmt = $this->pdo_article->prepare("SELECT * FROM puzzles WHERE id == :id");
|
||||||
|
$stmt->bindValue(":id", $id);
|
||||||
|
$stmt->execute();
|
||||||
|
return $stmt->fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getArticleNb() {
|
||||||
|
$query = $this->pdo_article->query("SELECT COUNT(*) FROM puzzles");
|
||||||
|
return $query->fetch()["COUNT(*)"];
|
||||||
|
}
|
||||||
|
|
||||||
public function checkTeamExists(int $id) {
|
public function checkTeamExists(int $id) {
|
||||||
$stmt = $this->pdo_teams->prepare("SELECT * FROM teams WHERE id == :id");
|
$stmt = $this->pdo_teams->prepare("SELECT * FROM teams WHERE id == :id");
|
||||||
$stmt->bindValue(":id", $id);
|
$stmt->bindValue(":id", $id);
|
||||||
@ -53,9 +64,78 @@
|
|||||||
return !empty($stmt->fetch());
|
return !empty($stmt->fetch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getArticleNb() {
|
public function checkArticleExists(int $id) {
|
||||||
$query = $this->pdo_article->query("SELECT COUNT(*) FROM puzzles");
|
return !empty($this->getArticle($id));
|
||||||
return $query->fetch()["COUNT(*)"];
|
}
|
||||||
|
|
||||||
|
public function checkPuzzle(int $id, int $code) {
|
||||||
|
$stmt = $this->pdo_article->prepare("SELECT * FROM puzzles WHERE (id == :id AND code == :code)");
|
||||||
|
$stmt->bindValue(":id", $id);
|
||||||
|
$stmt->bindValue(":code", $code);
|
||||||
|
$stmt->execute();
|
||||||
|
return !empty($stmt->fetch());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isPuzzleSolved(int $id, int $team) {
|
||||||
|
$stmt = $this->pdo_teams->prepare("SELECT * FROM solved WHERE (team_id == :team_id AND puzzle_id == :puzzle_id)");
|
||||||
|
$stmt->bindValue(":team_id", $team);
|
||||||
|
$stmt->bindValue(":puzzle_id", $id);
|
||||||
|
$stmt->execute();
|
||||||
|
return !empty($stmt->fetch());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function solvePuzzle(int $id, int $team) {
|
||||||
|
$stmt = $this->pdo_teams->prepare("INSERT INTO solved VALUES (:puzzle_id, :team_id)");
|
||||||
|
$stmt->bindValue(":puzzle_id", $id);
|
||||||
|
$stmt->bindValue(":team_id", $team);
|
||||||
|
$stmt->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSolvedPuzzles(int $team) {
|
||||||
|
// $team doit être une équipe existante :
|
||||||
|
$stmt = $this->pdo_teams->prepare("SELECT * FROM solved WHERE team_id == :id");
|
||||||
|
$stmt->bindValue(":id", $team);
|
||||||
|
$stmt->execute();
|
||||||
|
$res = $stmt->fetchAll();
|
||||||
|
$solved = [];
|
||||||
|
foreach ($res as $r) {
|
||||||
|
array_push($solved, $r["puzzle_id"]);
|
||||||
|
}
|
||||||
|
return $solved;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getUnsolvedPuzzles(int $team) {
|
||||||
|
$solved = $this->getSolvedPuzzles($team);
|
||||||
|
$unsolved = range(1, $this->getArticleNb());
|
||||||
|
// On supprime les énigmes résolues :
|
||||||
|
foreach ($solved as $p) {
|
||||||
|
$key = array_search($p, $unsolved);
|
||||||
|
array_splice($unsolved, $key, 1);
|
||||||
|
}
|
||||||
|
return $unsolved;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNextPuzzle(int $team) {
|
||||||
|
$unsolved = $this->getUnsolvedPuzzles($team);
|
||||||
|
$next = -1; // Quand il n'y a plus d'autre énigme à résoudre
|
||||||
|
if (!empty($unsolved)) {
|
||||||
|
$next = $unsolved[array_rand($unsolved)];
|
||||||
|
}
|
||||||
|
return $next;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkTeamBonus(int $team) {
|
||||||
|
// $team doit être une équipe existante :
|
||||||
|
$stmt = $this->pdo_teams->prepare("SELECT bonus FROM teams WHERE id == :id");
|
||||||
|
$stmt->bindValue(":id", $team);
|
||||||
|
$stmt->execute();
|
||||||
|
return $stmt->fetch()[0] == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTeams() {
|
||||||
|
$stmt = $this->pdo_teams->prepare("SELECT * FROM teams");
|
||||||
|
$stmt->execute();
|
||||||
|
return $stmt->fetchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// public function getTeamsNb() {
|
// public function getTeamsNb() {
|
||||||
|
@ -1,45 +1,46 @@
|
|||||||
<?php
|
<?php
|
||||||
$tr = [
|
$tr = [
|
||||||
"tab_title" => [
|
"tab_title" => [
|
||||||
"home" => "Home - Citizen's journey",
|
"home" => "Home - Lycée Pange Code Hunt",
|
||||||
"team_confirm" => "Team confirmation - Citizen's journey",
|
"team_confirm" => "Team confirmation - Lycée Pange Code Hunt",
|
||||||
"puzzles" => "Puzzles list - Citizen's journey",
|
"puzzles" => "Puzzles list - Lycée Pange Code Hunt",
|
||||||
"article" => "Puzzle - Citizen's journey"
|
"article" => "Puzzle - Lycée Pange Code Hunt"
|
||||||
],
|
],
|
||||||
"page_title" => [
|
"page_title" => [
|
||||||
"home" => "Citizen's journey",
|
"home" => "Code Hunt",
|
||||||
"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 Citizen's journey!",
|
"subtitle" => "Welcome to the code hunt of Lycée Jean de Pange of Sarreguemines !",
|
||||||
"message" => "Enter your team number to begin:",
|
"message" => "Enter your team number to begin :",
|
||||||
"team" => "Team number...",
|
"team" => "Team number...",
|
||||||
"button" => "OK"
|
"button" => "OK"
|
||||||
],
|
],
|
||||||
"team_confirm" => [
|
"team_confirm" => [
|
||||||
"subtitle" => "Please make sure you selected the right team.",
|
"subtitle" => "Please make sure you selected the right team.",
|
||||||
"message" => "Your name must appear on the following list: ",
|
"message" => "Your name must appear on the following list : ",
|
||||||
"button" => "Yes, this is my team !"
|
"button" => "Yes, this is my team !"
|
||||||
],
|
],
|
||||||
"article" => [
|
"article" => [
|
||||||
"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",
|
||||||
"prev_but" => "🡰 Prev.",
|
"next_but" => "Next puzzle",
|
||||||
"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",
|
||||||
"r_cam" => "Rear camera"
|
"r_cam" => "Rear camera"
|
||||||
],
|
],
|
||||||
"puzzles" => [
|
"puzzles" => [
|
||||||
"message" => "Select a puzzle in the list below:",
|
"message" => "Select a puzzle in the list below :",
|
||||||
"map_desc" => "Here is a map showing the location of the puzzles you already solved:"
|
"success" => "Congratulations, you solved all the puzzles ! You can now select a specific puzzle in the list below :",
|
||||||
|
"pz_but" => "Solve a puzzle",
|
||||||
|
"map_desc" => "Here is a map showing the location of the puzzles you already solved :"
|
||||||
],
|
],
|
||||||
"nav" => [
|
"nav" => [
|
||||||
"title" => "Citizen's journey",
|
"title" => "Code Hunt Pange",
|
||||||
"home" => "Home"
|
"home" => "Home"
|
||||||
],
|
],
|
||||||
"footer" => [
|
"footer" => [
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
$tr = [
|
$tr = [
|
||||||
"tab_title" => [
|
"tab_title" => [
|
||||||
"home" => "Accueil - Parcours citoyen",
|
"home" => "Accueil - Chasse au code Lycée Pange",
|
||||||
"team_confirm" => "Confirmation du choix d'équipe - Parcours citoyen",
|
"team_confirm" => "Confirmation du choix d'équipe - Chasse au code Lycée Pange",
|
||||||
"puzzles" => "Liste des énigmes - Parcours citoyen",
|
"puzzles" => "Liste des énigmes - Chasse au code Lycée Pange",
|
||||||
"article" => "Énigme - Parcours citoyen"
|
"article" => "Énigme - Chasse au code Lycée Pange"
|
||||||
],
|
],
|
||||||
"page_title" => [
|
"page_title" => [
|
||||||
"home" => "Parcours citoyen",
|
"home" => "Chasse au code",
|
||||||
"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 Parcours citoyen !",
|
"subtitle" => "Bienvenue à la chasse au code du Lycée Jean de Pange de Sarreguemines !",
|
||||||
"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,8 +27,7 @@
|
|||||||
"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",
|
||||||
"prev_but" => "🡰 Préc.",
|
"next_but" => "Énigme suivante",
|
||||||
"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",
|
||||||
@ -36,14 +35,16 @@
|
|||||||
],
|
],
|
||||||
"puzzles" => [
|
"puzzles" => [
|
||||||
"message" => "Choisissez une énigme dans la liste ci-dessous :",
|
"message" => "Choisissez une énigme dans la liste ci-dessous :",
|
||||||
|
"success" => "Félicitations, vous avez résolu toutes les énigmes ! Vous pouvez maintenant sélectionner une énigme en particulier dans la liste ci-dessous :",
|
||||||
|
"pz_but" => "Résoudre une énigme",
|
||||||
"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" => "Parcours citoyen",
|
"title" => "Chasse au code Pange",
|
||||||
"home" => "Accueil"
|
"home" => "Accueil"
|
||||||
],
|
],
|
||||||
"footer" => [
|
"footer" => [
|
||||||
"text" => "Lycée Jean de Pange Sarreguemines<br><a href='https://forge.chapril.org/Antux/JeuPistesSarreguemines'>Code source</a>"
|
"text" => "Lycée Jean de Pange Sarreguemines<br><a href='https://forge.chapril.org/antux18/ChasseTresorPange'>Code source</a>"
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
?>
|
?>
|
@ -1,9 +0,0 @@
|
|||||||
<?php
|
|
||||||
$pzorder = [
|
|
||||||
[7,4,3,2,5,8,9,6,10,1],
|
|
||||||
[10,6,8,5,2,7,4,3,9,1],
|
|
||||||
[5,2,7,4,3,6,8,10,9,1],
|
|
||||||
[3,6,8,10,9,4,7,5,2,1],
|
|
||||||
[9,6,10,4,7,8,5,3,2,1]
|
|
||||||
]
|
|
||||||
?>
|
|
@ -1,8 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once "require/base.php";
|
require_once "require/base.php";
|
||||||
|
|
||||||
$team_id = -1;
|
|
||||||
|
|
||||||
$database = new Database();
|
$database = new Database();
|
||||||
|
|
||||||
if (isset($_GET["team"])) {
|
if (isset($_GET["team"])) {
|
||||||
|
Loading…
Reference in New Issue
Block a user