Salut ,je suis vraiment fatiguée
J'essaye de créer un qcm avec java script à chaque fois que je croit que mon code fonctionne
je trouve un nouveau problème.Maintenant j'ai un problème dans le chrono.Bon voici mon code je ne sais pas comment décrire mon problème
Modifié par doucement (04 Apr 2018 - 17:37)
J'essaye de créer un qcm avec java script à chaque fois que je croit que mon code fonctionne
je trouve un nouveau problème.Maintenant j'ai un problème dans le chrono.Bon voici mon code je ne sais pas comment décrire mon problème
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="./SPORT_files/QCCM.css">
<title>SPORT</title>
</head>
<body>
<div id="frame001">
<div id="text001">
<h2>SPORT</h2>
<!--Question: <text id="number001" >0</text><br />
Score: <text id="score001">0</text><br/>-->
<!--<div id="ToutCrono">
Temps:<text id="Crono"></text><br/>
</div>-->
<p id="coeur">
<!--<img src="coeur11.png" id="coeur1">
<img src="coeur11.png" id="coeur2">
<img src="coeur11.png" id="coeur3">-->
</p>
<p id="gameOver"></p>
<div id="do"></div>
<!--<hr />-->
<div id="message001"></div><br>
</div>
<div id="text002">
<div id="question001"></div>
<div id="option001"></div>
<div id="option002"></div>
<div id="option003"></div>
<div id="option004"></div>
<div id="answer001"></div>
<div id="text001">
<div id="disappear001"><button class="buttons001" id="begin" onclick="e();rr1();begin001();">Begin</button></div>
</div>
<div id="next001"></div>
</div>
</div>
<script>
function e(){
document.getElementById("coeur").innerHTML=" <div id='img'><img src='coeur11.png' id='coeur1'><img src='coeur11.png' id='coeur2'> <img src='coeur11.png' id='coeur3'> </div><div id='ToutCrono'>Temps:<text id='Crono'></text><br/></div><div id='QU'>Question: <text id='number001' >0</text></div><br /><div id='Score'>Score: <text id='score001'>0</text></div><br/>";
}
var q = [ "Où eurent lieu les Jeux Olympiques de 1980 ? <br /><br />","Quel sport exerçait le regretté Gilles Villeneuve ? <br /><br />",
"Dans quel sport s'est illustré le légendaire Babe Ruth ? <br /><br />","Que signifie la lettre 'C' que l'on retrouve sur le chandail d'un des joueurs de chaque équipe de hockey ? <br /><br />","Comment s'appelait l'équipe de Québec dans la LNH ? <br /><br />","De quel pays le boomerang est-il originaire ?<br /><br />",
"De quel animal a-t-on besoin pour faire du polo ?<br /><br />","Quel est le trophée remis au champion des séries éliminatoires de LNH ? <br /><br />",
"Quel sport se joue sur glace avec un balai ? <br /><br />","Quel sport pratiquent les Harlem Globe Trotters ?<br /><br />"];
var a1 = ["<button class=buttons002 onclick=q1c()>À Calgary</button>",
"<button class=buttons002 onclick=q2c()>Course automobile</button>",
"<button class=buttons002 onclick=q3c()>Football américain</button>",
"<button class=buttons002 onclick=q4i()>Gardien de but</button>",
"<button class=buttons002 onclick=q5i()>Le Canadien</button>",
"<button class=buttons002 onclick=q6i()>Russie</button>",
"<button class=buttons002 onclick=q7i()>Cheval</button>",
"<button class=buttons002 onclick=q8i()>Coupe Grey</button>",
"<button class=buttons002 onclick=q9i()>Curling</button>",
"<button class=buttons002 onclick=q10i()>Basket-ball</button>"];
var a2 = ["<button class=buttons002 onclick=q1i()>À Athènes</button>",
"<button class=buttons002 onclick=q2i()>Hockey</button>",
"<button class=buttons002 onclick=q3i()>Lutte</button>",
"<button class=buttons002 onclick=q4c()>Coach</button>",
"<button class=buttons002 onclick=q5c()>Les Nordiques</button>",
"<button class=buttons002 onclick=q6c()>États-Unis</button>",
"<button class=buttons002 onclick=q7i()>Kangourou</button>",
"<button class=buttons002 onclick=q8i()>Coupe Stanley</button>",
"<button class=buttons002 onclick=q9i()>Ballon-balai</button>",
"<button class=buttons002 onclick=q10i()>Base-ball</button>"];
var a3 = ["<button class=buttons002 onclick=q1i()>À Moscou</button>",
"<button class=buttons002 onclick=q2i()>Soccer</button>",
"<button class=buttons002 onclick=q3i()>Base-ball</button>",
"<button class=buttons002 onclick=q4i()>Capitaine</button>",
"<button class=buttons002 onclick=q5i()>Les Grizzlys</button>",
"<button class=buttons002 onclick=q6i()>Australie</button>",
"<button class=buttons002 onclick=q7c()>Chien</button>",
"<button class=buttons002 onclick=q8c()>Coupe Memorial</button>",
"<button class=buttons002 onclick=q9i()>Les deux réponses sont bonnes</button>",
"<button class=buttons002 onclick=q10i()>Football américain</button>"];
var c = ["Correct", "Correct", "Correct", "Correct", "Correct", "Correct", "Correct", "Correct", "Correct", "Correct"];
var i = ["Incorrect", "Incorrect", "Incorrect", "Incorrect", "Incorrect", "Incorrect", "Incorrect", "Incorrect", "Incorrect", "Incorrect"];
var next2=0,next3=0,next4=0,next5=0,next6=0,next7=0,next8=0,next9=0,next10=0;
var n = 0;
n++;
var s = 0;
s++;
var r=0;
function begin001() {
disappear001.innerHTML = "";
message001.innerHTML = "";
question001.innerHTML = q[0];
option001.innerHTML = a1[0];
option002.innerHTML = a2[0];
option003.innerHTML = a3[0];
number001.innerHTML = 1;
}
function q1c() {
answer001.innerHTML = "<div id=green001>" + c[0] + "</div>";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<button class=buttons001 id=new1
onclick=deux()>Next</button>";
score001.innerHTML = s++;
next1+=1;
}
function q1i() {
answer001.innerHTML = "<div id=red001>" + i[0] + "</div>";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<button class=buttons001 id=new1 onclick=deux()
onmouseover=coeur()>Next</button>";
r++;
next1+=1;
}
function deux(){
{ new002();
rr2();
}
document.getElementById("Crono").innerHTML = "" ;
}
function new002() {
question001.innerHTML = q[1];
option001.innerHTML = a1[1];
option002.innerHTML = a2[1];
option003.innerHTML = a3[1];
next001.innerHTML = "";
answer001.innerHTML = "";
number001.innerHTML = 2;
// document.getElementById("Crono").innerHTML = "" ;
}
function q2c() {
answer001.innerHTML = "<div id=green001>" + c[1] + "</div>";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<button class=buttons001 onclick=trois()>Next</button>";
score001.innerHTML = s++;
next2+=1;
}
function q2i() {
answer001.innerHTML = "<div id=red001>" + i[1] + "</div>";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<button class=buttons001 onclick=trois() onmouseover=coeur()>Next</button>";
r++;
next2+=1;
}
function trois(){
new003();
rr3();
document.getElementById("Crono").innerHTML = "" ;
}
function new003() {
question001.innerHTML = q[2];
option001.innerHTML = a1[2];
option002.innerHTML = a2[2];
option003.innerHTML = a3[2];
next001.innerHTML = "";
answer001.innerHTML = "";
number001.innerHTML = 3;
//document.getElementById("Crono2").innerHTML = "" ;
}
function q3c() {
answer001.innerHTML = "<div id=green001>" + c[2] + "</div>";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<button class=buttons001 onclick=quatre()>Next</button>";
score001.innerHTML = s++;
next3+=1;
}
function q3i() {
answer001.innerHTML = "<div id=red001>" + i[2] + "</div>";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<button class=buttons001 onclick=quatre() onmouseover=coeur()>Next</button>";
r++;
next3+=1;
}
function quatre(){
new004();
rr4();
document.getElementById("Crono").innerHTML = "" ;
}
function new004() {
question001.innerHTML = q[3];
option001.innerHTML = a1[3];
option002.innerHTML = a2[3];
option003.innerHTML = a3[3];
next001.innerHTML = "";
answer001.innerHTML = "";
number001.innerHTML = 4;
//document.getElementById("Crono3").innerHTML = "" ;
}
function q4c() {
answer001.innerHTML = "<div id=green001>" + c[3] + "</div>";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<button class=buttons001 onclick=cinq() >Next</button>";
score001.innerHTML = s++;
next4+=1;
}
function q4i() {
answer001.innerHTML = "<div id=red001>" + i[3] + "</div>";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<button class=buttons001 onclick=cinq() onmouseover=coeur()>Next</button>";
r++;
next4+=1;
}
function cinq(){
new005();
rr5();
}
function new005() {
question001.innerHTML = q[4];
option001.innerHTML = a1[4];
option002.innerHTML = a2[4];
option003.innerHTML = a3[4];
next001.innerHTML = "";
answer001.innerHTML = "";
number001.innerHTML = 5;
// document.getElementById("Crono4").innerHTML = "" ;
}
function q5c() {
answer001.innerHTML = "<div id=green001>" + c[4] + "</div>";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<button class=buttons001 onclick=six()>Next</button>";
score001.innerHTML = s++;
next5+=1;
}
function q5i() {
answer001.innerHTML = "<div id=red001>" + i[4] + "</div>";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<button class=buttons001 onclick=six() onmouseover=coeur()>Next</button>";
r++;
next5+=1;
}
function six(){
new006();
rr6();
}
function new006() {
question001.innerHTML = q[5];
option001.innerHTML = a1[5];
option002.innerHTML = a2[5];
option003.innerHTML = a3[5];
next001.innerHTML = "";
answer001.innerHTML = "";
number001.innerHTML = 6;
//document.getElementById("Crono5").innerHTML = "" ;
}
function q6c() {
answer001.innerHTML = "<div id=green001>" + c[5] + "</div>";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<button class=buttons001 onclick=sept()>Next</button>";
score001.innerHTML = s++;
next6+=1;
}
function q6i() {
answer001.innerHTML = "<div id=red001>" + i[5] + "</div>";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<button class=buttons001 onclick=sept() onmouseover=coeur()>Next</button>";
r++;
next6+=1;
}
function sept(){
new007();
rr7();
}
function new007() {
question001.innerHTML = q[6];
option001.innerHTML = a1[6];
option002.innerHTML = a2[6];
option003.innerHTML = a3[6];
next001.innerHTML = "";
answer001.innerHTML = "";
number001.innerHTML = 7;
}
function q7c() {
answer001.innerHTML = "<div id=green001>" + c[6] + "</div>";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<button class=buttons001 onclick=huit()>Next</button>";
score001.innerHTML = s++;
next7+=1;
}
function q7i() {
answer001.innerHTML = "<div id=red001>" + i[6] + "</div>";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<button class=buttons001 onclick=huit() onmouseover=coeur()>Next</button>";
r++;
next7+=1;
}
function huit(){
new008();
rr8();
}
function new008() {
question001.innerHTML = q[7];
option001.innerHTML = a1[7];
option002.innerHTML = a2[7];
option003.innerHTML = a3[7];
next001.innerHTML = "";
answer001.innerHTML = "";
number001.innerHTML = 8;
}
function q8c() {
answer001.innerHTML = "<div id=green001>" + c[7] + "</div>";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<button class=buttons001 onclick=neuf()>Next</button>";
score001.innerHTML = s++;
next8+=1;
}
function q8i() {
answer001.innerHTML = "<div id=red001>" + i[7] + "</div>";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<button class=buttons001 onclick=neuf() onmouseover=coeur()>Next</button>";
r++;
next8+=1;
}
function neuf(){
new009();
rr9();
}
function new009() {
question001.innerHTML = q[8];
option001.innerHTML = a1[8];
option002.innerHTML = a2[8];
option003.innerHTML = a3[8];
next001.innerHTML = "";
answer001.innerHTML = "";
number001.innerHTML = 9;
}
function q9c() {
answer001.innerHTML = "<div id=green001>" + c[8] + "</div>";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<button class=buttons001 onclick=dix()>Next</button>";
score001.innerHTML = s++;
next9+=1;
}
function q9i() {
answer001.innerHTML = "<div id=red001>" + i[8] + "</div>";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<button class=buttons001 onclick=dix() onmouseover=coeur()>Next</button>";
r++;
next9+=1;
}
function dix(){
new010();
rr10();
}
function new010() {
question001.innerHTML = q[9];
option001.innerHTML = a1[9];
option002.innerHTML = a2[9];
option003.innerHTML = a3[9];
next001.innerHTML = "";
answer001.innerHTML = "";
number001.innerHTML = 10;
}
function q10c() {
answer001.innerHTML = "<div id=green001>" + c[9] + "</div>";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<button class=buttons001 onclick=end001() >next</button>";
score001.innerHTML = s++;
//next10+=1;
}
function q10i() {
answer001.innerHTML = "<div id=red001>" + i[9] + "</div>";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<button class=buttons001 onclick=end001() onmouseover=coeur()>next</button>";
r++;//si groupe veut pas repeter alors-->remplacer end001() par lien des cathégiries
// next10+=1;
}
function end001() {
message001.innerHTML = "End of Quiz.";
question001.innerHTML = "";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
next001.innerHTML = "<div id=text001>" + "<button class=buttons001 onclick=endOfQuiz()>END OF QUIZ</button>" + "</div>";
answer001.innerHTML = "";
}
function endOfQuiz(){
next001.innerHTML="<div id=text001>" +"<button class=buttons001 onclick=repeat001()>Repeat</button>" + "<div>";
}
function repeat001() {
location.reload();
}
function coeur(){
if(r==1){
v_div_parent = document.getElementById("img");
v_div_enfant1 = document.getElementById("coeur1");
v_div_parent.removeChild(v_div_enfant1);
}
else if(r==2){
v_div_parent = document.getElementById("img");
v_div_enfant1 = document.getElementById("coeur2");
v_div_parent.removeChild(v_div_enfant1);
}
else if(r==3){
v_div_parent = document.getElementById("img");
v_div_enfant1 = document.getElementById("coeur3");
v_div_parent.removeChild(v_div_enfant1);
gameOver.innerHTML="GAME OVER";
question001.innerHTML = "";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
answer001.innerHTML = "";
next001.innerHTML="<a href='page22.html'>"+"<button class=buttons001 onclick=GameOver()>GAME OVER</button>"+"</a>";
}
}
function rr1(){
if(next2==1) {
return;}
else {
setTimeout(rr2,7000);
var cpt= 5;
timer = setInterval(function(){
if(cpt>0 &number001.innerHTML ==1)
{
// décrémente le compteur
document.getElementById("Crono").innerHTML = cpt ;
--cpt;
}
else if(cpt<=0 &number001.innerHTML ==1)
{
document.getElementById("Crono").innerHTML = "" ;
new002();
clearInterval(timer);
}
}, 1000);
}
}
function rr2(){
if(next3==1) {return;}
else{
var cpt= 5;
setTimeout(rr3,7000);
timer = setInterval(function(){
if(cpt>0 & number001.innerHTML ==2)
{
// décrémente le compteur
//document.getElementById("Crono2").innerHTML = cpt2 ;
document.getElementById("Crono").innerHTML = cpt ;
--cpt;
}
else if(cpt<=0 & number001.innerHTML ==2)
{
//document.getElementById("Crono2").innerHTML = "0" ;
document.getElementById("Crono").innerHTML = "" ;
new003();
clearInterval(timer);
}
}, 1000);
}
}
function rr3(){
if(next4==1) {return;}
else{
var cpt3 = 5;
//setTimeout(rr4,7000);
timer = setInterval(function(){
if(cpt3>0 & number001.innerHTML ==3)
{
// décrémente le compteur
//document.getElementById("Crono3").innerHTML = cpt ;
document.getElementById("Crono").innerHTML = cpt3 ;
--cpt3;
}
else if(cpt3<=0 & number001.innerHTML ==3)
{
//document.getElementById("Crono3").innerHTML = "0" ;
document.getElementById("Crono").innerHTML = "" ;
new004();
clearInterval(timer);
}//setTimeout(rr4,3000);
}, 1000);
}
}
function rr4(){
if(next5==1) {return;}
else{
var cpt = 5;
setTimeout(rr5,7000);
timer = setInterval(function(){
if(cpt>0 & number001.innerHTML ==4)
{
// décrémente le compteur
document.getElementById("Crono").innerHTML = cpt ;
// document.getElementById("Crono3").innerHTML = "" ;
--cpt;
}
else if(cpt<=0 & number001.innerHTML ==4)
{
document.getElementById("Crono").innerHTML = "0" ;
//document.getElementById("Crono3").innerHTML = "" ;
new005();
clearInterval(timer);
}//setTimeout(rr5,3000);
}, 1000);
}
}
function rr5(){
if(next6==1) {return;}
else{
var cpt = 5;
setTimeout(rr6,7000);
timer = setInterval(function(){
if(cpt>0 & number001.innerHTML ==5)
{
// décrémente le compteur
document.getElementById("Crono").innerHTML = cpt ;
//document.getElementById("Crono4").innerHTML = "" ;
--cpt;
}
else if(cpt<=0 & number001.innerHTML ==5)
{
document.getElementById("Crono").innerHTML = "0" ;
//document.getElementById("Crono4").innerHTML = "" ;
new006();
clearInterval(timer);
}
}, 1000);
}
}
function rr6(){
if(next7==1) {return;}
else{
var cpt = 5;
setTimeout(rr7,7000);
timer = setInterval(function(){
if(cpt>0 & number001.innerHTML ==6)
{
// décrémente le compteur
document.getElementById("Crono").innerHTML = cpt ;
//document.getElementById("Crono").innerHTML = "" ;
--cpt;
}
else if(cpt<=0 & number001.innerHTML ==6)
{
document.getElementById("Crono").innerHTML = "0" ;
// document.getElementById("Crono").innerHTML = "" ;
new007();
clearInterval(timer);
}
}, 1000);
}
}
function rr7(){
if(next8==1) {return;}
else{
var cpt = 5;
setTimeout(rr8,7000);
timer = setInterval(function(){
if(cpt>0 & number001.innerHTML ==7)
{
// décrémente le compteur
document.getElementById("Crono").innerHTML = cpt ;
//document.getElementById("Crono").innerHTML = "" ;
--cpt;
}
else if(cpt<=0 & number001.innerHTML ==7)
{
document.getElementById("Crono").innerHTML = "0" ;
//document.getElementById("Crono").innerHTML = "" ;
new008();
clearInterval(timer);
}
}, 1000);
}
}
function rr8(){
if(next9==1) {return;}
else{
var cpt = 5;
setTimeout(rr9,7000);
timer = setInterval(function(){
if(cpt>0 & number001.innerHTML ==8)
{
// décrémente le compteur
document.getElementById("Crono").innerHTML = cpt ;
// document.getElementById("Crono").innerHTML = "" ;
--cpt;
}
else if(cpt<=0 & number001.innerHTML ==8)
{
document.getElementById("Crono").innerHTML = "0" ;
//document.getElementById("Crono").innerHTML = "" ;
new009();
clearInterval(timer);
}
}, 1000);
}
}
function rr9(){
if(next10==1) {return;}
else{
var cpt = 5;
setTimeout(rr10,7000);
timer = setInterval(function(){
if(cpt>0 & number001.innerHTML ==9)
{
// décrémente le compteur
document.getElementById("Crono").innerHTML = cpt ;
//document.getElementById("Crono").innerHTML = "" ;
--cpt;
}
else if(cpt<=0 & number001.innerHTML ==9)
{
document.getElementById("Crono").innerHTML = "0" ;
//document.getElementById("Crono").innerHTML = "" ;
new010();
clearInterval(timer);
}
}, 1000);
}
}
function rr10(){
var cpt = 5;
setTimeout(GameOver,7000);
timer = setInterval(function(){
if(cpt>0 & number001.innerHTML ==10)
{
// décrémente le compteur
document.getElementById("Crono2").innerHTML = cpt ;
document.getElementById("Crono").innerHTML = "" ;
--cpt;
}
else if(cpt<=0 & number001.innerHTML ==10)
{
document.getElementById("Crono2").innerHTML = "0" ;
document.getElementById("Crono").innerHTML = "" ;
GameOver();
clearInterval(timer);
}
}, 1000);
}
function GameOver() {
gameOver.innerHTML="GAME OVER";
question001.innerHTML = "";
option001.innerHTML = "";
option002.innerHTML = "";
option003.innerHTML = "";
answer001.innerHTML = "";
next001.innerHTML="<a href='page22.html'>"+"<button class=buttons001 >GAME OVER</button>"+"</a>";
img.innerHtml="";
}
</script>
</body></html>
Modifié par doucement (04 Apr 2018 - 17:37)