Jump to content

Recommended Posts

I want to assemble a multi-page questionnaire/quiz whereby submitting page 1 will lead to page 2 etc.

I have locked in the time that each page loads by using

unset($_SESSION['start']);

if($_SESSION['start'] == ""){
$_SESSION['start'] = time();
}

at the top of each page

However, I am having difficulty in getting the time at submission.

I realize I can simply use the start time of page 2 as the submission time for page 1, but that would technically be incorrect, right?

In actuality, a page would load (and the time recorded). A person would submit after any amount of expended time (and that would be recorded) Then there would be a gap before the next page loaded.

How can I effectively obtain these events?  Or am I unnecessarily overthinking this?

 

Link to comment
https://forums.phpfreaks.com/topic/316126-page-load-and-submit-times/
Share on other sites

If you want to measure the time from when the page starts processing until the page is loaded in the browser, you cannot do that strictly with PHP.  You'd have to capture the start time at the start of your PHP script, and the finish time via JavaScript's onload event.  This metric isn't really all that useful though.  How long it takes the page content to be loaded and processed will depend on the user's network speed which is beyond your control.  If you're looking to optimize your page load times, you should be looking at the PHP processing and browser loading/processing separately rather than as a combined single load time.

You could measure the processing time of your script in PHP by capturing the start time at the beginning of your script, then the ending time when your script ends.  This metric would tell you if your PHP is slow to process, which you could use to determine if you need to improve areas of your code.  Actual code profiling over just a simple load time would be better if this is your goal.

For the browser side of things, the browser developer tools include profiling/performance tools to measure your pages resource load times, rendering times, etc.

 

@kicken  Thanks for the help, but I wasn't as clear as I should have been.

I'm not interested in the page loading speeds (at this time)

I am only trying to determine how long each user remained on the specific page before advancing.  This would let me know if a question was too complicated, or maybe randomly answered.

Hypothetically, it would take more than 3 seconds to write 500 words versus cut & pasting. Likewise, if it took 20 minutes to add 3 + 3, then maybe you were distracted from the webpage, etc.

Or, maybe my design or layout is not easy enough to follow.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.