Bank Soal SD - Sejarah Indonesia
// Data Soal
const questions = [
{ question: "Siapa Proklamator Kemerdekaan Indonesia?", options: ["Ir. Soekarno & Drs. Moh. Hatta", "RA Kartini", "Diponegoro"], correct: 0 },
{ question: "Tanggal berapa Indonesia merdeka?", options: ["17 Agustus 1945", "20 Mei 1908", "28 Oktober 1928"], correct: 0 },
{ question: "Apa nama lagu kebangsaan Indonesia?", options: ["Indonesia Pusaka", "Hari Merdeka", "Indonesia Raya"], correct: 2 },
{ question: "Siapa yang menjahit bendera Merah Putih?", options: ["Fatmawati", "RA Kartini", "Cut Nyak Dien"], correct: 0 },
{ question: "Dimana teks proklamasi dibacakan?", options: ["Bandung", "Jakarta", "Yogyakarta"], correct: 1 },
{ question: "Siapa yang menulis teks Proklamasi?", options: ["Bung Hatta", "Ir. Soekarno", "Ahmad Soebardjo"], correct: 1 },
{ question: "Kapan Sumpah Pemuda diikrarkan?", options: ["28 Oktober 1928", "20 Mei 1908", "1 Juni 1945"], correct: 0 },
{ question: "Apa nama kerajaan Hindu tertua di Indonesia?", options: ["Sriwijaya", "Majapahit", "Kutai"], correct: 2 },
{ question: "Apa nama kapal yang digunakan untuk mengangkut Soekarno-Hatta ke Rengasdengklok?", options: ["KRI Dewaruci", "Diana", "Hudson"], correct: 1 },
{ question: "Siapa tokoh wanita pahlawan nasional dari Aceh?", options: ["Cut Nyak Dien", "Dewi Sartika", "Fatmawati"], correct: 0 },
];
let currentQuestionIndex = 0;
let score = 0;
function loadQuestion() {
if (currentQuestionIndex >= questions.length) {
document.getElementById("question-section").innerHTML = `
Selamat! Anda telah menyelesaikan semua soal.
Skor Anda: ${score}/${questions.length}
`;
return;
}
const questionData = questions[currentQuestionIndex];
const questionHTML = `
${questionData.question}
${questionData.options
.map(
(option, index) =>
`
`
)
.join("")}
`;
document.getElementById("question-section").innerHTML = questionHTML;
updateHeader();
}
function updateHeader() {
document.getElementById("questions-left").innerText = questions.length - currentQuestionIndex;
document.getElementById("score").innerText = score;
}
function checkAnswer(selectedOption) {
const questionData = questions[currentQuestionIndex];
const correctSound = document.getElementById("correct-sound");
const wrongSound = document.getElementById("wrong-sound");
if (selectedOption === questionData.correct) {
score++;
correctSound.play();
alert("Jawaban Anda benar!");
} else {
wrongSound.play();
alert(`Jawaban Anda salah! Jawaban yang benar adalah: ${questionData.options[questionData.correct]}`);
}
currentQuestionIndex++;
loadQuestion();
}
// Muat soal pertama
loadQuestion();