Hi, my site allows users (buyers) to buy e-learning courses for other users (receivers). In order to complete a course, the receiver must complete the same task every single day for duration of the course (1 week)
When a user starts the first task, the time is recorded and the receiver must complete the task each day before that hour ($first_hour) each day (i.e: on day 1, if the receiver starts the first task of the mission at 15:45pm then the receiver will have to complete the rest of the tasks for that mission before 15:00pm each day. The receiver can only complete one task per day.
A receiver can have many different courses assigned to their account, so when the receiver logs into their account, they will be re-directed to the my-account.php page where they will see a count down timer.
The timer will display one of two things:
1 (priority) - get the closest incomplete mission where the $first_hour is greater than the current time (where current time HAS NOT passed $first_hour) and display count down timer for "TIME LEFT TO COMPLETE NEXT TASK"
IF THERE ARE NO INCOMPLETE MISSIONS
2 - get the closest complete mission where the $first_hour is less than the current time (where current time HAS passed $first_hour) and display the timer for "TIME LEFT BEFORE YOU CAN START NEXT TASK"
Here is my pseudo code:
SELECT * (or whatever is needed) FROM courses WHERE $course_status = live AND $receiver_id = user_session
IF result = 0, then change timer counter to display "no live courses"
SELECT * (or whatever is needed) FROM courses WHERE $today_status = incomplete AND $first_hour is > than current_time ORD $first_hour DESC, LIMIT 1
IF result is not 0
01 - display the counter for "TIME LEFT TO COMPLETE NEXT TASK"
ELSE if result is 0
SELECT * (or whatever is needed) FROM courses WHERE $today_status = complete AND $first_hour is < than current_time ORD $first_hour DESC, LIMIT 1
01 - display the counter for "TIME LEFT BEFORE YOU CAN START NEXT TASK"
My code is only pseudo code and i know if it all over the place but i just want to know if you think it is on the right path, thanks in advance...