fix du quizz
This commit is contained in:
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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<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).style.color = "#00ff00";
|
||||
@@ -30,7 +39,10 @@ function tog()
|
||||
document.getElementById("tgl2"+nextquestion).disabled = "true";
|
||||
document.getElementById("sub1").disabled = "true";
|
||||
nextquestion = nextquestion + 1;
|
||||
if (nextquestion<=nbQuestion)
|
||||
{
|
||||
document.getElementById("test"+nextquestion).style.display = "block";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{% for q in questions %}
|
||||
<div class="test" id="test1">
|
||||
{% 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}}" 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 %}
|
||||
<button class="ans" id="sub1" onclick="tog()">sub</button>
|
||||
<p class="ans" id="answer1"><br></p><br>
|
||||
<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 %}
|
||||
{% endfor %}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<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()">Start Quiz!</button>
|
||||
<button id="strt" onclick="startQuiz({{questions.nbQuestion}})">Start Quiz!</button>
|
||||
{% include 'question.html' %}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user