Elementor #847

Prostate Health Quiz: How Well Are You Taking Care of Your Prostate?

Discover the key to Optimal Prostate Health with This Quick Quiz

Awesome Quiz App | Ali Aslan
Some Rules of this Quiz
1. You will have only 15 seconds per each question.
2. Once you select your answer, it can't be undone.
3. You can't select any option once time goes off.
4. You can't exit from the Quiz while you're playing.
5. You'll get points on the basis of your correct answers.
Awesome Quiz Application
Time Left
15
You've completed the Quiz!
' + '
'+ questions[index].options[1] +'
' + '
'+ questions[index].options[2] +'
' + '
'+ questions[index].options[3] +'
'; que_text.innerHTML = que_tag; //adding new span tag inside que_tag option_list.innerHTML = option_tag; //adding new div tag inside option_tag const option = option_list.querySelectorAll(".option"); // set onclick attribute to all available options for(i=0; i < option.length; i++){ option[i].setAttribute("onclick", "optionSelected(this)"); } } // creating the new div tags which for icons let tickIconTag = '
'; let crossIconTag = '
'; //if user clicked on option function optionSelected(answer){ clearInterval(counter); //clear counter clearInterval(counterLine); //clear counterLine let userAns = answer.textContent; //getting user selected option let correcAns = questions[que_count].answer; //getting correct answer from array const allOptions = option_list.children.length; //getting all option items if(userAns == correcAns){ //if user selected option is equal to array's correct answer userScore += 1; //upgrading score value with 1 answer.classList.add("correct"); //adding green color to correct selected option answer.insertAdjacentHTML("beforeend", tickIconTag); //adding tick icon to correct selected option console.log("Correct Answer"); console.log("Your correct answers = " + userScore); }else{ answer.classList.add("incorrect"); //adding red color to correct selected option //answer.insertAdjacentHTML("beforeend", crossIconTag); //adding cross icon to correct selected option console.log("Wrong Answer"); for(i=0; i < allOptions; i++){ if(option_list.children[i].textContent == correcAns){ //if there is an option which is matched to an array answer option_list.children[i].setAttribute("class", "option correct"); //adding green color to matched option option_list.children[i].insertAdjacentHTML("beforeend", tickIconTag); //adding tick icon to matched option console.log("Auto selected correct answer."); } } } for(i=0; i < allOptions; i++){ option_list.children[i].classList.add("disabled"); //once user select an option then disabled all options } next_btn.classList.add("show"); //show the next button if user selected any option } function showResult(){ info_box.classList.remove("activeInfo"); //hide info box quiz_box.classList.remove("activeQuiz"); //hide quiz box result_box.classList.add("activeResult"); //show result box const scoreText = result_box.querySelector(".score_text"); if (userScore > 3){ // if user scored more than 3 //creating a new span tag and passing the user score number and total question number let scoreTag = 'and congrats! 🎉, You got

'+ userScore +'

out of

'+ questions.length +'

'; scoreText.innerHTML = scoreTag; //adding new span tag inside score_Text } else if(userScore > 1){ // if user scored more than 1 let scoreTag = 'and nice 😎, You got

'+ userScore +'

out of

'+ questions.length +'

'; scoreText.innerHTML = scoreTag; } else{ // if user scored less than 1 let scoreTag = 'and sorry 😐, You got only

'+ userScore +'

out of

'+ questions.length +'

'; scoreText.innerHTML = scoreTag; } } function startTimer(time){ counter = setInterval(timer, 1000); function timer(){ timeCount.textContent = time; //changing the value of timeCount with time value time--; //decrement the time value if(time < 9){ //if timer is less than 9 let addZero = timeCount.textContent; timeCount.textContent = "0" + addZero; //add a 0 before time value } if(time < 0){ //if timer is less than 0 clearInterval(counter); //clear counter timeText.textContent = "Time Off"; //change the time text to time off const allOptions = option_list.children.length; //getting all option items let correcAns = questions[que_count].answer; //getting correct answer from array for(i=0; i < allOptions; i++){ if(option_list.children[i].textContent == correcAns){ //if there is an option which is matched to an array answer option_list.children[i].setAttribute("class", "option correct"); //adding green color to matched option option_list.children[i].insertAdjacentHTML("beforeend", tickIconTag); //adding tick icon to matched option console.log("Time Off: Auto selected correct answer."); } } for(i=0; i < allOptions; i++){ option_list.children[i].classList.add("disabled"); //once user select an option then disabled all options } next_btn.classList.add("show"); //show the next button if user selected any option } } } function startTimerLine(time){ counterLine = setInterval(timer, 29); function timer(){ time += 1; //upgrading time value with 1 time_line.style.width = time + "px"; //increasing width of time_line with px by time value if(time > 549){ //if time value is greater than 549 clearInterval(counterLine); //clear counterLine } } } function queCounter(index){ //creating a new span tag and passing the question number and total question let totalQueCounTag = '

'+ index +'

of

'+ questions.length +'

Questions
'; bottom_ques_counter.innerHTML = totalQueCounTag; //adding new span tag inside bottom_ques_counter }