Skip to content

Commit 62ff2bc

Browse files
authored
Add files via upload
1 parent edb77c8 commit 62ff2bc

File tree

4 files changed

+37
-26
lines changed

4 files changed

+37
-26
lines changed

quizz/EsiQuizzPNG.png

639 KB
Loading

quizz/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44

5-
<title>EsarQuizz</title>
5+
<title>EsiQuizz</title>
66
<link rel="stylesheet" href="styles.css">
77
<link rel="icon" href="EsarQuizzPNG.png">
88

@@ -21,7 +21,7 @@
2121
<div class="app">
2222

2323
<!-- <img src="EsarQuizzPNG.png" vertical-align: middle; width="50" height="50" > </img> -->
24-
<h1> EsarQuizz </h1>
24+
<h1> EsiQuizz </h1>
2525
<div class="quizz">
2626
<h2 id="question"> Questions ici </h2>
2727
<div id="answer-buttons">

quizz/script.js

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,23 @@ function showQuestion(){
8484
}
8585
};
8686

87+
for (let i = 0; i < questions[0].content.length; i++ ){
88+
var currentQuestion = document.getElementById(i);
89+
console.log(currentQuestion);
90+
if( i == currentQuestionIndex ){
91+
currentQuestion.style.width = "35px";
92+
currentQuestion.style.height = "35px";
93+
currentQuestion.style.borderRadius = "15px";
94+
currentQuestion.style.background = "#5b52bf";
95+
currentQuestion.style.color = "#FFF";
96+
currentQuestion.style.fontWeight = "bold";
97+
}else{
98+
currentQuestion.style.width = "30px";
99+
currentQuestion.style.height = "30px";
100+
currentQuestion.style.borderRadius = "12px";
101+
}
102+
}
103+
87104
renderMathInElement(document.body);
88105
if(answer.correct){
89106
button.dataset.correct = answer.correct;
@@ -111,33 +128,18 @@ function showIndex(){
111128
var number = i;
112129
index.setAttribute('id', number);
113130

114-
indexButton.addEventListener("click", goToIdex);
115-
116131

117132
let currentQuestion = questions[0].content[currentQuestionIndex];
118133
//console.log(currentQuestion + " " + currentQuestionIndex );
119134
indexButton.appendChild(index);
120135
}
121136
}
122137

123-
function colorIndex(){
124-
for(let i=0; i <= questions[0].content.length ; i++ ){
125-
var index = document.getElementById('0');
126-
//console.log(index.id);
127-
if (tableVerite[i]=-1){index.style.backgroundColor = "#7e74e2";}
128-
//else{index.style.backgroundColor = "#FAF";}
129-
//data-answer-btn = "btn-" + i;
130-
}
131-
//console.log(tableVerite);
132-
133-
}
134-
135-
function goToIdex(event){
136-
const clickedButton = event.target
137-
//console.log(clickedButton);
138-
var questionDemandee = parseInt(clickedButton.dataset.index, 10);
139-
currentQuestionIndex = questionDemandee -1
140-
showQuestion();
138+
function colorIndex(index){
139+
var button = document.getElementById(index);
140+
if (tableVerite[index]== -1 ){button.style.backgroundColor = "#7e74e2";}
141+
if (tableVerite[index]== 0 ){button.style.backgroundColor = "#ea9a9a";}
142+
if (tableVerite[index]== 1 ){button.style.backgroundColor = "#9AEABC";}
141143
}
142144

143145

@@ -164,13 +166,16 @@ function selectAnswer(e){
164166
const isCorrect = selectedBtn.dataset.correct === "true";
165167
if(isCorrect){
166168
selectedBtn.classList.add("correct");
167-
tableVerite[currentQuestionIndex]=1;
168-
console.log(tableVerite);
169+
tableVerite[currentQuestionIndex] = 1;
170+
console.log("correct " + tableVerite)
169171
score++;
170172
}else{
171173
selectedBtn.classList.add("incorrect");
172-
tableVerite[currentQuestionIndex]=0;
174+
tableVerite[currentQuestionIndex] = 0;
175+
console.log("incorrect " + tableVerite)
173176
}
177+
console.log("colorindex " + tableVerite)
178+
colorIndex(currentQuestionIndex);
174179
Array.from(answerButtons.children).forEach(button => {
175180
if(button.dataset.correct === "true"){
176181
button.classList.add("correct");
@@ -198,7 +203,6 @@ function handleNextButton(){
198203
currentQuestionIndex++;
199204
if(currentQuestionIndex < questions[0].content.length){
200205
showQuestion();
201-
colorIndex()
202206
}else{
203207
showScore();
204208
}
@@ -209,6 +213,11 @@ nextButton.addEventListener("click", ()=>{
209213
if(currentQuestionIndex < questions[0].content.length){
210214
handleNextButton();
211215
}else{
216+
for (let i=0; i<questions[0].content.length; i++){
217+
var button = document.getElementById(i);
218+
button.style.backgroundColor = "#7e74e2";
219+
}
220+
212221
startQuizz();
213222
}
214223
});

quizz/styles.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ body{
9393
transition : all 0.3s;
9494
text-align: center;
9595
transition : all 0.3s;
96+
cursor : pointer;
97+
font-weight: bold;
9698
}
9799

98100
.index:hover{

0 commit comments

Comments
 (0)