fix du quizz
This commit is contained in:
@@ -1,26 +1,39 @@
|
|||||||
[
|
{
|
||||||
|
"nbQuestion" : 2,
|
||||||
|
"questions" : [
|
||||||
{
|
{
|
||||||
"question" : "coucou",
|
"question" : "coucou",
|
||||||
"nb" : 1,
|
"nb" : 1,
|
||||||
|
"nbAnswer" : 2,
|
||||||
"answer" : [
|
"answer" : [
|
||||||
{
|
{
|
||||||
"answer" : "salut",
|
"answer" : "salut",
|
||||||
"nb" : 1
|
"nb" : 1,
|
||||||
|
"correct" : "true"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"answer" : "de",
|
||||||
|
"nb" : 2,
|
||||||
|
"correct" : "false"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"question" : "hello",
|
"question" : "hello",
|
||||||
"nb" : 2,
|
"nb" : 2,
|
||||||
|
"nbAnswer" : 2,
|
||||||
"answer" : [
|
"answer" : [
|
||||||
{
|
{
|
||||||
"answer" : "salut",
|
"answer" : "salut",
|
||||||
"nb" : 1
|
"nb" : 1,
|
||||||
|
"correct" : "false"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"answer" : "deux",
|
"answer" : "deux",
|
||||||
"nb" : 2
|
"nb" : 2,
|
||||||
|
"correct" : "true"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
}
|
||||||
@@ -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";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
{% for q in questions %}
|
{% for q in questions.questions %}
|
||||||
<div class="test" id="test1">
|
<div class="test" id="test{{q.nb}}">
|
||||||
<h2>{{q.question}}</h2>
|
<h2>{{q.question}}</h2>
|
||||||
{% for a in q.answer%}
|
{% for a in q.answer%}
|
||||||
<label class="ans">{{a.answer}}<input id="tgl{{a.nb}}{{q.nb}}" type="checkbox" onclick=""></input></label><br>
|
<label class="ans">{{a.answer}}<input id="tgl{{a.nb}}{{q.nb}}" attribut="{{a.correct}}" type="checkbox" onclick=""></input></label><br>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<button class="ans" id="sub1" onclick="tog()">sub</button>
|
<button class="ans" id="sub{{q.nb}}" onclick="tog({{q.nbAnswer}})">sub</button>
|
||||||
<p class="ans" id="answer1"><br></p><br>
|
<p class="ans" id="answer{{q.nb}}"><br></p><br>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<a href="test.html"><img class="logo" src="static/logo_n2i_color_moon.svg"></a>
|
<a href="test.html"><img class="logo" src="static/logo_n2i_color_moon.svg"></a>
|
||||||
<h1 id="txt">page du quiz</h1>
|
<h1 id="txt">page du quiz</h1>
|
||||||
<button id="strt" onclick="startQuiz()">Start Quiz!</button>
|
<button id="strt" onclick="startQuiz({{questions.nbQuestion}})">Start Quiz!</button>
|
||||||
{% include 'question.html' %}
|
{% include 'question.html' %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user