Problems with web service function "moodle_role_assign" if the user, before calling the function, isn't enrolled in the course yet.

Re: Problems with web service function "moodle_role_assign" if the user, before calling the function, isn't enrolled in the course yet.

by Jérôme Mouneyrac -
Number of replies: 0

Hi,
the following comment mention code from 2.2 but is applicable to 2.0:

I understand that it is confusing and not obvious that core_role_assign_roles does not enrol a user. However it is a Moodle feature.

In Moodle you can assign a role to a user who is not enrolled. For example: Hidden_roles (you probably better ask in the role forum for more information about the subject)

You most likely want to use core_enrol_get_enrolled_users (to know who is already enrolled) and enrol_manual_enrol_users (to enrol the students not already enrolled) too.

Cheers