«, answer: 3 },
{ question: «📜 ¿Qué idioma era utilizado predominantemente en los textos de la biblioteca?», options: [«Latín», «Griego», «Hebreo», «Egipcio»,], answer: 1 },
{ question: «🏛️ ¿Qué calamidad se dice que destruyó la biblioteca de Alejandría?», options: [«Un terremoto», «Un fuego», «Una inundación», «Guerra»,], answer: 1 },
{ question: «🌍 ¿Qué civilización fue conocida por su contribución al desarrollo de la biblioteca?», options: [«Egipcia», «Griega», «Romana», «Persa»,], answer: 1 },
{ question: «👨🏫 ¿Qué concepto contemporáneo comparte similitudes con la biblioteca de Alejandría?», options: [«Internet», «Museo», «Universidad», «Archivo»,], answer: 0 },
{ question: «⚖️ ¿Quién fue el último director conocido de la biblioteca?», options: [«Zenón», «Apolonio», «Herón», «Cicerón»,], answer: 2 },
{ question: «📖 ¿Cuántos libros se estima que pudo haber contenido la biblioteca?», options: [«30,000», «700,000», «1,000,000», «50,000»,], answer: 1 },
{ question: «🔑 ¿Qué legado importante dejó la biblioteca de Alejandría?», options: [«Inventos», «Conocimiento», «Riqueza», «Territorio»,], answer: 1 },
];
let current = 0;
let score = 0;
let timer;
let timeLeft = 15;
function startTimer() {
timeLeft = 15;
document.getElementById(«quiz-timer»).innerText = timeLeft;
clearInterval(timer);
timer = setInterval(() => {
timeLeft–;
document.getElementById(«quiz-timer»).innerText = timeLeft;
if (timeLeft === 0) {
clearInterval(timer);
disableOptions();
revealCorrect();
}
}, 1000);
}
function renderQuestion() {
const q = quizData[current];
const letters = [«A», «B», «C», «D»];
document.getElementById(«quiz-container»).className = «quiz-container»;
document.getElementById(«quiz-container»).innerHTML = `
Pregunta ${current + 1} de ${quizData.length}⏳ Tiempo: 15s
${q.question}
${q.options.map((opt, i) => `
`).join(«»)}
`;
startTimer();
}
window.selectAnswer = function(index) {
clearInterval(timer);
const correct = quizData[current].answer;
const buttons = document.querySelectorAll(«.quiz-option-button»);
buttons.forEach((btn, i) => {
btn.disabled = true;
if (i === correct) btn.classList.add(«correct»);
if (i === index && index !== correct) btn.classList.add(«incorrect»);
});
if (index === correct) score++;
document.getElementById(«next-btn»).disabled = false;
};
function disableOptions() {
const buttons = document.querySelectorAll(«.quiz-option-button»);
buttons.forEach(btn => btn.disabled = true);
document.getElementById(«next-btn»).disabled = false;
}
function revealCorrect() {
const correct = quizData[current].answer;
const buttons = document.querySelectorAll(«.quiz-option-button»);
buttons[correct].classList.add(«correct»);
}
window.nextQuestion = function() {
current++;
if (current < quizData.length) {
renderQuestion();
} else {
showResults();
}
};
function showResults() {
let message = "";
if (score === quizData.length) {
message = "¡Impresionante! Has descifrado todos los secretos de la biblioteca de Alejandría. 📚🏆";
} else if (score >= quizData.length * 0.7) {
message = «Muy bien hecho, has demostrado un gran conocimiento sobre este importante centro de saber. 🌟»;
} else if (score >= quizData.length * 0.4) {
message = «Adecuado, pero aún hay más misterios por descubrir sobre la biblioteca. 📖»;
} else {
message = «Parece que los secretos de la biblioteca son un verdadero rompecabezas. ¡Sigue explorando! 🧩»;
}
const shareText = `¡He acertado ${score} de ${quizData.length} preguntas sobre la biblioteca de Alejandría en un test! ¿Te atreves a superarme? responderapido.com`;
document.getElementById(«quiz-container»).innerHTML = `
Has acertado ${score} de ${quizData.length} preguntas