By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,890 Members | 1,039 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,890 IT Pros & Developers. It's quick & easy.

Recording user session durations

P: n/a
PWS
Hi all,

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.

I tried to tackle this problem using PHP, Javascript and cookies. When
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
time, that page will create a cookie for that module and javascript is
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
javascript timer starts again. When the user has passed the module
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
appreciate.

Thanks.
Sep 23 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 23 Sep, 11:44, PWS <phyow...@gmail.comwrote:
Hi all,

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.

I tried to tackle this problem using PHP, Javascript and cookies. When
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
time, that page will create a cookie for that module and javascript is
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
javascript timer starts again. When the user has passed the module
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
appreciate.

Thanks.
This is of course impossible. You have no idea what a student may be
doing at any time.
Sep 23 '08 #2

P: n/a
PWS wrote:
Hi all,

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.

I tried to tackle this problem using PHP, Javascript and cookies. When
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
time, that page will create a cookie for that module and javascript is
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
javascript timer starts again. When the user has passed the module
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
appreciate.

Thanks.
You can't reliably recored durations such as this with PHP and/or
javascript. It's just not possible.

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
computer)?

A java applet is probably your best way to go for something like this.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 23 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.