Changed around line 1
+ const startBtn = document.getElementById('start-btn');
+ const quizSection = document.getElementById('quiz');
+ const introSection = document.getElementById('intro');
+ const questionElement = document.getElementById('question');
+ const optionsElement = document.getElementById('options');
+ const progressBar = document.getElementById('progress-bar');
+ const resultsSection = document.getElementById('results');
+ const scoreElement = document.getElementById('score');
+ const interpretationElement = document.getElementById('interpretation');
+ const retryBtn = document.getElementById('retry-btn');
+
+ let currentQuestionIndex = 0;
+ let score = 0;
+
+ const questions = [
+ { question: "Which is more important to you?", options: ["Honesty", "Loyalty"], weights: [1, 2] },
+ { question: "Do you prefer?", options: ["Planning", "Spontaneity"], weights: [2, 1] },
+ { question: "Which do you value more?", options: ["Empathy", "Logic"], weights: [1, 2] },
+ // Add more questions here...
+ ];
+
+ startBtn.addEventListener('click', startQuiz);
+ retryBtn.addEventListener('click', retryQuiz);
+
+ function startQuiz() {
+ introSection.classList.add('hidden');
+ quizSection.classList.remove('hidden');
+ showQuestion();
+ }
+
+ function showQuestion() {
+ const currentQuestion = questions[currentQuestionIndex];
+ questionElement.innerText = currentQuestion.question;
+ optionsElement.innerHTML = '';
+ currentQuestion.options.forEach((option, index) => {
+ const button = document.createElement('button');
+ button.innerText = option;
+ button.addEventListener('click', () => selectAnswer(index));
+ optionsElement.appendChild(button);
+ });
+ updateProgressBar();
+ }
+
+ function selectAnswer(selectedIndex) {
+ const currentQuestion = questions[currentQuestionIndex];
+ score += currentQuestion.weights[selectedIndex];
+ currentQuestionIndex++;
+ if (currentQuestionIndex < questions.length) {
+ showQuestion();
+ } else {
+ showResults();
+ }
+ }
+
+ function updateProgressBar() {
+ const progress = ((currentQuestionIndex + 1) / questions.length) * 100;
+ progressBar.style.width = `${progress}%`;
+ }
+
+ function showResults() {
+ quizSection.classList.add('hidden');
+ resultsSection.classList.remove('hidden');
+ scoreElement.innerText = `Your Score: ${score}`;
+ interpretationElement.innerText = getInterpretation(score);
+ }
+
+ function getInterpretation(score) {
+ if (score < 10) {
+ return "You have a balanced emotional quotient. Keep nurturing your emotional intelligence.";
+ } else if (score < 20) {
+ return "You show strong emotional awareness. Continue to develop your emotional skills.";
+ } else {
+ return "You have a highly developed emotional quotient. Your emotional intelligence is a great asset.";
+ }
+ }
+
+ function retryQuiz() {
+ currentQuestionIndex = 0;
+ score = 0;
+ resultsSection.classList.add('hidden');
+ introSection.classList.remove('hidden');
+ }