MDL-46651 Check for existing course completion record before inserting