Changed around line 1
+ const questions = [
+ {
+ question: "Does your business have a clear mission and vision?",
+ options: ["Yes", "No", "Partially"],
+ weights: [3, 0, 1]
+ },
+ {
+ question: "Do you have a detailed business plan?",
+ options: ["Yes", "No", "In Progress"],
+ weights: [3, 0, 1]
+ },
+ {
+ question: "Is your target market clearly defined?",
+ options: ["Yes", "No", "Partially"],
+ weights: [3, 0, 1]
+ },
+ {
+ question: "Do you have a unique value proposition?",
+ options: ["Yes", "No", "Developing"],
+ weights: [3, 0, 1]
+ },
+ {
+ question: "Is your financial plan in place?",
+ options: ["Yes", "No", "In Progress"],
+ weights: [3, 0, 1]
+ },
+ {
+ question: "Do you have a marketing strategy?",
+ options: ["Yes", "No", "Developing"],
+ weights: [3, 0, 1]
+ },
+ {
+ question: "Is your team fully trained and prepared?",
+ options: ["Yes", "No", "Partially"],
+ weights: [3, 0, 1]
+ },
+ {
+ question: "Do you have the necessary technology and tools?",
+ options: ["Yes", "No", "Partially"],
+ weights: [3, 0, 1]
+ },
+ {
+ question: "Is your legal and compliance framework in place?",
+ options: ["Yes", "No", "In Progress"],
+ weights: [3, 0, 1]
+ },
+ {
+ question: "Do you have a risk management plan?",
+ options: ["Yes", "No", "Developing"],
+ weights: [3, 0, 1]
+ }
+ ];
+
+ let currentQuestion = 0;
+ let score = 0;
+
+ const questionElement = document.getElementById('question');
+ const optionsElement = document.getElementById('options');
+ const progressElement = document.getElementById('quiz-progress');
+ const progressText = document.getElementById('progress-text');
+ const quizSection = document.getElementById('quiz');
+ const resultsSection = document.getElementById('results');
+ const resultText = document.getElementById('result-text');
+ const retryBtn = document.getElementById('retry-btn');
+
+ function showQuestion() {
+ const question = questions[currentQuestion];
+ questionElement.textContent = question.question;
+ optionsElement.innerHTML = '';
+ question.options.forEach((option, index) => {
+ const button = document.createElement('button');
+ button.textContent = option;
+ button.addEventListener('click', () => selectAnswer(index));
+ optionsElement.appendChild(button);
+ });
+ progressElement.value = currentQuestion + 1;
+ progressText.textContent = `${currentQuestion + 1}/${questions.length}`;
+ }
+
+ function selectAnswer(index) {
+ score += questions[currentQuestion].weights[index];
+ currentQuestion++;
+ if (currentQuestion < questions.length) {
+ showQuestion();
+ } else {
+ showResults();
+ }
+ }
+
+ function showResults() {
+ quizSection.classList.add('hidden');
+ resultsSection.classList.remove('hidden');
+ const percentage = (score / (questions.length * 3)) * 100;
+ resultText.textContent = `Your business readiness score is ${percentage.toFixed(1)}%.`;
+ drawChart(percentage);
+ }
+
+ function drawChart(percentage) {
+ const ctx = document.getElementById('readiness-chart').getContext('2d');
+ new Chart(ctx, {
+ type: 'doughnut',
+ data: {
+ labels: ['Readiness', 'Remaining'],
+ datasets: [{
+ data: [percentage, 100 - percentage],
+ backgroundColor: ['#4a90e2', '#f5a623'],
+ borderWidth: 0
+ }]
+ },
+ options: {
+ responsive: true,
+ maintainAspectRatio: false,
+ cutout: '80%',
+ plugins: {
+ legend: {
+ display: false
+ }
+ }
+ }
+ });
+ }
+
+ retryBtn.addEventListener('click', () => {
+ currentQuestion = 0;
+ score = 0;
+ quizSection.classList.remove('hidden');
+ resultsSection.classList.add('hidden');
+ showQuestion();
+ });
+
+ showQuestion();