Sounds pretty complicated. Have you tried using the Course Duration option in the course settings? It basically allows students to remain enrolled in a course for a specific duration. It can be anything from a few seconds to many weeks.
You'll find the option in your course's self-enrolment and manual enrolment settings.
Hope you find this useful.