Limit External DB enrollments to specific category of Moodle courses?

Limit External DB enrollments to specific category of Moodle courses?

by Carly Born -
Number of replies: 5

We keep several years of courses on Moodle for a number of reasons.  We are now using the External Database plugin to manage enrollments, but it seems to search through every course in our Moodle instance.  Is there a way to limit it to current and immediately past/future terms?

We are using Moodle 3.8.5

Average of ratings: -
In reply to Carly Born

Re: Limit External DB enrollments to specific category of Moodle courses?

by Randy Thornton -
Picture of Documentation writers
Carly,

Are those previous courses still visible? There's an option in the settings for the DB enrolment method to tell it to Ignore hidden courses.

Otherwise it will go through processing every course that listed for each enrolment in the external table. Do you remove those old course enrolments from the external table? If you have the "external unenrol action" set to one of the Disable options, you don't need to keep the enrolment in the external table anymore if the course is not being used.
In reply to Randy Thornton

Re: Limit External DB enrollments to specific category of Moodle courses?

by Carly Born -
Randy,

Those are both good suggestions, but we may not be able to use them.

Yes, the courses are visible until the faculty member chooses to hide them. Some choose to hide them to keep problem set solutions and the like from 'getting out'. But most prefer to leave their course open so that students can refer back to their content.

We also have enrollments happen 3 times a year (we are on a trimester schedule), and things move very quick. Our courses start out hidden from students, to give the faculty a chance to put something together, and so students would not show up in their course until they were ready to show it to their students. That would be problematic, because it would mean they would have to open it, then wait for everyone to get enrolled before they could reliably send out info via the Announcements forum.

And we rely on the Unenrollment setting to remove students who drop the course.
In reply to Carly Born

Re: Limit External DB enrollments to specific category of Moodle courses?

by Randy Thornton -
Picture of Documentation writers
Carly,

Got it. So, as long as past courses are held open, you need to have the entries in the external table and the sync will of course process them every time. Over time, the enrolments will grow but most of them will be static and unchanging.

One possible solution (other than hacking up the sync code) would be to change the enrolment method in the old courses to some other method, eg manual or cohort or even flatfile. If you mass change the enrolments to, say, manual on the retirement of a course, it gets them out of the external db which would just hold current course enrolments. Since you won't be adding any new enrolments to such old courses, you can do that process once to swap the enrolment methods in them, and then just let them sit there until the day you finally turn the course off for good. In effect, the external db would be only only for active, current courses. Retired courses would have enrolments with some other method.

Of course, this would depend on other factors, especially numbers. But it would reduce the external db to only handling current active course enrolments.
In reply to Randy Thornton

Re: Limit External DB enrollments to specific category of Moodle courses?

by Carly Born -
Randy,

That's an interesting option. I assume that would be a direct database edit, correct? I wonder if I could create a scheduled task to do something like that (after writing the query)?
In reply to Carly Born

Re: Limit External DB enrollments to specific category of Moodle courses?

by Randy Thornton -
Picture of Documentation writers
Carly,

I would edit the database ;) but I think the safer way is use the Upload users, which allows you to add manual enrolments (manual only) to courses. The data you need is already in the external table so you could convert it to the csv format. Once working, they have double enrolments, then later you remove the enrolment from the external table to leave just the manual one.