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...
Just to clarify,
If I started my first task last night at 22:30 hrs and completed it by 23:30, then am I not able to start my second tast a few hours later, say at 00:30 today?
Or do you mean 24 hours must elapse between the start of tasks?
Hi, thanks for your reply... considering you started your first task at 22:30, then your $first_hour is recorded and set as 22:00
Also, considering you have now completed your first task, $today_status = complete and it will not be turned back to incomplete until the CRON runs at 22:00 (your $first_hour) where it will check if the task was completed for the previous day along with turning it back to incomplete so it can be started again
So if I started my first task at 2200 last night, and I do not complete task 2 by 2300 today, I get rolled back and have to start again at task 1 - is that the case?
Kind of... but you will not be rolled back... you will simply fail the course...
I have drawn out what i mean below... a cron runs every hour on the hour but only queries courses where $first_hour = current_hour
If you start your first task at 15:07, you cannot start the second task until after 15:00 the next day, until the cron turns $today_status back to incomplete... and then you have to complete the task within 24 hours...
This topic is now closed. New replies are no longer allowed.