diff --git a/Quiz/question.html b/Quiz/question.html deleted file mode 100644 index 64c1db9..0000000 --- a/Quiz/question.html +++ /dev/null @@ -1,10 +0,0 @@ -{% for q in questions %} -
-

{{q.question}}

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



-
-{% endfor %} \ No newline at end of file diff --git a/Quiz/quiz.html b/Quiz/quiz.html deleted file mode 100644 index 23bd702..0000000 --- a/Quiz/quiz.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - Nuit de l'info quiz - - - - - - -

page du quiz

- -
-

Question

-
-
- -



-
-
-

Question

-
-
- -



-
- - 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..79ab7f0 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('quiz.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..e92afa4 --- /dev/null +++ b/flask_base/data/quizz.json @@ -0,0 +1,39 @@ +{ + "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/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 75% rename from Quiz/test.js rename to flask_base/static/quizz.js index 009e425..5419352 100644 --- a/Quiz/test.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 +

{{q.question}}

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



+ +{% endfor %} diff --git a/flask_base/templates/quiz.html b/flask_base/templates/quiz.html new file mode 100644 index 0000000..1ba8d69 --- /dev/null +++ b/flask_base/templates/quiz.html @@ -0,0 +1,15 @@ + + + + Nuit de l'info quiz + + + + + + +

page du quiz

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