document.addEventListener('DOMContentLoaded', function () { const addQuestionButtons = document.querySelectorAll('.add-question-btn'); const questionsContainer = document.getElementById('questions-container'); let questionCounter = 0; addQuestionButtons.forEach(button => { button.addEventListener('click', function () { const type = this.dataset.type; addQuestion(type); }); }); function addQuestion(type) { questionCounter++; const questionId = `question-${questionCounter}`; let questionHtml = `
Question ${questionCounter}
`; switch (type) { case 'text': questionHtml += `

A short text answer will be collected.

`; break; case 'multiple-choice': case 'checkboxes': questionHtml += `
`; break; } questionHtml += `
`; questionsContainer.insertAdjacentHTML('beforeend', questionHtml); } window.addOption = function(questionId, questionIndex) { const optionsContainer = document.getElementById(`${questionId}-options-container`); const optionHtml = `
`; optionsContainer.insertAdjacentHTML('beforeend', optionHtml); } });