Fausto Busuito commited on
Commit
cdf7dae
·
1 Parent(s): 44f0b86

Application changes

Browse files
app/static/script.js CHANGED
@@ -28,6 +28,7 @@ function startQuiz() {
28
 
29
  function displayQuestion() {
30
  const question = questions[currentIndex];
 
31
  document.getElementById('question').innerText = question.question;
32
 
33
  const isMultipleChoice = /Select TWO|Choose two/i.test(question.question);
@@ -46,14 +47,12 @@ function displayQuestion() {
46
 
47
  input.addEventListener('change', () => {
48
  if (isMultipleChoice) {
49
- // Add or remove the answer for multiple choice
50
  if (input.checked) {
51
  userAnswers[currentIndex].push(i);
52
  } else {
53
  userAnswers[currentIndex] = userAnswers[currentIndex].filter(j => j !== i);
54
  }
55
  } else {
56
- // Set only one answer for single choice
57
  userAnswers[currentIndex] = [i];
58
  }
59
  });
@@ -71,6 +70,7 @@ function displayQuestion() {
71
  }
72
 
73
 
 
74
  function selectAnswer(optionIndex) {
75
  const currentAnswers = userAnswers[currentIndex];
76
  if (currentAnswers.includes(optionIndex)) {
 
28
 
29
  function displayQuestion() {
30
  const question = questions[currentIndex];
31
+ document.getElementById('question-number').innerText = `Question ${currentIndex + 1} of ${questions.length}`;
32
  document.getElementById('question').innerText = question.question;
33
 
34
  const isMultipleChoice = /Select TWO|Choose two/i.test(question.question);
 
47
 
48
  input.addEventListener('change', () => {
49
  if (isMultipleChoice) {
 
50
  if (input.checked) {
51
  userAnswers[currentIndex].push(i);
52
  } else {
53
  userAnswers[currentIndex] = userAnswers[currentIndex].filter(j => j !== i);
54
  }
55
  } else {
 
56
  userAnswers[currentIndex] = [i];
57
  }
58
  });
 
70
  }
71
 
72
 
73
+
74
  function selectAnswer(optionIndex) {
75
  const currentAnswers = userAnswers[currentIndex];
76
  if (currentAnswers.includes(optionIndex)) {
app/static/style.css CHANGED
@@ -26,3 +26,15 @@ label {
26
  font-size: 16px;
27
  cursor: pointer;
28
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  font-size: 16px;
27
  cursor: pointer;
28
  }
29
+
30
+ #navigation {
31
+ display: flex;
32
+ justify-content: space-between;
33
+ margin-top: 20px;
34
+ }
35
+
36
+ #navigation button {
37
+ padding: 10px 15px;
38
+ font-size: 16px;
39
+ cursor: pointer;
40
+ }
app/templates/index.html CHANGED
@@ -27,13 +27,15 @@
27
  <div id="navigation">
28
  <button id="prev">Previous</button>
29
  <button id="next">Next</button>
 
30
  </div>
31
- <button id="end-session">End Session</button>
32
  </div>
33
  </div>
 
34
  <div id="results-container" style="display: none;">
35
  <h2>Quiz Results</h2>
36
  <p id="score"></p>
 
37
  </div>
38
  </div>
39
  <script src="/static/script.js"></script>
 
27
  <div id="navigation">
28
  <button id="prev">Previous</button>
29
  <button id="next">Next</button>
30
+ <button id="end-session">End Session</button>
31
  </div>
 
32
  </div>
33
  </div>
34
+ <h2 id="question-number"></h2>
35
  <div id="results-container" style="display: none;">
36
  <h2>Quiz Results</h2>
37
  <p id="score"></p>
38
+ <button id="restart">Return to Start</button>
39
  </div>
40
  </div>
41
  <script src="/static/script.js"></script>