Moodle

Retain group memberships after unenrolling/re-enrolling

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.9.5, 2.0
  • Fix Version/s: 2.0
  • Component/s: Groups
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE, MOODLE_20_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

Currently the role_unassign function does some cleanup of group memberships and lastaccess dates. This means when a student is unenrolled then re-enrolled they lose their group memberships. This is contrary to most other features of Moodle such as assignment submissions, forum posts etc which will re-appear when the student gets their access back.

This is especially problematic when using external systems for enrolments, because every time something goes wrong with the system and roles get unassigned, group memberships have to be recovered from a backed up copy of the database. The group memberships / lastaccess are the only parts that get lost upon dropping and regaining a role - everything else returns as if the access was never lost.

The cleanup is based on the 'moodle/course:view' capability, so even if the students role changes from 'student' to 'withdrawnstudent' (a role without moodle/course:view capability), the group memberships / access dates are lost.

Simply commenting out the cleanup code might not be a suitable solution since lots of code relies on the groups_members table being current. What about having a groups_members_archive table which can be used to reassign group memberships? Perhaps this might be an optional feature since some people might not want group memberships restored.

I see this as a critical feature for institutions who rely on third party systems for enrolments - we have been hit by this problem repeatedly for different clients. Whenever there is a hiccup in enrolments (whether it be caused by an administrative error or a software bug), we have to go to backups to recover the lost groups memberships.

Thanks

Activity

Hide
Petr Škoda (skodak) added a comment -

Sorry, we do have to cleanup data after unenroling. The reason is code complexity and performance. We will also need to fix user deleting and finally allow full data purging if requested.

I think proper solution is to completely redesign enrolments and prevent both software bugs and administration errors.

Show
Petr Škoda (skodak) added a comment - Sorry, we do have to cleanup data after unenroling. The reason is code complexity and performance. We will also need to fix user deleting and finally allow full data purging if requested. I think proper solution is to completely redesign enrolments and prevent both software bugs and administration errors.
Hide
Ashley Holman added a comment -

Hi Peter,

There are often unavoidable issues that cause students to get unenrolled.

Eg. the institution might be running a Student Information System such as PeopleSoft or Callista. The student could be marked as withdrawn from the course or the whole unit might get temporarily removed from the SiS for one reason or another. Once the problem gets rectified and the student regains their 'student' role on the course, their group assignments and lastaccess dates are then missing, however all their other work is still present.

We need a method of ensuring group assignments can persist across user unenrolments/re-enrolments so that we don't have to manually recover lost group memberships.

If this does not seem suitable for core I guess we will have to develop our own patch here, as this problem is probably our biggest issue with Moodle right now.

Any recommendations on the approach for this? I was thinking of having a separate archive table, which archives group memberships of unenrolled students, ready to be restored back into the groups_members table when the user is enrolled again.

Cheers
Ashley

Show
Ashley Holman added a comment - Hi Peter, There are often unavoidable issues that cause students to get unenrolled. Eg. the institution might be running a Student Information System such as PeopleSoft or Callista. The student could be marked as withdrawn from the course or the whole unit might get temporarily removed from the SiS for one reason or another. Once the problem gets rectified and the student regains their 'student' role on the course, their group assignments and lastaccess dates are then missing, however all their other work is still present. We need a method of ensuring group assignments can persist across user unenrolments/re-enrolments so that we don't have to manually recover lost group memberships. If this does not seem suitable for core I guess we will have to develop our own patch here, as this problem is probably our biggest issue with Moodle right now. Any recommendations on the approach for this? I was thinking of having a separate archive table, which archives group memberships of unenrolled students, ready to be restored back into the groups_members table when the user is enrolled again. Cheers Ashley
Hide
Ashley Holman added a comment -

Another real-world example:

We provide a custom integration with a student information system that allows lecturers to map cohorts from the SiS into Moodle courses. This gets done via the external database plugin which is presented with a table of enrolments generated by the middleware. The lecture might map in one cohort with an end date of July 21. So on July 21, all students from the cohort lose acccess (get unenrolled in the external database). The lecturer then realises they made a mistake and they need to give the students an extra few weeks of access because some are resitting exams, so they go into the middleware interface and modify the end date to be July 27th. Next time the database sync runs, the students are re-assigned their access and everything is back to normal, except for the fact that all of their group memberships are lost! The lecturer then needs to manually reallocate those students into their groups which can be difficult, or in other cases where they are using the tutorial signup module, the students need to go resignup for their tutorials.

Hope that gives some better background on the issue.

