Go Premium for a chance to win a PS4. Enter to Win


Automating timers

Posted on 2011-09-26
Medium Priority
Last Modified: 2012-05-12
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
Question by:oo7ml
LVL 13

Assisted Solution

by:Hugh McCurdy
Hugh McCurdy earned 600 total points
ID: 36599292
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.
LVL 111

Accepted Solution

Ray Paseur earned 1400 total points
ID: 36599387
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.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question