const yourQuiz = [] const createQuizBtn = document.getElementById('create_constructor') createQuizBtn.onclick = (e) => { e.preventDefault(); e.stopPropagation(); document.querySelector('#button-block').setAttribute('display', 'none'); buildConstructor(); } const titleOfQuiz = () => { const header = document.querySelector('.main-header') const userQuizTitle = document.createElement('h2') } const buildConstructor = () => { const templateForm = document.createElement('form') templateForm.className = "template_form" templateForm.innerHTML = `
Quiz Constructor

` document.querySelector('#quiz_constructor').appendChild(templateForm); document.querySelector('.add_answer').onclick = (e) => { e.preventDefault(); e.stopPropagation(); let answerContainer = document.querySelector('.constructor_answers'); const frame = document.createElement('p'); frame.innerHTML = ` ` answerContainer.appendChild(frame); } document.querySelector('.add_question').onclick = (e) => { e.preventDefault(); e.stopPropagation(); yourQuiz.push(newQuestion()) setConstructorToLS(yourQuiz); templateForm.remove(); buildConstructor(); } console.log(yourQuiz) const btnStartYourQuiz = document.getElementById('btnStart'); btnStartYourQuiz.onclick = (e) => { e.preventDefault(); e.stopPropagation(); setConstructorToLS(); templateForm.remove(); initializeClock('countdown', deadline); buildQuiz(); localStorage.setItem('timeinterval', initializeClock('countdown', deadline)); } } titleQuiz = document.querySelector('#titleQuiz') const newQuestion = () => { const questionCust = document.querySelector('#customerQuestion').value; const letterCust = document.querySelector('.constructor_answer_letter').value; const answerCust = document.querySelector('.constructor_answer').value; const correctAnswerLetter = document.querySelector('#correct_answer_letter').value; let answers = [] for (letterCust in questionCust.answers) { answerCust = questionCust.answers[letterCust] answers.push(`${letterCust} : ${answerCust}`) } return { question: questionCust, answers: {...[answers].map(item => item.key)}, correctAnswer: correctAnswerLetter } }