Do you think this will work...

Discussion in 'PHP' started by oo7ml, Oct 14, 2011.

  1. #1
    Hi

    Introduction
    I am creating an e-learning website that allows people to buy Education Courses for other people (college friends etc...). Receivers of these Courses have to sign into the website to complete one tutorial every day for the duration of the course... they cannot complete more than one tutorial each day. If receivers do not complete a tutorial each day, then they immediately fail the course, however the buyer can assign a number of lifelines to the user so they can miss a number of days during the duration of the course.

    Receivers will need to choose their timezone so that the site will know the start and end of each specific users day.

    Help Required
    I need some way of automating the courses and tutorials, to check if tutorials have been completed the previous day and to set up tutorials for the current day... so i have decided that the best way (IMO) is to create a cron script that will run at the very start of each users day.

    Considering each user will be from a different timezone, the cron will need to run every hour, on the hour (24 times a day at ##:00:01) however each time it runs, it will only need to query the courses who's day starts on the current hour that the script is running (current server hour)

    So considering the cron will be running at the very start of each users day, it can check the status of yesterdays tutorial and prepare the tutorial for the current day...

    I have tried to illustrate this in the image below... do you think this will work effectively... thanks in advance for your help...


    [​IMG]
     
    oo7ml, Oct 14, 2011 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    Yes it will, but a better way is the following

    you have tables for users, courses and a table that combines those 2. (user_cours => user_id, course_id, start = datetime, end=datetime)

    The only thing you have to do is when a user starts a course, add it into the user_cours table
    When a user finish that course you'll add the ending time.

    Now you can build your cronjob to update the courses that arn't finished (lets say not within 24 hours from start)
    Next is that you'll check the time between the 'end' and now() and if this is bigger then 24H the user should have 'free days left' or is ready to quit the course

    Hope you'll get this? :D
     
    EricBruggema, Oct 14, 2011 IP
  3. oo7ml

    oo7ml Well-Known Member

    Messages:
    656
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    105
    #3
    Hi, thanks for your reply, but sorry, i do not understand what you are saying... also i don't have a user_course table

    I have a receiver_id field in the course table that is used to link to the user...
     
    oo7ml, Oct 14, 2011 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    You don't start a project with any table. Add one.
     
    Rukbat, Oct 14, 2011 IP