Suspend ONLY student role with external database plugin

Suspend ONLY student role with external database plugin

by Susan Mangan -
Number of replies: 0

Moodle version 3.5 - using External Database enrolment plug-in.

Is it possible to suspend ONLY student roles when records are removed from the external source?  There are no settings in the GUI for this.  It seems it's all or nothing.

We keep 4 semesters worth of course data on our server and currently we are querying external records against all 4 semesters to maintain the data.  We would like to make a change to maintain only current semester enrolments and remove student access from any non-current course.  (But keep the older courses in tact with student data, etc.)

The Suspending users option will work great for our purposes if only we could choose what role to suspend.  We don't want the teacher role to also be suspended as they need to maintain access to these older courses.

We could just choose to keep all users enrolled but then we lose the functionality of suspending/removing users if they drop a course that is in progress.  And this solution also then leaves us with having to find a way to manually remove access to all the students for all previous courses.

The only solutions that come to mind are some sort of code hack or running a stored procedure to flip enrolment status for all Teachers from External Database to Manual before end of the semester.  But this just seems like overkill.  If it was a small simple code hack that someone could show me that would be amazeballs.

*EDIT ohhhhhhhh I think I may be on to something.  I was just reviewing the code and found:

if ($unenrolaction == ENROL_EXT_REMOVED_SUSPENDNOROLES) {
if (isset($requestedroles[$userid])) {
// We want this "other user" to keep their roles.

Going back to the External Database GUI, I see "Remote Other User field" option.

Is it as simple as adding "Teacher" role into this field?

Average of ratings: -