Login Register


Quiz Timer filter_list
Author
Message
RE: Quiz Timer #9
(07-16-2014, 07:10 PM)h3r0 Wrote: The issue with having a JS timer would have to be cheating. But the method WILL be storing a unix time stamp somewhere. You could go with storing it in a PHP session..
Code:
$date = new DateTime(); $_SESSION['last_submit_time'] = $date->getTimestamp();
This allows you to use AJAX or just use PHP and when the page loads inject the $_SESSION['last_submit_time'] into the JS.

But if you were feeling a little dangerous you can do some HTML5 Web Storage which is a local database http://www.w3schools.com/html/html5_webstorage.asp
Issue with that is that it could be edited by the user.


I would suggest going the pure PHP route (No Ajax) because what if a user doesn't have Javascript. Or use Ajax and fall back onto to PHP (This is probably the best and most professional route if you plan on making this a reusable piece of software to sell)
You could also make a fallback for non js users.

The possibilities of js/jquery/ajax + php will provide the user with a nicer experience in realtime. Personally I always show a message if js isn't supported or if noscript is running on the browser. I don't really care about the small percentage of users that don't have js support in their browser. Of course it's a different thing if you're building an app for a client.

Reply





Messages In This Thread
Quiz Timer - by Ex094 - 07-16-2014, 09:59 AM



Users browsing this thread: 1 Guest(s)