tes kuis
TARIKH 1
193
window.location.reload(); // Refresh halaman untuk reset skor dan UI
194
}).catch(error => {
195
console.error('Error:', error);
196
alert("Terjadi kesalahan saat mendaftar skor.");
197
registerButton.disabled = false;
198
registerButton.textContent = 'Daftarkan Skor ke Leaderboard';
199
});
200
}
201
202
function restartQuiz() {
203
window.location.reload(); // Refresh halaman untuk memulai ulang kuis
204
}
205
206
function viewLeaderboard() {
207
window.location.href = "https://kuismdta.blogspot.com/p/leaderboard.html"; // Ganti dengan URL halaman leaderboard Anda
208
}
209
210
function startTimer() {
211
timerElement = document.createElement('div');
212
timerElement.style.textAlign = 'center';
213
document.getElementById("quiz-container").appendChild(timerElement);
214
timeLeft = 20; // Mengatur ulang waktu untuk soal berikutnya
215
timer = setInterval(function() {
216
timerElement.textContent = 'Waktu tersisa: ' + timeLeft + ' detik';
217
if (timeLeft <= 0) {
218
clearInterval(timer);
219
timerElement.textContent = '';
220
processTimeOut();
221
}
222
timeLeft--;
223
}, 1000);
224
}
225
226
function processTimeOut() {
227
var buttons = document.querySelectorAll('#quiz-container button');
228
buttons.forEach(btn => {
229
btn.disabled = true;
230
btn.style.backgroundColor = 'red'; // Semua tombol menunjukkan kesalahan saat waktu habis
231
});
232
displayEndPopup();
233
}
234
235