forked from antux18/ChasseTresorPange
Mise en place de la réponse du site au scan du QR code.
This commit is contained in:
parent
0dd6af01d5
commit
13fa1824da
18
answer.php
18
answer.php
@ -29,11 +29,27 @@
|
||||
}
|
||||
|
||||
else {
|
||||
// On enregistre la réussite dans la table :
|
||||
// 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");
|
||||
$stmt->bindValue(":puzzle_id", $art_id);
|
||||
$stmt->bindValue(":team_id", $team_id);
|
||||
$stmt->execute();
|
||||
|
||||
// Si ce n'est pas le cas, on enregistre :
|
||||
if (empty($stmt->fetch())) {
|
||||
$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->execute();
|
||||
}
|
||||
|
||||
$data = [
|
||||
"infos" => $article["infos"],
|
||||
"place" => $article["place"]
|
||||
];
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
header("Content-Type: application/json; charset=utf-8");
|
||||
echo json_encode($data);
|
||||
}
|
||||
}
|
||||
|
@ -20,9 +20,13 @@
|
||||
$this->pdo_teams = new PDO("sqlite:" . dirname(__FILE__) . $data_path . "teams.db");
|
||||
$this->pdo_teams->query('CREATE TABLE IF NOT EXISTS "teams" (
|
||||
"id" INTEGER NOT NULL UNIQUE,
|
||||
"solved_id" INTEGER[],
|
||||
PRIMARY KEY("id" AUTOINCREMENT)
|
||||
)');
|
||||
|
||||
$this->pdo_teams->query('CREATE TABLE IF NOT EXISTS "solved" (
|
||||
"puzzle_id" INTEGER NOT NULL,
|
||||
"team_id" INTEGER NOT NULL
|
||||
)');
|
||||
}
|
||||
|
||||
catch (PDOException $exception) {
|
||||
|
@ -14,11 +14,24 @@ if (lg == null) {
|
||||
}
|
||||
}
|
||||
|
||||
if (lg == "en") {
|
||||
var qr_error = "Sorry, wrong QR code, please try another one !";
|
||||
}
|
||||
|
||||
if (lg == "fr") {
|
||||
var qr_error = "Désolé, ce n'est pas le bon QR code, veuillez en essayer un autre !";
|
||||
}
|
||||
|
||||
export async function puzzleSolve(code, team_id, art_id) {
|
||||
try {
|
||||
const response = await fetch("/answer.php?lg=" + lg + "&team=" + team_id + "&code=" + code + "&id=" + art_id);
|
||||
const data = await response.text();
|
||||
console.log(data);
|
||||
if (data == 0) {
|
||||
alert(qr_error);
|
||||
}
|
||||
else {
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
|
Loading…
Reference in New Issue
Block a user