Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Recording user session durations
September 23, 2008, 10:44 am
rate this thread
I developed an online learning website where each student has his own
username/password and they can view course materials and take tests
online. I did that in PHP and PostgreSQL.
Now, I need to implement a function that I don't seem to be doing
right. A course has multiple modules under it and a module has several
pages, all are done in PHP. I am required to log the times (durations)
each student spends on a module. Duration is counted as the total time
a student spends reading pages of a module and taking the test.
Duration counting stops when the student passed the module test. It's
not (start time - end time). It might take 3 days for a student to
read a module's materials and take the test, however, the actual
duration he spent on the module might be 10 hours.
To make things more complicated, there is no sequence a student reads
modules. He can read some pages in module 1, jump to module 5 and come
back to module 1 again.
a new student opens a page of a module, that time is Starttime,
written to the duration field of a table in postgres. At the same
used to start a timer on user's PC. When the user leaves that page,
that timer is stopped and duration is recorded in the cookie. When the
user visits another page of the module, if there is a duration
recorded in the module's cookie, it is added to the duration field in
the postgres table. The duration field in the cookie is then reset and
test, duration counting stops and the end time is recorded.
It's not an elegant solution I know but that's the only way I can
think of since PHP alone can't handle the duration recording. When I
tested it with many users, I see mixed results. Some durations seem to
be ok but some are way off; either too big or too small (like 0.5
minutes). I tried different ways but it doesn't solve the problem.
I have been searching for a solution to this problem and haven't found
anything. If anyone can suggest me a solution, I would really
- Captain Paralytic
September 23, 2008, 11:43 am
Re: Recording user session durations
You can't reliably recored durations such as this with PHP and/or
You know the problem with doing it server-side. And many users have
their browsers set to delete cookies when the browser is closed, so your
cookie idea is bound to fail. And what happens if the student accesses
the page from two (or more) computers (or two or more students share a
A java applet is probably your best way to go for something like this.
Remove the "x" from my email address
JDS Computer Training Corp.
Re: Recording user session durations
When you start a module, the logged-in student accesses the module's
first page. You can add code on each module's page to log the date/time
stamp into postgres. I don't know if there's a way to log the date/time
stamp of when they leave the page, but essentially that's what you need.
can be turned off and varies from system to system and browser to
browser. PHP has sessions which depend on cookies. You might read up
You may be better off with a module start and stop page to log those
times and each sub-page has a start/stop page. The duration would be
Until you can come up with a way to measure the time the student spends
on each page of a module, you won't solve this problem. You can't code
what you don't fundamentally understand.
DeeDee, don't press that button! DeeDee! NO! Dee...
[I filter all Goggle Groups posts, so any reply may be automatically by ignored]
- » getting parameters to send then to another function
- — Next thread in » PHP Scripting Forum
- » When would you use an abstract class and when an interface?
- — Previous thread in » PHP Scripting Forum