Project Overview:
I need a JavaScript countdown timer for a quiz application I’m working on, that keeps track of users time on a page, if the user leaves the page or closes their browser before the time runs out, then comes back days later the timer will need to pick backup where they left off. The script will need to use JavaScript, Ajax, PHP, mySQL.
This is how I see the system working:
When the page loads the first time the script uses ajax to call a PHP file that looks in a mySQL database to see if the current user has loaded the page before, if not then start the counter from the time set in the JavaScript variables, the script will need to call and add the user to the database if they currently do not have a session, if the user has an open session in the database the script will need to update the time, the script will need to update the database every 30 seconds.
This script will be getting integrated in to a larger quiz application. The main file should be called “[login to view URL]”, the PHP file that calls the database can be called “[login to view URL]”, the JavaScript file can be called “[login to view URL]”.
The mySQL table will need to be named “jos_quiz_timer_sessions” and it will need to have the following columns “id, user, quiz, time”.
I Read your synopsis of your needs, and feel that I can help you out. The one question I do have is does the counter HAVE to have the time stored in JS or are you open to having a different approach toward the solution to your problem? I am willing and ready to help you out.
Thanks!
Tony