Fausto Busuito
commited on
Commit
•
fff0efe
1
Parent(s):
66efcf5
Application changes
Browse files- app/static/script.js +17 -8
app/static/script.js
CHANGED
@@ -98,6 +98,7 @@ document.getElementById('prev').addEventListener('click', () => {
|
|
98 |
document.getElementById('end-session').addEventListener('click', () => {
|
99 |
let correctCount = 0;
|
100 |
|
|
|
101 |
const resultsTable = document.createElement('table');
|
102 |
resultsTable.style.width = '100%';
|
103 |
resultsTable.style.borderCollapse = 'collapse';
|
@@ -136,15 +137,20 @@ document.getElementById('end-session').addEventListener('click', () => {
|
|
136 |
|
137 |
// Colonna risposta corretta
|
138 |
const correctAnswerCell = document.createElement('td');
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
|
|
|
|
|
|
145 |
correctAnswerCell.style.border = '1px solid #ddd';
|
146 |
correctAnswerCell.style.padding = '10px';
|
147 |
-
|
|
|
|
|
148 |
row.appendChild(correctAnswerCell);
|
149 |
|
150 |
// Colonna stato
|
@@ -175,11 +181,13 @@ document.getElementById('end-session').addEventListener('click', () => {
|
|
175 |
const score = (correctCount / questions.length) * 100;
|
176 |
|
177 |
// Mostra il punteggio
|
178 |
-
document.getElementById('score')
|
|
|
179 |
|
180 |
// Aggiungi la tabella ai risultati
|
181 |
const resultsContainer = document.getElementById('results-container');
|
182 |
resultsContainer.innerHTML = ''; // Pulisci i risultati precedenti
|
|
|
183 |
resultsContainer.appendChild(resultsTable);
|
184 |
|
185 |
// Mostra il contenitore dei risultati e nascondi il quiz
|
@@ -191,6 +199,7 @@ document.getElementById('end-session').addEventListener('click', () => {
|
|
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';
|
|
|
98 |
document.getElementById('end-session').addEventListener('click', () => {
|
99 |
let correctCount = 0;
|
100 |
|
101 |
+
// Crea la tabella dei risultati
|
102 |
const resultsTable = document.createElement('table');
|
103 |
resultsTable.style.width = '100%';
|
104 |
resultsTable.style.borderCollapse = 'collapse';
|
|
|
137 |
|
138 |
// Colonna risposta corretta
|
139 |
const correctAnswerCell = document.createElement('td');
|
140 |
+
if (userAnswers[index].length === 0) {
|
141 |
+
correctAnswerCell.innerText = 'No answer';
|
142 |
+
} else {
|
143 |
+
const correctAnswersText = question.correct.map(letter => {
|
144 |
+
const optionIndex = letter.charCodeAt(0) - 65; // A = 0, B = 1, C = 2, ...
|
145 |
+
return question.options[optionIndex];
|
146 |
+
}).join(', ');
|
147 |
+
correctAnswerCell.innerText = correctAnswersText;
|
148 |
+
}
|
149 |
correctAnswerCell.style.border = '1px solid #ddd';
|
150 |
correctAnswerCell.style.padding = '10px';
|
151 |
+
if (userAnswers[index].length > 0) {
|
152 |
+
correctAnswerCell.style.backgroundColor = '#d4edda'; // Verde chiaro per evidenziare la risposta corretta
|
153 |
+
}
|
154 |
row.appendChild(correctAnswerCell);
|
155 |
|
156 |
// Colonna stato
|
|
|
181 |
const score = (correctCount / questions.length) * 100;
|
182 |
|
183 |
// Mostra il punteggio
|
184 |
+
const scoreElement = document.getElementById('score');
|
185 |
+
scoreElement.innerText = `Your score: ${score.toFixed(2)}%`;
|
186 |
|
187 |
// Aggiungi la tabella ai risultati
|
188 |
const resultsContainer = document.getElementById('results-container');
|
189 |
resultsContainer.innerHTML = ''; // Pulisci i risultati precedenti
|
190 |
+
resultsContainer.appendChild(scoreElement);
|
191 |
resultsContainer.appendChild(resultsTable);
|
192 |
|
193 |
// Mostra il contenitore dei risultati e nascondi il quiz
|
|
|
199 |
|
200 |
|
201 |
|
202 |
+
|
203 |
document.getElementById('restart').addEventListener('click', () => {
|
204 |
document.getElementById('results-container').style.display = 'none';
|
205 |
document.getElementById('file-selection').style.display = 'block';
|