at the moment course completion is performed by "Calculate regular completion data" cron job.
The problem is that the student waits a few minutes before the course is marked as completed.
I'm thinking about creating a plugin, that will listen for activity completion event, then will check if corresponding course (for the given user) should be completed.
Is there any reason why the course completion is done in a cron and not "on the fly?
One of the problems that may occur is that a single course completion may trigger recursive completion of many courses. Anyway, I don't think that this will be a huge performance problem.