Fausto Busuito
commited on
Commit
·
b4859d5
1
Parent(s):
a8edac9
Application changes
Browse files- app/static/script.js +21 -20
- app/static/style.css +0 -9
app/static/script.js
CHANGED
@@ -223,39 +223,43 @@ document.getElementById('end-session').addEventListener('click', () => {
|
|
223 |
document.getElementById('quiz-container').style.display = 'none';
|
224 |
resultsContainer.style.display = 'block';
|
225 |
});
|
|
|
|
|
|
|
226 |
|
|
|
227 |
document.getElementById('restart').addEventListener('click', () => {
|
228 |
-
//
|
|
|
|
|
|
|
|
|
|
|
229 |
document.getElementById('results-container').style.display = 'none';
|
230 |
document.getElementById('quiz-container').style.display = 'block';
|
231 |
-
|
232 |
-
//
|
233 |
resetQuizState();
|
234 |
-
|
235 |
// Reset della selezione del file
|
236 |
-
document.getElementById('file-selector').value = ''; //
|
237 |
|
238 |
// Pulisce il contenuto dei risultati
|
239 |
document.getElementById('results-container').innerHTML = '';
|
240 |
-
|
241 |
// Ripristina la visualizzazione della prima domanda
|
242 |
loadQuestion();
|
243 |
});
|
244 |
|
245 |
-
// Funzione per reset
|
246 |
function resetQuizState() {
|
247 |
currentQuestionIndex = 0; // Ripristina l'indice della domanda
|
248 |
userAnswers = []; // Resetta le risposte dell'utente
|
|
|
249 |
timer = 0; // Resetta il timer
|
250 |
-
clearInterval(timerInterval); // Ferma qualsiasi intervallo di timer in corso
|
251 |
-
|
252 |
-
// Reset della visualizzazione delle risposte
|
253 |
-
document.getElementById('question-container').innerHTML = ''; // Pulisce la domanda
|
254 |
-
document.getElementById('answers-container').innerHTML = ''; // Pulisce le risposte
|
255 |
-
document.getElementById('timer').innerText = '00:00'; // Reset timer
|
256 |
}
|
257 |
|
258 |
-
// Funzione per caricare
|
259 |
function loadQuestion() {
|
260 |
if (questions.length > 0) {
|
261 |
const question = questions[currentQuestionIndex];
|
@@ -282,16 +286,14 @@ function loadQuestion() {
|
|
282 |
// Visualizza il numero di domanda
|
283 |
document.getElementById('question-number').innerText = `Question ${currentQuestionIndex + 1} of ${questions.length}`;
|
284 |
|
285 |
-
//
|
286 |
startTimer();
|
287 |
-
}
|
288 |
}
|
289 |
|
290 |
// Funzione per avviare il timer
|
291 |
-
let timerInterval;
|
292 |
function startTimer() {
|
293 |
-
timer
|
294 |
-
|
295 |
timerInterval = setInterval(() => {
|
296 |
timer++;
|
297 |
const minutes = String(Math.floor(timer / 60)).padStart(2, '0');
|
@@ -301,7 +303,6 @@ function startTimer() {
|
|
301 |
}
|
302 |
|
303 |
|
304 |
-
|
305 |
function updateTimer() {
|
306 |
const elapsedTime = Math.floor((Date.now() - startTime) / 1000);
|
307 |
const hours = String(Math.floor(elapsedTime / 3600)).padStart(2, '0');
|
|
|
223 |
document.getElementById('quiz-container').style.display = 'none';
|
224 |
resultsContainer.style.display = 'block';
|
225 |
});
|
226 |
+
// Variabile globale per il timer
|
227 |
+
let timer = 0;
|
228 |
+
let timerInterval;
|
229 |
|
230 |
+
// Aggiungi l'evento al pulsante "Return to Start"
|
231 |
document.getElementById('restart').addEventListener('click', () => {
|
232 |
+
// Ferma il timer prima di resettare
|
233 |
+
clearInterval(timerInterval);
|
234 |
+
timer = 0; // Reset del timer
|
235 |
+
document.getElementById('timer').innerText = '00:00'; // Ripristina il timer a 00:00
|
236 |
+
|
237 |
+
// Nascondi la sezione dei risultati e mostra il quiz
|
238 |
document.getElementById('results-container').style.display = 'none';
|
239 |
document.getElementById('quiz-container').style.display = 'block';
|
240 |
+
|
241 |
+
// Reset delle variabili di stato
|
242 |
resetQuizState();
|
243 |
+
|
244 |
// Reset della selezione del file
|
245 |
+
document.getElementById('file-selector').value = ''; // Resetta la selezione del file
|
246 |
|
247 |
// Pulisce il contenuto dei risultati
|
248 |
document.getElementById('results-container').innerHTML = '';
|
249 |
+
|
250 |
// Ripristina la visualizzazione della prima domanda
|
251 |
loadQuestion();
|
252 |
});
|
253 |
|
254 |
+
// Funzione per il reset completo dello stato del quiz
|
255 |
function resetQuizState() {
|
256 |
currentQuestionIndex = 0; // Ripristina l'indice della domanda
|
257 |
userAnswers = []; // Resetta le risposte dell'utente
|
258 |
+
clearInterval(timerInterval); // Ferma qualsiasi intervallo del timer in corso
|
259 |
timer = 0; // Resetta il timer
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
}
|
261 |
|
262 |
+
// Funzione per caricare una domanda
|
263 |
function loadQuestion() {
|
264 |
if (questions.length > 0) {
|
265 |
const question = questions[currentQuestionIndex];
|
|
|
286 |
// Visualizza il numero di domanda
|
287 |
document.getElementById('question-number').innerText = `Question ${currentQuestionIndex + 1} of ${questions.length}`;
|
288 |
|
289 |
+
// Riavvia il timer
|
290 |
startTimer();
|
|
|
291 |
}
|
292 |
|
293 |
// Funzione per avviare il timer
|
|
|
294 |
function startTimer() {
|
295 |
+
clearInterval(timerInterval); // Assicurati di fermare il timer precedente
|
296 |
+
timer = 0; // Reset del timer
|
297 |
timerInterval = setInterval(() => {
|
298 |
timer++;
|
299 |
const minutes = String(Math.floor(timer / 60)).padStart(2, '0');
|
|
|
303 |
}
|
304 |
|
305 |
|
|
|
306 |
function updateTimer() {
|
307 |
const elapsedTime = Math.floor((Date.now() - startTime) / 1000);
|
308 |
const hours = String(Math.floor(elapsedTime / 3600)).padStart(2, '0');
|
app/static/style.css
CHANGED
@@ -46,15 +46,6 @@ label {
|
|
46 |
margin-top: 20px;
|
47 |
}
|
48 |
|
49 |
-
#navigation button {
|
50 |
-
font-size: 16px;
|
51 |
-
border: none;
|
52 |
-
background-color: #bfbfbf;
|
53 |
-
color: white;
|
54 |
-
cursor: pointer;
|
55 |
-
transition: background-color 0.3s ease;
|
56 |
-
}
|
57 |
-
|
58 |
#navigation button:hover {
|
59 |
background-color: #0056b3;
|
60 |
}
|
|
|
46 |
margin-top: 20px;
|
47 |
}
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
#navigation button:hover {
|
50 |
background-color: #0056b3;
|
51 |
}
|