From 6f67a7def345b990057bc657bd35233f3eff4047 Mon Sep 17 00:00:00 2001 From: romaing Date: Thu, 21 Aug 2025 12:14:39 +0200 Subject: [PATCH 1/4] cleaned ReadMe --- ReadMe.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ReadMe.md b/ReadMe.md index f4255bb..5fec79e 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,18 +1,17 @@ # QuestionsPourUnChampignon -## Auteur : Lucas Hureaux -### Ce projet est un quiz. Le but : répondre à toutes les questions. Plus de détails dans les instructions du quiz situés dans le menu principal. +**Auteur :** [Lucas Hureaux](https://github.com/LucBlocker01) -## Instructions : +Ce projet est un quiz. Le but : répondre à toutes les questions. Plus de détails dans les instructions du quiz situés dans le menu principal. -### 1. Si ce n'est pas déjà fait, télécharger PHP 8.1 au minimum (je ne sais pas si les versions antérieurs vont fonctionner pour ce projet). Des tutos sur Internet vous aiderons là-dessus. +## Instructions : -### 2. Ouvrir le répertoire principal du projet (le dossier dans laquelle se trouve ce fichier readme) et ouvrir la boîte de commande Powershell en faisant clic droit + shift et sélectionner "Ouvrir la fenêtre Powershell ici". +1. Si ce n'est pas déjà fait, télécharger PHP 8.1 au minimum (je ne sais pas si les versions antérieurs vont fonctionner pour ce projet). Des tutos sur Internet vous aiderons là-dessus. -### 3. Taper la commande suivante : +2. Ouvrir le répertoire principal du projet (le dossier dans laquelle se trouve ce fichier readme) et ouvrir la boîte de commande Powershell en faisant clic droit + shift et sélectionner "Ouvrir la fenêtre Powershell ici". -```php -S localhost:8000``` +3. Taper la commande suivante : `php -S localhost:8000` -### 4. Ouvrir un navigateur web et taper dans la boîte URL "[localhost:8000/public/index.html](http://localhost:8000/public/index.html)" +4. Ouvrir un navigateur web et taper dans la boîte URL : [localhost:8000/public/index.html](http://localhost:8000/public/index.html) -### 5. Suivez les instructions en cliquant sur "Instructions" dans le menu principal \ No newline at end of file +5. Suivez les instructions en cliquant sur "Instructions" dans le menu principal From d3c50bc21fa0bbcc9d5fb2dd20186e8f23f176cd Mon Sep 17 00:00:00 2001 From: romaing Date: Thu, 21 Aug 2025 12:23:06 +0200 Subject: [PATCH 2/4] moved quizCreator.php in public and updated ReadMe to expose only public --- ReadMe.md | 2 +- public/js/utils.js | 2 +- public/quizCreator.php | 7 +++++++ src/classes/Question.php | 2 +- src/classes/Quiz.php | 4 ++-- src/questionGenerator.php | 4 ++-- src/quizCreator.php | 7 ------- 7 files changed, 14 insertions(+), 14 deletions(-) create mode 100644 public/quizCreator.php delete mode 100644 src/quizCreator.php diff --git a/ReadMe.md b/ReadMe.md index 5fec79e..9d34445 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -10,7 +10,7 @@ Ce projet est un quiz. Le but : répondre à toutes les questions. Plus de déta 2. Ouvrir le répertoire principal du projet (le dossier dans laquelle se trouve ce fichier readme) et ouvrir la boîte de commande Powershell en faisant clic droit + shift et sélectionner "Ouvrir la fenêtre Powershell ici". -3. Taper la commande suivante : `php -S localhost:8000` +3. Taper la commande suivante : `php -S localhost:8000 -t public` 4. Ouvrir un navigateur web et taper dans la boîte URL : [localhost:8000/public/index.html](http://localhost:8000/public/index.html) diff --git a/public/js/utils.js b/public/js/utils.js index 9c504fd..f770f27 100644 --- a/public/js/utils.js +++ b/public/js/utils.js @@ -15,7 +15,7 @@ async function quizFetcher() { break; } localStorage.setItem("totalLives", lives) - response = await fetch("http://localhost:8000/src/quizCreator.php", { + response = await fetch("/quizCreator.php", { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" diff --git a/public/quizCreator.php b/public/quizCreator.php new file mode 100644 index 0000000..2d11116 --- /dev/null +++ b/public/quizCreator.php @@ -0,0 +1,7 @@ + $this->correctAnswer ]; } -} \ No newline at end of file +} diff --git a/src/classes/Quiz.php b/src/classes/Quiz.php index 98d5162..0f18964 100644 --- a/src/classes/Quiz.php +++ b/src/classes/Quiz.php @@ -1,6 +1,6 @@ $this->difficulty ]; } -} \ No newline at end of file +} diff --git a/src/questionGenerator.php b/src/questionGenerator.php index c57e942..b0b73a3 100644 --- a/src/questionGenerator.php +++ b/src/questionGenerator.php @@ -4,7 +4,7 @@ header("Access-Control-Allow-Headers: Content-Type, Authorization"); header("Content-Type: application/json; charset=UTF-8"); -require "classes/Question.php"; +require __DIR__ . "/classes/Question.php"; function generateQuestions($difficulty) { switch ($difficulty) { @@ -296,4 +296,4 @@ function generateQuestions($difficulty) { return $questions; -} \ No newline at end of file +} diff --git a/src/quizCreator.php b/src/quizCreator.php deleted file mode 100644 index b18c3b6..0000000 --- a/src/quizCreator.php +++ /dev/null @@ -1,7 +0,0 @@ - Date: Thu, 21 Aug 2025 12:23:06 +0200 Subject: [PATCH 3/4] moved quizCreator.php in public and updated ReadMe to expose only public --- ReadMe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReadMe.md b/ReadMe.md index 9d34445..a5a358a 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -12,6 +12,6 @@ Ce projet est un quiz. Le but : répondre à toutes les questions. Plus de déta 3. Taper la commande suivante : `php -S localhost:8000 -t public` -4. Ouvrir un navigateur web et taper dans la boîte URL : [localhost:8000/public/index.html](http://localhost:8000/public/index.html) +4. Ouvrir un navigateur web et taper dans la boîte URL : [localhost:8000](http://localhost:8000) 5. Suivez les instructions en cliquant sur "Instructions" dans le menu principal From 82b8b25b6421057b0f979d10523155779378668f Mon Sep 17 00:00:00 2001 From: romaing Date: Thu, 21 Aug 2025 12:37:24 +0200 Subject: [PATCH 4/4] implemented template system --- public/index.html | 44 ---------------------------------- public/index.php | 38 ++++++++++++++++++++++++++++++ public/instructions.html | 51 ---------------------------------------- public/instructions.php | 45 +++++++++++++++++++++++++++++++++++ public/js/backToMenu.js | 2 +- public/js/index.js | 2 +- public/js/lose.js | 2 +- templates/layout.php | 30 +++++++++++++++++++++++ 8 files changed, 116 insertions(+), 98 deletions(-) delete mode 100644 public/index.html create mode 100644 public/index.php delete mode 100644 public/instructions.html create mode 100644 public/instructions.php create mode 100644 templates/layout.php diff --git a/public/index.html b/public/index.html deleted file mode 100644 index 4bb45df..0000000 --- a/public/index.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - QuestionsPourUnChampignon - - - - - - -
- -
-
QuestionsPourUnChampignon
-
- -
-
-
-
-
Choisir une difficulté
-
- - - - - - -
-
- - -
-
-
-
- - - - \ No newline at end of file diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..06de2fe --- /dev/null +++ b/public/index.php @@ -0,0 +1,38 @@ + + + + +
Choisir une difficulté
+
+ + + + + + +
+
+ + +
+ + + + - - - QuestionsPourUnChampignon - - - - - - -
- -
-
QuestionsPourUnChampignon
-
- -
-
-
-
-
Instructions
-
-
- QuestionsPourUnChampignon est un quiz composé de diverses questions, - certains plus difficiles que d'autres, auxquels vous devez répondre. -
-
- Vous pouvez sélectionner plusieurs niveaux de difficulté. Les niveaux les plus bas seront plus indulgents, offrant davantage de vies et moins de choix de réponses, tandis que les niveaux plus élevés sont bien plus exigeants. -
-
- Les niveaux élevés rajouteront des éléments supplémentaires comme un temps limité également. -
-
- Pour gagner un niveau, vous devez répondre à toutes les questions de celui-ci sans perdre toutes vos vies. -
-
- Serez-vous capables d'obtenir un score parfait? -
-
- -
-
-
- - - - diff --git a/public/instructions.php b/public/instructions.php new file mode 100644 index 0000000..ae8d6d5 --- /dev/null +++ b/public/instructions.php @@ -0,0 +1,45 @@ + + + + +
Instructions
+
+
+ QuestionsPourUnChampignon est un quiz composé de diverses questions, + certains plus difficiles que d'autres, auxquels vous devez répondre. +
+
+ Vous pouvez sélectionner plusieurs niveaux de difficulté. Les niveaux les plus bas seront plus indulgents, offrant davantage de vies et moins de choix de réponses, tandis que les niveaux plus élevés sont bien plus exigeants. +
+
+ Les niveaux élevés rajouteront des éléments supplémentaires comme un temps limité également. +
+
+ Pour gagner un niveau, vous devez répondre à toutes les questions de celui-ci sans perdre toutes vos vies. +
+
+ Serez-vous capables d'obtenir un score parfait? +
+
+ + + + + + + + QuestionsPourUnChampignon + + + + + +
+ +
+
QuestionsPourUnChampignon
+
+ +
+
+
+
+ +
+
+
+ + +