body {
font-family: ‘Arial’, sans-serif;
line-height: 1.6;
max-width: 100%;
margin: 0 auto;
padding: 20px;
background-color: #f5f5f5;
color: #333;
}
.container {
background-color: white;
border-radius: 10px;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1, h2, h3 {
color: #2c3e50;
text-align: center;
}
.intro {
background-color: #f8f9fa;
padding: 15px;
border-radius: 5px;
margin-bottom: 20px;
border-left: 4px solid #3498db;
}
#start-btn, #next-btn, #restart-btn, #previous-btn {
background-color: #3498db;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
margin: 10px 5px;
font-size: 16px;
transition: background-color 0.3s;
}
#start-btn:hover, #next-btn:hover, #restart-btn:hover, #previous-btn:hover {
background-color: #2980b9;
}
#restart-btn {
background-color: #2ecc71;
}
#restart-btn:hover {
background-color: #27ae60;
}
#previous-btn {
background-color: #95a5a6;
}
#previous-btn:hover {
background-color: #7f8c8d;
}
#timer {
text-align: center;
font-size: 20px;
margin: 10px 0;
font-weight: bold;
color: #e74c3c;
}
.question-container {
display: none;
padding: 15px;
background-color: #fff;
border-radius: 5px;
margin-bottom: 10px;
border-left: 4px solid #3498db;
}
.options {
margin-top: 15px;
}
.option {
display: block;
padding: 10px;
margin: 5px 0;
background-color: #f1f1f1;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
.option:hover {
background-color: #e6e6e6;
}
.option.selected {
background-color: #3498db;
color: white;
}
.option.correct {
background-color: #2ecc71;
color: white;
}
.option.incorrect {
background-color: #e74c3c;
color: white;
}
.feedback {
margin-top: 20px;
padding: 15px;
border-radius: 5px;
text-align: center;
font-weight: bold;
}
.level-description {
margin-top: 20px;
padding: 15px;
background-color: #f8f9fa;
border-radius: 5px;
border-left: 4px solid #2ecc71;
}
.progress-container {
width: 100%;
height: 20px;
background-color: #f1f1f1;
border-radius: 10px;
margin: 20px 0;
}
.progress-bar {
height: 100%;
background-color: #3498db;
border-radius: 10px;
width: 0%;
transition: width 0.3s;
}
.btn-container {
display: flex;
justify-content: space-between;
margin-top: 20px;
}
.hidden {
display: none;
}
#result-container {
display: none;
text-align: center;
padding: 20px;
background-color: #f8f9fa;
border-radius: 5px;
margin-top: 20px;
border: 2px solid #2ecc71;
}
#level-badge {
font-size: 60px;
font-weight: bold;
color: #2c3e50;
margin: 20px 0;
}
.firework {
position: absolute;
width: 5px;
height: 5px;
border-radius: 50%;
box-shadow: 0 0 10px 5px rgba(255, 255, 255, 0.8);
animation: firework 1s ease-out;
animation-fill-mode: forwards;
}
@keyframes firework {
0% {
transform: translate(0, 0);
opacity: 1;
width: 5px;
height: 5px;
}
100% {
transform: translate(var(–x-move), var(–y-move));
opacity: 0;
width: 2px;
height: 2px;
}
}
Bienvenido al Test de Nivel de Inglés
Este test te permitirá determinar tu nivel de inglés según el Marco Común Europeo de Referencia para las Lenguas (MCER), desde A1 hasta C2.
Instrucciones:
- El test contiene aproximadamente 75 preguntas de dificultad progresiva
- Tienes 45 segundos para responder a cada pregunta
- La duración total del test es de 5 a 20 minutos según tu nivel
- El test se detendrá automáticamente una vez que se identifique tu nivel
- Puedes reiniciar el test en cualquier momento
¡Buena suerte!
¡Felicitaciones!
Has completado el test de nivel de inglés.
Tu nivel de inglés es:
// Definición de las preguntas por nivel
const questions = [
// A1 Questions (1-15)
{
level: “A1”,
question: “What’s your name?”,
options: [“My name is John.”, “I have John.”, “I am John.”, “I John.”],
answer: 0
},
{
level: “A1”,
question: “Good morning, _____ are you?”,
options: [“what”, “who”, “how”, “where”],
answer: 2
},
{
level: “A1”,
question: “There is _____ book on the table.”,
options: [“a”, “an”, “some”, “the”],
answer: 0
},
{
level: “A1”,
question: “I like _____ coffee.”,
options: [“the”, “-“, “a”, “an”],
answer: 1
},
{
level: “A1”,
question: “We _____ students.”,
options: [“are”, “is”, “am”, “be”],
answer: 0
},
{
level: “A1”,
question: “What are the colors of the USA flag?”,
options: [“Red, white and blue”, “Blue, white and red”, “White, red and blue”, “Red, blue and white”],
answer: 0
},
{
level: “A1”,
question: “I _____ bread every morning.”,
options: [“eat”, “eats”, “eating”, “to eat”],
answer: 0
},
{
level: “A1”,
question: “She _____ from England.”,
options: [“are”, “is”, “am”, “be”],
answer: 1
},
{
level: “A1”,
question: “We _____ to the cinema yesterday.”,
options: [“go”, “will go”, “went”, “going”],
answer: 2
},
{
level: “A1”,
question: “I _____ get up at 7am every day.”,
options: [“must”, “should”, “have”, “can”],
answer: 0
},
{
level: “A1”,
question: “_____ do you live?”,
options: [“Where”, “Who”, “What”, “How”],
answer: 0
},
{
level: “A1”,
question: “Today is _____ Monday.”,
options: [“in”, “on”, “at”, “-“],
answer: 3
},
{
level: “A1”,
question: “My mother is my father’s _____.”,
options: [“wife”, “husband”, “daughter”, “son”],
answer: 0
},
{
level: “A1”,
question: “I would like _____ water, please.”,
options: [“some”, “a”, “an”, “the”],
answer: 0
},
{
level: “A1”,
question: “_____ do you like to do in your free time?”,
options: [“What”, “How”, “Why”, “When”],
answer: 0
},
// A2 Questions (16-30)
{
level: “A2”,
question: “If I had time, I _____ to the cinema.”,
options: [“go”, “would go”, “will go”, “went”],
answer: 1
},
{
level: “A2”,
question: “She _____ in London for two years.”,
options: [“lives”, “lived”, “has lived”, “will live”],
answer: 2
},
{
level: “A2”,
question: “I can’t go out _____ it’s raining.”,
options: [“because”, “so”, “but”, “or”],
answer: 0
},
{
level: “A2”,
question: “Have you _____ this movie?”,
options: [“seen”, “see”, “saw”, “seeing”],
answer: 0
},
{
level: “A2”,
question: “We _____ dinner at a restaurant tomorrow evening.”,
options: [“are having”, “have”, “will have”, “had”],
answer: 0
},
{
level: “A2”,
question: “I’m looking for _____ apartment to rent.”,
options: [“an”, “the”, “a”, “-“],
answer: 0
},
{
level: “A2”,
question: “They _____ hands.”,
options: [“shook”, “shaked”, “shake”, “shaken”],
answer: 0
},
{
level: “A2”,
question: “_____ does it take to get to the airport?”,
options: [“How long”, “How many”, “What time”, “What”],
answer: 0
},
{
level: “A2”,
question: “I would like _____ early tomorrow morning.”,
options: [“to wake up”, “waking up”, “wake up”, “woke up”],
answer: 0
},
{
level: “A2”,
question: “Yesterday, we _____ to the restaurant.”,
options: [“went”, “go”, “will go”, “have gone”],
answer: 0
},
{
level: “A2”,
question: “She _____ understood the question.”,
options: [“hasn’t”, “didn’t”, “doesn’t”, “won’t”],
answer: 1
},
{
level: “A2”,
question: “This is the car _____ I bought yesterday.”,
options: [“that”, “who”, “whose”, “where”],
answer: 0
},
{
level: “A2”,
question: “Can you tell me _____ you did that?”,
options: [“why”, “how”, “when”, “where”],
answer: 0
},
{
level: “A2”,
question: “I don’t like this shirt, I prefer _____.”,
options: [“this one”, “these one”, “those one”, “that ones”],
answer: 0
},
{
level: “A2”,
question: “_____ to get to the station, please?”,
options: [“Where”, “How”, “When”, “What”],
answer: 1
},
// B1 Questions (31-45)
{
level: “B1”,
question: “If I _____ more money, I would buy a new car.”,
options: [“had”, “would have”, “have”, “will have”],
answer: 0
},
{
level: “B1”,
question: “I doubt that he _____ on time.”,
options: [“is”, “will be”, “would be”, “be”],
answer: 1
},
{
level: “B1”,
question: “This is the movie _____ everyone is talking about.”,
options: [“that”, “which”, “who”, “whose”],
answer: 0
},
{
level: “B1”,
question: “You need to _____ this document before tomorrow.”,
options: [“finishing”, “finish”, “to finish”, “finished”],
answer: 1
},
{
level: “B1”,
question: “She asked me if I _____ come to her party.”,
options: [“can”, “could”, “will”, “would”],
answer: 1
},
{
level: “B1”,
question: “_____ his tardiness, he was able to attend the meeting.”,
options: [“Despite”, “Although”, “However”, “Nevertheless”],
answer: 0
},
{
level: “B1”,
question: “It’s important that you _____ this problem quickly.”,
options: [“solve”, “solving”, “solved”, “to solve”],
answer: 0
},
{
level: “B1”,
question: “I wish she _____ to the party.”,
options: [“comes”, “came”, “had come”, “would come”],
answer: 2
},
{
level: “B1”,
question: “We _____ already finished when they arrived.”,
options: [“had”, “have”, “will have”, “would have”],
answer: 0
},
{
level: “B1”,
question: “I’ll lend you my book provided that you _____ it back.”,
options: [“give”, “will give”, “gave”, “giving”],
answer: 1
},
{
level: “B1”,
question: “That’s the person _____ I told you about yesterday.”,
options: [“that”, “who”, “whom”, “whose”],
answer: 2
},
{
level: “B1”,
question: “Whatever you _____, I won’t change my mind.”,
options: [“say”, “will say”, “would say”, “saying”],
answer: 0
},
{
level: “B1”,
question: “_____ his age, he remains very active.”,
options: [“Despite”, “Because of”, “Thanks to”, “Due to”],
answer: 0
},
{
level: “B1”,
question: “I _____ you as soon as I have news.”,
options: [“contact”, “will contact”, “would contact”, “am contacting”],
answer: 1
},
{
level: “B1”,
question: “It’s possible that he _____ late tomorrow.”,
options: [“will be”, “is”, “be”, “would be”],
answer: 0
},
// B2 Questions (46-60)
{
level: “B2”,
question: “In case you _____ delayed, please let me know.”,
options: [“are”, “will be”, “would be”, “being”],
answer: 0
},
{
level: “B2”,
question: “I still haven’t received the package _____ I ordered two weeks ago.”,
options: [“which”, “what”, “whose”, “where”],
answer: 0
},
{
level: “B2”,
question: “_____ you may be right, I cannot support you in this matter.”,
options: [“Although”, “Despite”, “Because”, “Since”],
answer: 0
},
{
level: “B2”,
question: “It’s not so much his attitude _____ his words that shocked me.”,
options: [“as”, “like”, “than”, “but”],
answer: 0
},
{
level: “B2”,
question: “If you _____ earlier, you wouldn’t have missed your flight.”,
options: [“left”, “would leave”, “had left”, “have left”],
answer: 2
},
{
level: “B2”,
question: “I would prefer that you _____ this task by tomorrow.”,
options: [“complete”, “completed”, “completing”, “to complete”],
answer: 0
},
{
level: “B2”,
question: “_____ his experience, he was able to handle the crisis effectively.”,
options: [“Thanks to”, “Due to”, “Regarding”, “Following”],
answer: 0
},
{
level: “B2”,
question: “Here are the documents _____ you should refer to.”,
options: [“that”, “which”, “to which”, “what”],
answer: 2
},
{
level: “B2”,
question: “It is imperative that we _____ this decision now.”,
options: [“make”, “will make”, “would make”, “made”],
answer: 0
},
{
level: “B2”,
question: “_____ for this reason, I refuse to participate.”,
options: [“If only”, “Even”, “Only”, “Just”],
answer: 2
},
{
level: “B2”,
question: “The meeting, _____ I had completely forgotten about, has been postponed.”,
options: [“which”, “that”, “what”, “who”],
answer: 0
},
{
level: “B2”,
question: “_____ she is very young, she already has a lot of experience.”,
options: [“Although”, “Despite”, “Even though”, “In spite of”],
answer: 0
},
{
level: “B2”,
question: “You should _____ these documents before Friday.”,
options: [“sign”, “to sign”, “signing”, “signed”],
answer: 0
},
{
level: “B2”,
question: “This is the proposal _____ we finally opted for.”,
options: [“that”, “which”, “for which”, “what”],
answer: 2
},
{
level: “B2”,
question: “I replied to his email, _____ I haven’t received a response yet.”,
options: [“however”, “therefore”, “meanwhile”, “furthermore”],
answer: 0
},
// C1 Questions (61-75)
{
level: “C1”,
question: “Had it not been for his intervention, we _____ in a much more complicated situation.”,
options: [“would be”, “would have been”, “will be”, “had been”],
answer: 1
},
{
level: “C1”,
question: “You’d better _____ the consequences before making your decision.”,
options: [“to weigh”, “weighing”, “weigh”, “weighed”],
answer: 2
},
{
level: “C1”,
question: “This work, _____ the critics have praised, remains unknown to the general public.”,
options: [“that”, “which”, “whom”, “whose”],
answer: 1
},
{
level: “C1”,
question: “_____ it is an exceptional situation, we cannot make an exception.”,
options: [“Although”, “Since”, “Because”, “As”],
answer: 0
},
{
level: “C1”,
question: “It’s a phenomenon _____ causes remain mysterious.”,
options: [“whose”, “which”, “that”, “whom”],
answer: 0
},
{
level: “C1”,
question: “_____ intelligent he may be, he made an error of judgment.”,
options: [“So”, “However”, “As”, “No matter how”],
answer: 2
},
{
level: “C1”,
question: “It is appropriate that we _____ the different options available to us.”,
options: [“examine”, “examined”, “examining”, “to examine”],
answer: 0
},
{
level: “C1”,
question: “_____ the new information, we will need to adjust our strategy.”,
options: [“Regarding”, “In view of”, “Despite”, “Notwithstanding”],
answer: 1
},
{
level: “C1”,
question: “I would appreciate it if you could _____ your response as soon as possible.”,
options: [“send”, “to send”, “sending”, “sent”],
answer: 0
},
{
level: “C1”,
question: “_____ absurd as it may seem, his theory proved to be correct.”,
options: [“As”, “So”, “Such”, “How”],
answer: 0
},
{
level: “C1”,
question: “It’s high time you _____ responsibility for this matter.”,
options: [“take”, “took”, “taking”, “to take”],
answer: 1
},
{
level: “C1”,
question: “This decision, _____ we strongly opposed, was finally adopted.”,
options: [“to which”, “which”, “that”, “against which”],
answer: 3
},
{
level: “C1”,
question: “_____ she prepared her speech carefully, she had difficulty convincing the audience.”,
options: [“Although”, “Since”, “Because”, “While”],
answer: 0
},
{
level: “C1”,
question: “This hypothesis, _____ attractive it may be, is not based on any tangible evidence.”,
options: [“however”, “as”, “whatever”, “nevertheless”],
answer: 0
},
{
level: “C1”,
question: “It is essential that you _____ this contract before the end of the month.”,
options: [“terminate”, “terminated”, “terminating”, “to terminate”],
answer: 0
},
// C2 Questions (76-90)
{
level: “C2”,
question: “_____ the complexity of the problem, we should approach this issue with caution.”,
options: [“Given”, “In view of”, “Because of”, “Concerning”],
answer: 1
},
{
level: “C2”,
question: “The government passed this law, _____ strong opposition from unions.”,
options: [“despite”, “notwithstanding”, “in spite of”, “regardless of”],
answer: 1
},
{
level: “C2”,
question: “_____ we had taken all the necessary steps, our application was rejected.”,
options: [“Even though”, “Whereas”, “While”, “Seeing that”],
answer: 0
},
{
level: “C2”,
question: “These delaying tactics, _____ you have engaged in, have only served to delay the inevitable.”,
options: [“in which”, “which”, “to which”, “that”],
answer: 0
},
{
level: “C2”,
question: “It would have been preferable _____ this opportunity when it presented itself.”,
options: [“to seize”, “seizing”, “having seized”, “seize”],
answer: 0
},
{
level: “C2”,
question: “_____ demonstrating the absurdity of this theory, he launched into a convoluted explanation.”,
options: [“For the purpose of”, “With the aim of”, “For the sake of”, “With a view to”],
answer: 2
},
{
level: “C2”,
question: “This measure, _____ implementation faces numerous obstacles, should be reconsidered.”,
options: [“whose”, “which”, “that”, “for which”],
answer: 0
},
{
level: “C2”,
question: “_____ his commitment, he failed to change his opponents’ position.”,
options: [“Such was”, “So was”, “As was”, “That was”],
answer: 0
},
{
level: “C2”,
question: “I very much doubt that he _____ tomorrow’s meeting, given his busy schedule.”,
options: [“attends”, “will attend”, “would attend”, “attending”],
answer: 1
},
{
level: “C2”,
question: “_____ appearances, this proposal conceals less praiseworthy intentions.”,
options: [“Despite”, “Except”, “Behind”, “Besides”],
answer: 2
},
{
level: “C2”,
question: “It’s important that we _____ these misunderstandings before they escalate into open conflict.”,
options: [“clear up”, “clearing up”, “cleared up”, “to clear up”],
answer: 0
},
{
level: “C2”,
question: “It’s an issue _____ he did not deem appropriate to comment publicly.”,
options: [“on which”, “about which”, “that”, “which”],
answer: 0
},
{
level: “C2”,
question: “_____ that may be, we need to make a decision before the end of the week.”,
options: [“Be it as it may”, “However”, “Whatever”, “Nevertheless”],
answer: 0
},
{
level: “C2”,
question: “The report, _____ you will find a summary in the appendix, indicates a worrying situation.”,
options: [“of which”, “which”, “whose”, “that”],
answer: 0
},
{
level: “C2”,
question: “_____ mitigating circumstances, the sentence would have been much more severe.”,
options: [“Were it not for”, “Without”, “But for”, “In the absence of”],
answer: 0
}
];
// Variables globales
let currentQuestionIndex = 0;
let userAnswers = [];
let timer;
let timeLeft = 45;
let questionsPerLevel = {
“A1”: 0,
“A2”: 0,
“B1”: 0,
“B2”: 0,
“C1”: 0,
“C2”: 0
};
let correctPerLevel = {
“A1”: 0,
“A2”: 0,
“B1”: 0,
“B2”: 0,
“C1”: 0,
“C2”: 0
};
let currentLevelIndex = 0;
const levels = [“A1”, “A2”, “B1”, “B2”, “C1”, “C2”];
let testCompleted = false;
// Contar las preguntas por nivel
questions.forEach(question => {
questionsPerLevel[question.level]++;
});
// Descripción de los niveles
const levelDescriptions = {
“A1”: “Nivel Principiante (A1): Puedes comprender y utilizar expresiones cotidianas y frases muy básicas. Puedes presentarte y presentar a alguien, y hacer preguntas simples sobre temas personales.”,
“A2”: “Nivel Elemental (A2): Puedes comprender frases y expresiones frecuentemente utilizadas relacionadas con áreas inmediatas (información personal, compras, entorno cercano, trabajo). Puedes comunicarte en tareas simples y cotidianas.”,
“B1”: “Nivel Intermedio (B1): Puedes comprender los puntos principales de una conversación en un lenguaje claro y estándar. Puedes desenvolverte en la mayoría de las situaciones durante un viaje. Puedes producir un discurso simple y coherente sobre temas familiares.”,
“B2”: “Nivel Avanzado (B2): Puedes comprender el contenido esencial de temas concretos o abstractos en un texto complejo. Puedes comunicarte con un grado de espontaneidad y fluidez que hace posible la interacción normal con un hablante nativo.”,
“C1”: “Nivel Dominio Operativo (C1): Puedes comprender una amplia gama de textos extensos y exigentes, así como captar significados implícitos. Puedes expresarte de forma espontánea y fluida sin tener que buscar demasiado las palabras.”,
“C2”: “Nivel Maestría (C2): Puedes comprender prácticamente todo lo que lees o escuchas sin esfuerzo. Puedes expresarte espontáneamente, con gran fluidez y precisión, y puedes distinguir matices sutiles de significado incluso en situaciones complejas.”
};
// Inicialización del test
document.addEventListener(‘DOMContentLoaded’, function() {
document.getElementById(‘start-btn’).addEventListener(‘click’, startTest);document.getElementById(‘next-btn’).addEventListener(‘click’, nextQuestion);
document.getElementById(‘previous-btn’).addEventListener(‘click’, previousQuestion);
document.getElementById(‘restart-btn’).addEventListener(‘click’, restartTest);
});
// Iniciar el test
function startTest() {
document.getElementById(‘intro-container’).style.display = ‘none’;
document.getElementById(‘test-container’).style.display = ‘block’;
document.getElementById(‘question-container’).style.display = ‘block’;
// Reiniciar variables
currentQuestionIndex = 0;
userAnswers = Array(questions.length).fill(null);
correctPerLevel = {
“A1”: 0,
“A2”: 0,
“B1”: 0,
“B2”: 0,
“C1”: 0,
“C2”: 0
};
testCompleted = false;
currentLevelIndex = 0;
// Mostrar la primera pregunta
showQuestion(currentQuestionIndex);
startTimer();
updateProgressBar();
}
// Mostrar pregunta
function showQuestion(index) {
const questionData = questions[index];
const questionContainer = document.getElementById(‘question-container’);
// Crear el contenido de la pregunta
let content = `
Pregunta ${index + 1} (Nivel ${questionData.level})
${questionData.question}
`;
// Mostrar la pregunta
questionContainer.innerHTML = content;
// Agregar eventos a las opciones
const options = document.querySelectorAll(‘.option’);
options.forEach(option => {
option.addEventListener(‘click’, function() {
selectOption(this);
});
});
// Mostrar/ocultar botones de navegación
document.getElementById(‘previous-btn’).style.display = index > 0 ? ‘block’ : ‘none’;
// Actualizar el temporizador
resetTimer();
}
// Seleccionar una opción
function selectOption(selectedOption) {
const options = document.querySelectorAll(‘.option’);
options.forEach(option => {
option.classList.remove(‘selected’);
});
selectedOption.classList.add(‘selected’);
userAnswers[currentQuestionIndex] = parseInt(selectedOption.getAttribute(‘data-index’));
}
// Avanzar a la siguiente pregunta
function nextQuestion() {
// Si no se ha seleccionado una respuesta, mostrar un mensaje
if (userAnswers[currentQuestionIndex] === null) {
alert(‘Por favor, selecciona una respuesta antes de continuar.’);
return;
}
// Verificar si la respuesta es correcta
const currentQuestion = questions[currentQuestionIndex];
const userAnswer = userAnswers[currentQuestionIndex];
const currentLevel = currentQuestion.level;
if (userAnswer === currentQuestion.answer) {
correctPerLevel[currentLevel]++;
}
// Avanzar a la siguiente pregunta
currentQuestionIndex++;
// Verificar si necesitamos cambiar de nivel o terminar el test
if (shouldChangeLevel() || currentQuestionIndex >= questions.length) {
finishTest();
return;
}
// Mostrar la siguiente pregunta
showQuestion(currentQuestionIndex);
updateProgressBar();
}
// Volver a la pregunta anterior
function previousQuestion() {
if (currentQuestionIndex > 0) {
currentQuestionIndex–;
showQuestion(currentQuestionIndex);
updateProgressBar();
}
}
// Verificar si se debe cambiar de nivel
function shouldChangeLevel() {
const currentQuestion = questions[currentQuestionIndex – 1];
const currentLevel = currentQuestion.level;
const currentLevelQuestions = questionsPerLevel[currentLevel];
// Contar cuántas preguntas de este nivel se han respondido
const answeredQuestionsOfLevel = questions
.slice(0, currentQuestionIndex)
.filter(q => q.level === currentLevel)
.length;
// Si se han contestado al menos 10 preguntas del nivel actual
if (answeredQuestionsOfLevel >= 10) {
// Calcular porcentaje de aciertos
const correctPercentage = (correctPerLevel[currentLevel] / answeredQuestionsOfLevel) * 100;
// Si el porcentaje de aciertos es menor al 60%, detenemos el test
if (correctPercentage = 60) {
return true;
}
// Si se han contestado todas las preguntas del nivel actual
if (answeredQuestionsOfLevel >= currentLevelQuestions) {
// Avanzamos al siguiente nivel
const currentLevelIndex = levels.indexOf(currentLevel);
if (currentLevelIndex answer !== null).length;
const correctAnswers = levels.reduce((total, level) => total + correctPerLevel[level], 0);
const accuracy = Math.round((correctAnswers / answeredQuestions) * 100);
feedback.textContent = `Has respondido correctamente ${correctAnswers} de ${answeredQuestions} preguntas (${accuracy}% de precisión).`;
// Crear fuegos artificiales
createFireworks();
testCompleted = true;
}
// Determinar el nivel del usuario
function determineUserLevel() {
let userLevel = “A1”;
for (let i = levels.length – 1; i >= 0; i–) {
const level = levels[i];
const answeredQuestionsOfLevel = questions
.slice(0, currentQuestionIndex)
.filter(q => q.level === level)
.length;
if (answeredQuestionsOfLevel > 0) {
const correctPercentage = (correctPerLevel[level] / answeredQuestionsOfLevel) * 100;
if (correctPercentage >= 60) {
userLevel = level;
break;
}
}
}
return userLevel;
}
// Reiniciar el test
function restartTest() {
document.getElementById(‘result-container’).style.display = ‘none’;
startTest();
}
// Temporizador
function startTimer() {
timeLeft = 45;
document.getElementById(‘timer’).textContent = timeLeft;
timer = setInterval(function() {
timeLeft–;
document.getElementById(‘timer’).textContent = timeLeft;
if (timeLeft {
option.classList.remove(‘selected’);
if (parseInt(option.getAttribute(‘data-index’)) === randomAnswer) {
option.classList.add(‘selected’);
}
});
}
// Avanzar a la siguiente pregunta automáticamente
setTimeout(function() {
nextQuestion();
}, 1000);
}
}, 1000);
}
// Reiniciar el temporizador
function resetTimer() {
clearInterval(timer);
startTimer();
}
// Actualizar barra de progreso
function updateProgressBar() {
const progress = (currentQuestionIndex / questions.length) * 100;
document.querySelector(‘.progress-bar’).style.width = `${progress}%`;
}
// Crear efectos de fuegos artificiales
function createFireworks() {
const resultContainer = document.getElementById(‘result-container’);
for (let i = 0; i {
const firework = document.createElement(‘div’);
firework.classList.add(‘firework’);
// Posición inicial
const startX = Math.random() * resultContainer.offsetWidth;
const startY = Math.random() * resultContainer.offsetHeight;
firework.style.left = `${startX}px`;
firework.style.top = `${startY}px`;
// Color aleatorio
const hue = Math.floor(Math.random() * 360);
firework.style.backgroundColor = `hsl(${hue}, 100%, 50%)`;
firework.style.boxShadow = `0 0 10px 5px hsl(${hue}, 100%, 60%)`;
// Dirección aleatoria
const xMove = (Math.random() – 0.5) * 100;
const yMove = (Math.random() – 0.5) * 100;
firework.style.setProperty(‘–x-move’, `${xMove}px`);
firework.style.setProperty(‘–y-move’, `${yMove}px`);
resultContainer.appendChild(firework);
// Eliminar después de la animación
setTimeout(() => {
firework.remove();
}, 1000);
}, i * 100);
}
}