From 0a8136dfb5fd6ce8b71b133f97d17aa5d338c6db Mon Sep 17 00:00:00 2001 From: furtest Date: Fri, 5 Dec 2025 01:51:51 +0100 Subject: [PATCH 1/4] Start of the quizz on the backend --- Quiz/test.html | 18 ------------------ Quiz/test.php | 0 flask_base/app.py | 8 +++++++- flask_base/data/leaderboard.json | 11 +---------- flask_base/data/quizz.json | 12 ++++++++++++ .../static}/logo_n2i_color_moon.jpg | 0 .../static}/logo_n2i_color_moon.png | 0 .../static}/logo_n2i_color_moon.svg | 0 Quiz/test.css => flask_base/static/quiz.css | 0 Quiz/test.js => flask_base/static/quizz.js | 0 {Quiz => flask_base/templates}/question.html | 0 {Quiz => flask_base/templates}/quiz.html | 0 12 files changed, 20 insertions(+), 29 deletions(-) delete mode 100644 Quiz/test.html delete mode 100644 Quiz/test.php create mode 100644 flask_base/data/quizz.json rename {Quiz => flask_base/static}/logo_n2i_color_moon.jpg (100%) rename {Quiz => flask_base/static}/logo_n2i_color_moon.png (100%) rename {Quiz => flask_base/static}/logo_n2i_color_moon.svg (100%) rename Quiz/test.css => flask_base/static/quiz.css (100%) rename Quiz/test.js => flask_base/static/quizz.js (100%) rename {Quiz => flask_base/templates}/question.html (100%) rename {Quiz => flask_base/templates}/quiz.html (100%) diff --git a/Quiz/test.html b/Quiz/test.html deleted file mode 100644 index 451cff5..0000000 --- a/Quiz/test.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - Nuit de l'info tkt - - - - - - -

Nuit de l'Info

-

hello world!

- - - - - - \ No newline at end of file diff --git a/Quiz/test.php b/Quiz/test.php deleted file mode 100644 index e69de29..0000000 diff --git a/flask_base/app.py b/flask_base/app.py index fcfc691..b3b49a9 100644 --- a/flask_base/app.py +++ b/flask_base/app.py @@ -1,4 +1,4 @@ -from flask import Flask, jsonify, request +from flask import Flask, jsonify, request, render_template import json import os @@ -36,6 +36,12 @@ def get_leaderboard(): leaderboard_sorted = sorted(leaderboard, key=lambda x: x['score'], reverse=True) return jsonify({'leaderboard': leaderboard_sorted}) +@app.route('/questions') +def show_questions(): + with open('./data/quizz.json', 'r') as file: + questions = json.load(file) + return render_template('question.html', questions=questions) + if __name__ == '__main__': app.run(debug=True, port=8080) diff --git a/flask_base/data/leaderboard.json b/flask_base/data/leaderboard.json index a1e83b5..0637a08 100644 --- a/flask_base/data/leaderboard.json +++ b/flask_base/data/leaderboard.json @@ -1,10 +1 @@ -[ - { - "name": "Alice", - "score": 100 - }, - { - "name": "salut", - "score": 30 - } -] \ No newline at end of file +[] \ No newline at end of file diff --git a/flask_base/data/quizz.json b/flask_base/data/quizz.json new file mode 100644 index 0000000..79b2b49 --- /dev/null +++ b/flask_base/data/quizz.json @@ -0,0 +1,12 @@ +[ + { + "question" : "coucou", + "nb" : 1, + "answer" : [ + { + "answer" : "salut", + "nb" : 1 + } + ] + } +] diff --git a/Quiz/logo_n2i_color_moon.jpg b/flask_base/static/logo_n2i_color_moon.jpg similarity index 100% rename from Quiz/logo_n2i_color_moon.jpg rename to flask_base/static/logo_n2i_color_moon.jpg diff --git a/Quiz/logo_n2i_color_moon.png b/flask_base/static/logo_n2i_color_moon.png similarity index 100% rename from Quiz/logo_n2i_color_moon.png rename to flask_base/static/logo_n2i_color_moon.png diff --git a/Quiz/logo_n2i_color_moon.svg b/flask_base/static/logo_n2i_color_moon.svg similarity index 100% rename from Quiz/logo_n2i_color_moon.svg rename to flask_base/static/logo_n2i_color_moon.svg diff --git a/Quiz/test.css b/flask_base/static/quiz.css similarity index 100% rename from Quiz/test.css rename to flask_base/static/quiz.css diff --git a/Quiz/test.js b/flask_base/static/quizz.js similarity index 100% rename from Quiz/test.js rename to flask_base/static/quizz.js diff --git a/Quiz/question.html b/flask_base/templates/question.html similarity index 100% rename from Quiz/question.html rename to flask_base/templates/question.html diff --git a/Quiz/quiz.html b/flask_base/templates/quiz.html similarity index 100% rename from Quiz/quiz.html rename to flask_base/templates/quiz.html From 6dc6df60c689bf17b6d837530aaa7837e8772f5a Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 5 Dec 2025 02:11:00 +0100 Subject: [PATCH 2/4] inclusion question dans quiz --- flask_base/app.py | 2 +- flask_base/templates/quiz.html | 15 +-------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/flask_base/app.py b/flask_base/app.py index b3b49a9..79ab7f0 100644 --- a/flask_base/app.py +++ b/flask_base/app.py @@ -40,7 +40,7 @@ def get_leaderboard(): def show_questions(): with open('./data/quizz.json', 'r') as file: questions = json.load(file) - return render_template('question.html', questions=questions) + return render_template('quiz.html', questions=questions) if __name__ == '__main__': app.run(debug=True, port=8080) diff --git a/flask_base/templates/quiz.html b/flask_base/templates/quiz.html index 23bd702..dd5bbfd 100644 --- a/flask_base/templates/quiz.html +++ b/flask_base/templates/quiz.html @@ -10,19 +10,6 @@

