Fausto Busuito
commited on
Commit
•
66efcf5
1
Parent(s):
27200ef
Application changes
Browse files- app/static/script.js +7 -2
app/static/script.js
CHANGED
@@ -136,7 +136,11 @@ document.getElementById('end-session').addEventListener('click', () => {
|
|
136 |
|
137 |
// Colonna risposta corretta
|
138 |
const correctAnswerCell = document.createElement('td');
|
139 |
-
const correctAnswersText = question.correct.map(
|
|
|
|
|
|
|
|
|
140 |
correctAnswerCell.innerText = correctAnswersText;
|
141 |
correctAnswerCell.style.border = '1px solid #ddd';
|
142 |
correctAnswerCell.style.padding = '10px';
|
@@ -150,7 +154,7 @@ document.getElementById('end-session').addEventListener('click', () => {
|
|
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';
|
@@ -186,6 +190,7 @@ document.getElementById('end-session').addEventListener('click', () => {
|
|
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';
|
|
|
136 |
|
137 |
// Colonna risposta corretta
|
138 |
const correctAnswerCell = document.createElement('td');
|
139 |
+
const correctAnswersText = question.correct.map(letter => {
|
140 |
+
// Converte la lettera in opzione
|
141 |
+
const optionIndex = letter.charCodeAt(0) - 65; // A = 0, B = 1, C = 2, ...
|
142 |
+
return question.options[optionIndex];
|
143 |
+
}).join(', ');
|
144 |
correctAnswerCell.innerText = correctAnswersText;
|
145 |
correctAnswerCell.style.border = '1px solid #ddd';
|
146 |
correctAnswerCell.style.padding = '10px';
|
|
|
154 |
statusCell.style.color = 'orange';
|
155 |
} else {
|
156 |
// Confronto corretto per risposte multiple (controllo che le risposte dell'utente corrispondano alle risposte corrette)
|
157 |
+
const isCorrect = JSON.stringify(userAnswers[index].sort()) === JSON.stringify(question.correct.sort().map(letter => letter.charCodeAt(0) - 65));
|
158 |
if (isCorrect) {
|
159 |
statusCell.innerText = 'Correct';
|
160 |
statusCell.style.color = 'green';
|
|
|
190 |
|
191 |
|
192 |
|
193 |
+
|
194 |
document.getElementById('restart').addEventListener('click', () => {
|
195 |
document.getElementById('results-container').style.display = 'none';
|
196 |
document.getElementById('file-selection').style.display = 'block';
|