k21chrono Posted November 6, 2009 Share Posted November 6, 2009 The only part i need help with is the timing element, like it needs to start the timer when the page loads and the timer stops when they submit the quiz/survey. Quote Link to comment https://forums.phpfreaks.com/topic/180575-how-would-you-create-a-timed-survey-or-quiz/ Share on other sites More sharing options...
mrMarcus Posted November 6, 2009 Share Posted November 6, 2009 upon starting the quiz (opening the page or whatever), record a timestamp either in a db, file or session variable. then, upon completion of the quiz, grab a timestamp as well. then, minus the last first timestamp from the last recorded timestamp, and there you go .. the difference would be the total amount time spent taking the quiz. Quote Link to comment https://forums.phpfreaks.com/topic/180575-how-would-you-create-a-timed-survey-or-quiz/#findComment-952682 Share on other sites More sharing options...
mikesta707 Posted November 6, 2009 Share Posted November 6, 2009 Alternatively you could use javascript, but it may be better to go with the session idea as javascript can be turned off, and changed and all that stuff Quote Link to comment https://forums.phpfreaks.com/topic/180575-how-would-you-create-a-timed-survey-or-quiz/#findComment-952685 Share on other sites More sharing options...
k21chrono Posted November 9, 2009 Author Share Posted November 9, 2009 Mkay could you give me the syntax for grabbing a timestamp like as in how you would do what you just said lol Quote Link to comment https://forums.phpfreaks.com/topic/180575-how-would-you-create-a-timed-survey-or-quiz/#findComment-954236 Share on other sites More sharing options...
mikesta707 Posted November 9, 2009 Share Posted November 9, 2009 you can get a timestamp with the time() function. $timeStart = time(); When you submit the form on the processing page you could have $timeEnd = time(); obviously you will need to sent the start time to the next page (through a hidden field, a session, save it to a DB, etc.) Quote Link to comment https://forums.phpfreaks.com/topic/180575-how-would-you-create-a-timed-survey-or-quiz/#findComment-954265 Share on other sites More sharing options...
k21chrono Posted November 11, 2009 Author Share Posted November 11, 2009 Okay i've got the times set up using cookied variables now i just need to know how i would subtract the two time values, sorry for the really noobish question btw. Quote Link to comment https://forums.phpfreaks.com/topic/180575-how-would-you-create-a-timed-survey-or-quiz/#findComment-955709 Share on other sites More sharing options...
Daniel0 Posted November 11, 2009 Share Posted November 11, 2009 You would want to use sessions, not cookies. Otherwise it would be trivial to cheat it. Cookies are stored with the user, session data is stored on the server. Quote Link to comment https://forums.phpfreaks.com/topic/180575-how-would-you-create-a-timed-survey-or-quiz/#findComment-955749 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.