page du quiz

-
-

Question

-
-
- -



-
-
-

Question

-
-
- -



-
+ {% include 'question.html' %} From 0a95a72cbb66696efb887aef5f2b433a915fe2e2 Mon Sep 17 00:00:00 2001 From: furtest Date: Fri, 5 Dec 2025 02:16:50 +0100 Subject: [PATCH 3/4] Ajoute les routes statiques pour le quizz --- flask_base/data/quizz.json | 14 ++++++++++++++ flask_base/templates/quiz.html | 8 ++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/flask_base/data/quizz.json b/flask_base/data/quizz.json index 79b2b49..1d8db8a 100644 --- a/flask_base/data/quizz.json +++ b/flask_base/data/quizz.json @@ -8,5 +8,19 @@ "nb" : 1 } ] + }, + { + "question" : "hello", + "nb" : 2, + "answer" : [ + { + "answer" : "salut", + "nb" : 1 + }, + { + "answer" : "deux", + "nb" : 2 + } + ] } ] diff --git a/flask_base/templates/quiz.html b/flask_base/templates/quiz.html index dd5bbfd..91d105e 100644 --- a/flask_base/templates/quiz.html +++ b/flask_base/templates/quiz.html @@ -2,12 +2,12 @@ Nuit de l'info quiz - - - + + + - +

page du quiz

{% include 'question.html' %} From 36edabe1daf0e24d8996fbd4a34d4ef8aecb2a03 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 5 Dec 2025 03:42:04 +0100 Subject: [PATCH 4/4] fix du quizz --- flask_base/data/quizz.json | 65 ++++++++++++++++++------------ flask_base/static/quizz.js | 22 +++++++--- flask_base/templates/question.html | 12 +++--- flask_base/templates/quiz.html | 2 +- 4 files changed, 63 insertions(+), 38 deletions(-) diff --git a/flask_base/data/quizz.json b/flask_base/data/quizz.json index 1d8db8a..e92afa4 100644 --- a/flask_base/data/quizz.json +++ b/flask_base/data/quizz.json @@ -1,26 +1,39 @@ -[ - { - "question" : "coucou", - "nb" : 1, - "answer" : [ - { - "answer" : "salut", - "nb" : 1 - } - ] - }, - { - "question" : "hello", - "nb" : 2, - "answer" : [ - { - "answer" : "salut", - "nb" : 1 - }, - { - "answer" : "deux", - "nb" : 2 - } - ] - } -] +{ + "nbQuestion" : 2, + "questions" : [ + { + "question" : "coucou", + "nb" : 1, + "nbAnswer" : 2, + "answer" : [ + { + "answer" : "salut", + "nb" : 1, + "correct" : "true" + }, + { + "answer" : "de", + "nb" : 2, + "correct" : "false" + } + ] + }, + { + "question" : "hello", + "nb" : 2, + "nbAnswer" : 2, + "answer" : [ + { + "answer" : "salut", + "nb" : 1, + "correct" : "false" + }, + { + "answer" : "deux", + "nb" : 2, + "correct" : "true" + } + ] + } + ] +} \ No newline at end of file diff --git a/flask_base/static/quizz.js b/flask_base/static/quizz.js index 009e425..5419352 100644 --- a/flask_base/static/quizz.js +++ b/flask_base/static/quizz.js @@ -5,18 +5,27 @@ function test() document.getElementById("demo").innerHTML = "Title!"; } var nextquestion; -function startQuiz() +var nbQuestion; +function startQuiz(j) { nextquestion = 1; + nbQuestion = j; document.getElementById("test1").style.display = "block"; document.getElementById("strt").disabled = "true"; } -function tog() +function tog(j) { - var chk1 = document.getElementById("tgl1"+nextquestion) - var chk2 = document.getElementById("tgl2"+nextquestion) - if (chk1.checked==true && chk2.checked != true) + + var chk = []; + var test = true + for (i=0;i +{% for q in questions.questions %} +

{{q.question}}

{% for a in q.answer%} -
+
{% endfor %} - -



+ +



-{% endfor %} \ No newline at end of file +{% endfor %} diff --git a/flask_base/templates/quiz.html b/flask_base/templates/quiz.html index 91d105e..1ba8d69 100644 --- a/flask_base/templates/quiz.html +++ b/flask_base/templates/quiz.html @@ -9,7 +9,7 @@

page du quiz

- + {% include 'question.html' %}