• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

Automating timers

Hi, my site allows people to buy e-learning courses for other people. As soon as a person receives and starts a course, they must complete daily tutorials every day for the period of the course.
Most courses take 2 weeks to complete, so this means the person will have to login and complete a tutorial every day for 2 weeks (14 days)

When a user logins to complete a tutorial each day, they will have to read several course notes and then at the end, they will have to complete a very easy interactive task, such as dragging a round ball and dropping it into a round hole. This small interactive task is very important as it marks the tutorial for that day as “complete” for that day. If they do not complete the interactive task, then the tutorial will not be completed for that day and they will fail the entire course.

Once a user has completed the daily tutorial, they cannot start the next (tomorrows) tutorial until the start of a new day (00:00) and they must complete each tutorial before the end of their day (23:59)

Considering users will be from different time zones, they must choose their timezone before starting their very first course. This will allow the site to calculate the start and end time of a user’s day.

My question is:
How should I create and automate this function so that the site can monitor and control the timing and completion of tutorials. I was thinking I need to add additional fields to the course table in the database such as:

$duration (the length of the course)
$start_date (the date the user starts the first tutorial of the course)
$end_date (the $start_date + ($duration (2 weeks) ))
$time_zone (this will be used to calculate the users time, in order to signify the start and end of their day)
$daily_status (incomplete, completed)

I am sure I need more fields, but first I need to establish how I can automate all of this

P.S – I am not worried about how I will automate what notes or interactive task need to be displayed and completed each day… I am only looking for help on how I can automate the time and completion of each tutorial each day, thanks in advance for your help
2 Solutions
Hugh McCurdyCommented:
I fear that I misunderstand the question.  This doesn't seem like automatic timing.

Related to control of access, the user will make page load requests throughout the day and the request will either be inside or outside the window (the day).  It's a simple comparison of the current to the boundary times for the daily window.

I am concerned about your data and what I view as a lack of flexibility.  

I would expand the daily status to an array of size 14 so that you can track each day.  Instead of just complete/incomplete, perhaps you should record the date and time it was completed.  I would also avoid hard coding 14 to much into the code especially considering that PHP is loosely typed.  At some point, someone may ask you to setup a 10 day or 21 day class.

Another, and I think more important, flexibility concern is that people have lives and things happen in those lives.  While you can state the rule that they must complete the tutorial, once per day for 14 days in a row, I think that plan is going to get you into trouble with unhappy customers, lost business, etc.

One simple observation is that some people's beliefs prevent them from working on a particular day of the week or on certain holidays.  How many Christians are going to schedule the tutorial if the 14 days spans Good Friday and Easter?  If nothing else, the strict plan creates a revenue hole based on the calendar.

Another problem is that, because people have lives, surprise events happen.  People get sick.  Do you really want to deal with a mother who completed 13 sessions but on the 14th day her daughter ended up in the emergency room?  Of course, she's going with her daughter to the ER.

What if the student encounters a power failure that lasts several hours and is truly unable to take the class one day because of it?  Or what if there's a hurricane and much of the east coast of the US evacuates?  (Or Katrina in New Orleans a few years ago?)

You customers will have good reasons and will almost certainly become angry with you if you don't accept those good reasons.  Even if you want to accept the good reason, your software design doesn't yet accommodate.  

Part of the solution is to track each day as an independent event (the "14" element array).  Another is to not insist (include a test) that day 13's work has to actually be done on day 13 but that it could be done on day 15.
Ray PaseurCommented:
You can learn the way to handle the DATETIME things from this article.  Clients in different time zones are a fairly common issue.

Please read that over and then post back with any specific questions.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now