// Menyusun pertanyaan dan jawaban

const questions = [
  {
    question: "Ukuran panjang lapangan bola voli adalah  …..",
    options: ["14 meter", "16 meter", "18 meter", "20 meter"],
  },
  // ... tambahkan pertanyaan dan opsi lainnya
];

// Fungsi untuk mengacak opsi jawaban
function shuffleOptions(options) {
  for (let i = options.length - 1; i > 0; i--) {
    const j = Math.floor(Math.random() * (i + 1));
    [options[i], options[j]] = [options[j], options[i]];
  }
  return options;
}

// Membuat pertanyaan-pertanyaan dalam formulir Google
function createGoogleForm() {
  const form = FormApp.create('Quiz Olahraga');
  const formId = form.getId();

  questions.forEach((q, index) => {
    const item = form.addMultipleChoiceItem();
    const shuffledOptions = shuffleOptions([...q.options]);

    item.setTitle(q.question)
      .setChoiceValues(shuffledOptions)
      .setRequired(true);

    // Menambahkan section untuk setiap 10 pertanyaan
    if ((index + 1) % 10 === 0 && index !== questions.length - 1) {
      form.addSectionHeaderItem().setTitle(`Bagian ${Math.ceil((index + 1) / 10)}`);
    }
  });

  Logger.log(`Formulir Google telah dibuat. ID: ${formId}`);
}

// Menjalankan fungsi untuk membuat formulir
createGoogleForm();