Merge branch 'yann' into yoyo

This commit is contained in:
Yoan Guerin
2025-12-05 03:59:25 +01:00
14 changed files with 89 additions and 72 deletions

View File

@@ -1,10 +0,0 @@
{% for q in questions %}
<div class="test" id="test1">
<h2>{{q.question}}</h2>
{% for a in q.answer%}
<label class="ans">{{a.answer}}<input id="tgl{{a.nb}}{{q.nb}}" type="checkbox" onclick=""></input></label><br>
{% endfor %}
<button class="ans" id="sub1" onclick="tog()">sub</button>
<p class="ans" id="answer1"><br></p><br>
</div>
{% endfor %}

View File

@@ -1,28 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Nuit de l'info quiz</title>
<link href="test.css" rel="stylesheet">
<link href="logo_n2i_color_moon.svg" rel="icon">
<script src="test.js"></script>
</head>
<body>
<a href="test.html"><img class="logo" src="logo_n2i_color_moon.svg"></a>
<h1 id="txt">page du quiz</h1>
<button id="strt" onclick="startQuiz()">Start Quiz!</button>
<div class="test" id="test1">
<h2>Question</h2>
<label class="ans">answer 1<input id="tgl11" type="checkbox" onclick=""></input></label><br>
<label class="ans">answer 2<input id="tgl21" type="checkbox" onclick=""></input></label><br>
<button class="ans" id="sub1" onclick="tog()">sub</button>
<p class="ans" id="answer1"><br></p><br>
</div>
<div class="test" id="test2">
<h2>Question</h2>
<label class="ans">answer 1<input id="tgl12" type="checkbox" onclick=""></input></label><br>
<label class="ans">answer 2<input id="tgl22" type="checkbox" onclick=""></input></label><br>
<button class="ans" onclick="tog()">sub</button>
<p class="ans" id="answer2"><br></p><br>
</div>
</body>
</html>

View File

@@ -1,18 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Nuit de l'info tkt</title>
<link href="test.css" rel="stylesheet">
<link href="logo_n2i_color_moon.svg" rel="icon">
<script src="test.js"></script>
</head>
<body>
<a href="test.html"><img class="logo" src="logo_n2i_color_moon.svg"></a>
<h1 id="demo">Nuit de l'Info</h1>
<p>hello world!</p>
<a href="quiz.html"><button>useless button</button></a>
<a href="https://google.com"><button type = "button">Google</button></a>
</body>
</html>

View File

View File

@@ -1,4 +1,4 @@
from flask import Flask, jsonify, request from flask import Flask, jsonify, request, render_template
import json import json
import os import os
@@ -36,6 +36,12 @@ def get_leaderboard():
leaderboard_sorted = sorted(leaderboard, key=lambda x: x['score'], reverse=True) leaderboard_sorted = sorted(leaderboard, key=lambda x: x['score'], reverse=True)
return jsonify({'leaderboard': leaderboard_sorted}) 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__': if __name__ == '__main__':
app.run(debug=True, port=8080) app.run(debug=True, port=8080)

View File

@@ -1,10 +1 @@
[ []
{
"name": "Alice",
"score": 100
},
{
"name": "salut",
"score": 30
}
]

View File

@@ -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"
}
]
}
]
}

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -5,18 +5,27 @@ function test()
document.getElementById("demo").innerHTML = "Title!"; document.getElementById("demo").innerHTML = "Title!";
} }
var nextquestion; var nextquestion;
function startQuiz() var nbQuestion;
function startQuiz(j)
{ {
nextquestion = 1; nextquestion = 1;
nbQuestion = j;
document.getElementById("test1").style.display = "block"; document.getElementById("test1").style.display = "block";
document.getElementById("strt").disabled = "true"; document.getElementById("strt").disabled = "true";
} }
function tog() function tog(j)
{ {
var chk1 = document.getElementById("tgl1"+nextquestion)
var chk2 = document.getElementById("tgl2"+nextquestion) var chk = [];
if (chk1.checked==true && chk2.checked != true) var test = true
for (i=0;i<j;i++)
{
chk[i] = document.getElementById("tgl"+(i+1)+nextquestion);
test = test && String(chk[i].checked) == chk[i].getAttribute("attribut");
}
if (test)
{ {
document.getElementById("answer"+nextquestion).innerHTML = "correct"; document.getElementById("answer"+nextquestion).innerHTML = "correct";
document.getElementById("answer"+nextquestion).style.color = "#00ff00"; document.getElementById("answer"+nextquestion).style.color = "#00ff00";
@@ -30,7 +39,10 @@ function tog()
document.getElementById("tgl2"+nextquestion).disabled = "true"; document.getElementById("tgl2"+nextquestion).disabled = "true";
document.getElementById("sub1").disabled = "true"; document.getElementById("sub1").disabled = "true";
nextquestion = nextquestion + 1; nextquestion = nextquestion + 1;
if (nextquestion<=nbQuestion)
{
document.getElementById("test"+nextquestion).style.display = "block"; document.getElementById("test"+nextquestion).style.display = "block";
}
} }

View File

@@ -0,0 +1,10 @@
{% for q in questions.questions %}
<div class="test" id="test{{q.nb}}">
<h2>{{q.question}}</h2>
{% for a in q.answer%}
<label class="ans">{{a.answer}}<input id="tgl{{a.nb}}{{q.nb}}" attribut="{{a.correct}}" type="checkbox" onclick=""></input></label><br>
{% endfor %}
<button class="ans" id="sub{{q.nb}}" onclick="tog({{q.nbAnswer}})">sub</button>
<p class="ans" id="answer{{q.nb}}"><br></p><br>
</div>
{% endfor %}

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>Nuit de l'info quiz</title>
<link href="/static/quiz.css" rel="stylesheet">
<link href="/static/logo_n2i_color_moon.svg" rel="icon">
<script src="static/quizz.js"></script>
</head>
<body>
<a href="test.html"><img class="logo" src="static/logo_n2i_color_moon.svg"></a>
<h1 id="txt">page du quiz</h1>
<button id="strt" onclick="startQuiz({{questions.nbQuestion}})">Start Quiz!</button>
{% include 'question.html' %}
</body>
</html>