Basically, unenrolling a user causes irrecoverable loss of their group memberships, and we would prefer to have the ability to recover group memberships without having to go to DB backups and manually restore rows into the groups_members table.

Thanks

Show
Ashley Holman added a comment - Another real-world example: We provide a custom integration with a student information system that allows lecturers to map cohorts from the SiS into Moodle courses. This gets done via the external database plugin which is presented with a table of enrolments generated by the middleware. The lecture might map in one cohort with an end date of July 21. So on July 21, all students from the cohort lose acccess (get unenrolled in the external database). The lecturer then realises they made a mistake and they need to give the students an extra few weeks of access because some are resitting exams, so they go into the middleware interface and modify the end date to be July 27th. Next time the database sync runs, the students are re-assigned their access and everything is back to normal, except for the fact that all of their group memberships are lost! The lecturer then needs to manually reallocate those students into their groups which can be difficult, or in other cases where they are using the tutorial signup module, the students need to go resignup for their tutorials. Hope that gives some better background on the issue. Basically, unenrolling a user causes irrecoverable loss of their group memberships, and we would prefer to have the ability to recover group memberships without having to go to DB backups and manually restore rows into the groups_members table. Thanks
Hide
Petr Škoda (skodak) added a comment -

I agree it should be possible to prevent accidental unerolments. Keeping all the data all the time is not a real solution, just a workaround that has some nasty side effects.

There need to be several more enrolment states:
1/ active enrolment
2/ suspended enrolment
3/ archived enrolment

The other extreme is we should be able to purge user data, user preferences from course after unenrolment.

Alternative solution might be to backup deleted info during unernolment somehow and have option to reuse it after reenrolling.

I do not know how to solve this in 1.9.x because the whole concept of enrolment feels wrong, I think it can not be fixed and should be completely redesigned. In fact I already redesigned it and made some significant improvements in roles too, unfortunately it was not accepted into core yet. I hope I will have some time later this summer to continue with that project. I will post in GDF and it will also appear on planet.moodle.org

In any case thanks for all your ideas and feedback!

Show
Petr Škoda (skodak) added a comment - I agree it should be possible to prevent accidental unerolments. Keeping all the data all the time is not a real solution, just a workaround that has some nasty side effects. There need to be several more enrolment states: 1/ active enrolment 2/ suspended enrolment 3/ archived enrolment The other extreme is we should be able to purge user data, user preferences from course after unenrolment. Alternative solution might be to backup deleted info during unernolment somehow and have option to reuse it after reenrolling. I do not know how to solve this in 1.9.x because the whole concept of enrolment feels wrong, I think it can not be fixed and should be completely redesigned. In fact I already redesigned it and made some significant improvements in roles too, unfortunately it was not accepted into core yet. I hope I will have some time later this summer to continue with that project. I will post in GDF and it will also appear on planet.moodle.org In any case thanks for all your ideas and feedback!
Hide
Ashley Holman added a comment -

Thanks Petr, those additional enrolment states look like they would solve my problem, providing that an archived enrolment would archive the user's group memberships.

I guess the confusion right now is that there is no cleanup done for activity modules, but cleanup gets done on groups / access dates. The lack of cleanup for modules is actually convenient for us because we don't have to recover that information after a student temporarily loses access. But I see your point that cleanup is necessary to keep the system lean. An archived enrolment state would be great so that we can restore all the userdata (including groups) upon re-enrolment.

Cheers

Show
Ashley Holman added a comment - Thanks Petr, those additional enrolment states look like they would solve my problem, providing that an archived enrolment would archive the user's group memberships. I guess the confusion right now is that there is no cleanup done for activity modules, but cleanup gets done on groups / access dates. The lack of cleanup for modules is actually convenient for us because we don't have to recover that information after a student temporarily loses access. But I see your point that cleanup is necessary to keep the system lean. An archived enrolment state would be great so that we can restore all the userdata (including groups) upon re-enrolment. Cheers
Hide
Petr Škoda (skodak) added a comment -

Hello, the enrolments plugins were rewritten in 2.0, it is now possible to suspend enrolment. The enrolment plugins now control all the ascpects, nothing is hardcoded. If you do not like standard enrol plugins you may create your own.

Petr Škoda

Show
Petr Škoda (skodak) added a comment - Hello, the enrolments plugins were rewritten in 2.0, it is now possible to suspend enrolment. The enrolment plugins now control all the ascpects, nothing is hardcoded. If you do not like standard enrol plugins you may create your own. Petr Škoda

People

Vote (9)
Watch (5)

Dates

  • Created:
    Updated:
    Resolved: