2.8 enrolment question...which tables identify whether the user has been unenroled?

2.8 enrolment question...which tables identify whether the user has been unenroled?

by Melanie Scott -
Number of replies: 4
Picture of Particularly helpful Moodlers

I think my brain has started to bleed.  I have mdl_enroll (this is the table that id's methods for each course).  I get that one.  I've got mdl_user_enrolment (where it shows a user has been enrolled)  but I see a whole lot of enrolment that has been removed, canceled, deleted, whatever but it doesn't ever seem to show me the enrolment is no longer valid.  Maybe someone got enroled by accident and was unenroled...

Basically, I'm creating business intelligence reports (again...is it just me, or does anyone else hear the word oxymoron every time someone says business intelligence?).  My current ones do fine but they pull all enrolments, even if the user isn't enroled any longer and I can't quite figure out how to stop that.  I keep trying to link in context with roles and role assignments and then it explodes.  Maybe I'm not doing it right.

Average of ratings: -
In reply to Melanie Scott

Re: 2.8 enrolment question...which tables identify whether the user has been unenroled?

by Elizabeth Dalton -

In what way are you considering enrollments no longer valid? Do you want to exclude enrollments that have been expired, or just the ones that have dropped the course?

Have you seen this sample report? https://docs.moodle.org/22/en/ad-hoc_contributed_reports#LIST_of_all_site_USERS_by_COURSE_enrollment_.28Moodle_2.x.29

It should do what you are trying to do, if you restrict to the specific courses you are interested in.

In reply to Elizabeth Dalton

Re: 2.8 enrolment question...which tables identify whether the user has been unenroled?

by Melanie Scott -
Picture of Particularly helpful Moodlers

We don't set enrollments to expire (wish I could), so just those who have 'dropped.'

I haven't looked at the ad hoc...we use configurable reports.  I'll take a look.

In reply to Melanie Scott

Re: 2.8 enrolment question...which tables identify whether the user has been unenroled?

by Elizabeth Dalton -
Configurable Reports is a fork of Ad-Hoc Queries, so the same reports will generally work. smile
In reply to Melanie Scott

Re: 2.8 enrolment question...which tables identify whether the user has been unenroled?

by Randy Thornton -
Picture of Documentation writers


Melanie,

There are only two states for a user enrolment, ACTIVE or SUSPENDED. 

This is shown by the status column in the user_enrolment table, where 0 means the user is active and 1 means they are suspended. If a user has been unenrolled, then their enrollment will be removed from this table altogether. *

You can filter your report to list only active enrollments with a WHERE clause in your report, for instance with a 'WHERE prefix_user.enrolment.status = 0' to the end to limit it to only actively enrolled users.

"Active" means actively enrolled, that is the user can use the course. It does not tell you how active or when they last accessed it or what they are doing. That info is elsewhere.

Moodle doesn't know what "valid" is in terms of enrollment, if by that you mean something other than just actively enrolled.  You may need to be looking at other data to figure that out (like last access or completion or grades, etc.)


*Note: this is true for basic enrollments; external source enrollments like LDAP etc are a bit more complex.


Randy