The course completion cron code sometimes has to run twice before students are marked as complete in a course.
I think this is because:
- as part of completion_cron_mark_started() and maybe completion_cron_criteria(), records get inserted into course_completions with a reaggregate value of time()
- in completion_cron_completions(), only course completions with a reaggregate less than the the value of time() are checked
For small sites its possible for records that should be processed in completion_cron_completion() to get missed.
The function completion_cron_completions should check for records that have a reaggregate value less than *or equal* to the current value of time().