Hi, my site requires users to complete a certain task on the site everyday before the end of the day 23:59:59 (don't worry about timezones or the task)
The task has a $today_status (complete or incomplete)
I have a cron that runs at the start of the day (00:00:01) to do 2 things:
01 - check if all tasks were completed yesterday (check for all tasks that are still incomplete)
02 - reset all of yesterdays tasks back to incomplete so the user can start the task again today (for the new day)
Each task has a count down timer displayed next to it so that the user can see one of the following two timers:
A (IF $today_status = incomplete) - the time they have left to complete the task (counting down to the end of the day)
B (IF $today_status = complete) - the time they have to wait before they can complete the second task (counting down to the end of the day)
I have 2 small problems that are related:
The crons runs as soon as it turns into a new day at 00:00:01 however the cron not might finish processing all of the tasks until 00:07:19 so there is a 7 min error gap... this could increase as more users join.
So, if the user has completed the task for the previous day, and then views the task at 00:03:27 the next day... $today_status could still be 'completed' as the cron might not have processed it for the previous day yet... and there for the timer will say
(time left to wait before you can start the next task)
It will say the above because it is still in 'complete' status... however the user just logged in early so they could complete today's task early BUT the site is telling them otherwise... it is telling them they have to wait until tomorrow to complete the next task...
I hope i am explaining this correctly and thank you so much if you have bothered to read down this far... any help will be greatly appreciated... thanks in advance
Timestamp? Store a timestamp for when user last did a task?
With a timestamp you can check individually instead of by cron?
If a timestamp cant do, why not tell the script the cron job has started, and as such the task is not yet available? Set a flag in a file, or DB.
You are a bit vague... The above is just fishing for a solution.
I'd run this slightly different so that you don't need a cron job, just a query to check progress for whenever you feel like it.
whatever your current setup is
on the server side in php, ensure that multiples are done for the same day before insertion into completions, this will allow the user to work ahead if you / they want to without a cron running.
This topic is now closed. New replies are no longer allowed.