Changed around line 1
+ const questions = [
+ {
+ question: "What does BTP stand for in SAP BTP?",
+ answers: ["Business Technology Platform", "Business Technical Process", "Basic Technology Platform", "Business Transform Platform"],
+ correct: 0
+ },
+ {
+ question: "Which of these is NOT a core capability of SAP BTP?",
+ answers: ["Database Management", "Application Development", "Hardware Manufacturing", "Integration"],
+ correct: 2
+ },
+ // Add more questions here (20-30 total)
+ ];
+
+ let currentQuestion = 0;
+ let score = 0;
+ let wrongAnswers = [];
+
+ const questionEl = document.getElementById('question');
+ const answersEl = document.getElementById('answers');
+ const scoreEl = document.getElementById('current-score');
+ const nextBtn = document.getElementById('next-btn');
+ const scoreContainer = document.getElementById('score-container');
+ const questionContainer = document.getElementById('question-container');
+ const finalResults = document.getElementById('final-results');
+ const finalScoreEl = document.getElementById('final-score');
+ const totalQuestionsEl = document.getElementById('total-questions');
+ const reviewAnswersEl = document.getElementById('review-answers');
+ const progressEl = document.getElementById('progress');
+ const restartBtn = document.getElementById('restart-btn');
+
+ function startQuiz() {
+ currentQuestion = 0;
+ score = 0;
+ wrongAnswers = [];
+ showQuestion();
+ updateProgress();
+ }
+
+ function showQuestion() {
+ const question = questions[currentQuestion];
+ questionEl.textContent = question.question;
+ answersEl.innerHTML = '';
+
+ question.answers.forEach((answer, index) => {
+ const button = document.createElement('button');
+ button.textContent = answer;
+ button.classList.add('answer-btn');
+ button.addEventListener('click', () => selectAnswer(index));
+ answersEl.appendChild(button);
+ });
+
+ questionContainer.classList.remove('hidden');
+ scoreContainer.classList.add('hidden');
+ finalResults.classList.add('hidden');
+ }
+
+ function selectAnswer(answerIndex) {
+ const correct = questions[currentQuestion].correct === answerIndex;
+ const buttons = answersEl.getElementsByTagName('button');
+
+ Array.from(buttons).forEach(button => {
+ button.disabled = true;
+ });
+
+ if (correct) {
+ buttons[answerIndex].classList.add('correct');
+ score++;
+ } else {
+ buttons[answerIndex].classList.add('wrong');
+ buttons[questions[currentQuestion].correct].classList.add('correct');
+ wrongAnswers.push({
+ question: questions[currentQuestion].question,
+ wrongAnswer: questions[currentQuestion].answers[answerIndex],
+ correctAnswer: questions[currentQuestion].answers[questions[currentQuestion].correct]
+ });
+ }
+
+ scoreEl.textContent = score;
+ questionContainer.classList.add('hidden');
+ scoreContainer.classList.remove('hidden');
+ updateProgress();
+ }
+
+ function nextQuestion() {
+ currentQuestion++;
+
+ if (currentQuestion < questions.length) {
+ showQuestion();
+ } else {
+ showFinalResults();
+ }
+ }
+
+ function showFinalResults() {
+ questionContainer.classList.add('hidden');
+ scoreContainer.classList.add('hidden');
+ finalResults.classList.remove('hidden');
+
+ finalScoreEl.textContent = score;
+ totalQuestionsEl.textContent = questions.length;
+
+ reviewAnswersEl.innerHTML = '';
+ wrongAnswers.forEach(wrong => {
+ const reviewItem = document.createElement('div');
+ reviewItem.classList.add('review-item', 'incorrect');
+ reviewItem.innerHTML = `
+
Question: ${wrong.question}
+
Your Answer: ${wrong.wrongAnswer}
+
Correct Answer: ${wrong.correctAnswer}
+ `;
+ reviewAnswersEl.appendChild(reviewItem);
+ });
+ }
+
+ function updateProgress() {
+ const progress = ((currentQuestion + 1) / questions.length) * 100;
+ progressEl.style.width = `${progress}%`;
+ }
+
+ nextBtn.addEventListener('click', nextQuestion);
+ restartBtn.addEventListener('click', startQuiz);
+
+ startQuiz();