arnav1776/Hogwarts

Adding timer to the quiz

Closed this issue · 7 comments

Is your feature request related to a problem? Please describe.
Adding timer to each questions or to the whole quiz in the quiz will make it more realistic quiz.

Please do assign me this issue.

@arnav1776 should I timer to each question or to the whole quiz?

@Code-Aditya-14 I think it would be better to add it to each question, like 15 or 20 seconds per question.

@Code-Aditya-14 Make sure that it switches to the next question after answering & not just remains on the page until the timer gets over.

@arnav1776 This is the changes I made:

image

Please let me know if any changes in design is needed. Added timer of 15 seconds in each questions.
Also there is little interval in the timer in starting the timer after displaying the questions. Please let me know if it can be fixed.
I will create the PR soon.

Try doing it like this, and the design looks good no changes are required for it.

var count = 15;
var interval = setInterval(function(){
document.getElementById('count').innerHTML=count;
count--;
if (count === 0){
clearInterval(interval);
document.getElementById('count').innerHTML='Done';
// or...
alert("You're out of time!");
}
}, 1000);

@arnav1776 Thanks, with alert function getting that on time. I had created the PR. Also not writing done

document.getElementById('count').innerHTML='Done';

If it is needed please let me know. :)

@Code-Aditya-14 No that's not required, it was just for an example, thanks for contributing.