Fausto Busuito commited on
Commit
27200ef
1 Parent(s): 528f8fc

Application changes

Browse files
Files changed (1) hide show
  1. app/static/script.js +12 -8
app/static/script.js CHANGED
@@ -74,6 +74,7 @@ function displayQuestion() {
74
 
75
 
76
 
 
77
  function selectAnswer(optionIndex) {
78
  const currentAnswers = userAnswers[currentIndex];
79
  if (currentAnswers.includes(optionIndex)) {
@@ -147,15 +148,17 @@ document.getElementById('end-session').addEventListener('click', () => {
147
  if (userAnswers[index].length === 0) {
148
  statusCell.innerText = 'Not answered';
149
  statusCell.style.color = 'orange';
150
- } else if (
151
- JSON.stringify(userAnswers[index].sort()) === JSON.stringify(question.correct.sort())
152
- ) {
153
- statusCell.innerText = 'Correct';
154
- statusCell.style.color = 'green';
155
- correctCount++;
156
  } else {
157
- statusCell.innerText = 'Incorrect';
158
- statusCell.style.color = 'red';
 
 
 
 
 
 
 
 
159
  }
160
  statusCell.style.border = '1px solid #ddd';
161
  statusCell.style.padding = '10px';
@@ -182,6 +185,7 @@ document.getElementById('end-session').addEventListener('click', () => {
182
 
183
 
184
 
 
185
  document.getElementById('restart').addEventListener('click', () => {
186
  document.getElementById('results-container').style.display = 'none';
187
  document.getElementById('file-selection').style.display = 'block';
 
74
 
75
 
76
 
77
+
78
  function selectAnswer(optionIndex) {
79
  const currentAnswers = userAnswers[currentIndex];
80
  if (currentAnswers.includes(optionIndex)) {
 
148
  if (userAnswers[index].length === 0) {
149
  statusCell.innerText = 'Not answered';
150
  statusCell.style.color = 'orange';
 
 
 
 
 
 
151
  } else {
152
+ // Confronto corretto per risposte multiple (controllo che le risposte dell'utente corrispondano alle risposte corrette)
153
+ const isCorrect = JSON.stringify(userAnswers[index].sort()) === JSON.stringify(question.correct.sort());
154
+ if (isCorrect) {
155
+ statusCell.innerText = 'Correct';
156
+ statusCell.style.color = 'green';
157
+ correctCount++;
158
+ } else {
159
+ statusCell.innerText = 'Incorrect';
160
+ statusCell.style.color = 'red';
161
+ }
162
  }
163
  statusCell.style.border = '1px solid #ddd';
164
  statusCell.style.padding = '10px';
 
185
 
186
 
187
 
188
+
189
  document.getElementById('restart').addEventListener('click', () => {
190
  document.getElementById('results-container').style.display = 'none';
191
  document.getElementById('file-selection').style.display = 'block';