course completion: MDL-2631 Fix rare mark_completed bug