We have a Moodle course that requires students to complete mandatory training Lessons and Quizzes. Before entering the course, students are asked to put in a specific enrolment key which then allocates them to a group (specific to their year - a '1st year BSc' group for example). Students complete the Lessons and Quizzes. Their self-enrolment method duration is set to 24 weeks so their enrolment becomes inactive at that point.
The following year, the same students are required to take the Lessons and Quizzes (random questions) again. However, they need to insert a new enrolment key so that they can be allocated to the correct group - 2nd year BSc for example.
In this course, although the students enrolment method is inactive after 24 weeks, they are still attached to their group, so when they try to login the next year, they are not asked for an enrolment key and they still appear in their original group.
I might be missing a really obvious setting here, but how can I remove users from their groups when their enrolment expires? To ensure that when they next try to login, it asks them for an enrolment key again.
Any help or advice would be greatly appreciated. Previously using Moodle 2.7 but now on 2.9.