SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Sep 2011
    Posts
    267
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    cron a script to run on the hour every hour.

    Find any user who's timezone makes (current_server_time +/- timezoneadjustment) = 00:00.
    Foreach such user, if daily_status = completed, day++, daily_status = incomplete.
    Use day to determine which tasks the user may access.

    I dont know how you want to react when a user hasnt completed their assignment for a given day, but
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  3. #3
    SitePoint Addict
    Join Date
    Sep 2011
    Posts
    267
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your reply... if a user does not complete a tutorial for a given day, the overall course status is set to "failed"...

    Can you elaborate as to why you would use and increment days...

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    Because it's all your system cares about? It's also a little bit easier (imo) than making the system do date math every time it runs or displays the client. I dont care when you started the course; If you've completed 7 days and your status is incomplete, then the first 7 lessons are done, the 8th is open and outstanding. If your status is complete, the first 7 lessons are done, and today's lesson is done. If you hit 14, you've completed the whole course.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  5. #5
    SitePoint Addict
    Join Date
    Sep 2011
    Posts
    267
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok cool, thanks...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •