get_string('configdefaultcourseroleid', 'admin'), $studentrole->id, $assignableroles));
$temp->add(new admin_setting_configcheckbox('autologinguests', get_string('autologinguests', 'admin'), get_string('configautologinguests', 'admin'), 0));
+
+$temp->add(new admin_setting_configmultiselect('nonmetacoursesyncroleids', get_string('nonmetacoursesyncroleids', 'admin'),
+ get_string('confignonmetacoursesyncroleids', 'admin'), '', $assignableroles));
+
//$temp->add(new admin_setting_configcheckbox('allusersaresitestudents', get_string('allusersaresitestudents', 'admin'), get_string('configallusersaresitestudents','admin'), 1));
$temp->add(new admin_setting_configmultiselect('hiddenuserfields', get_string('hiddenuserfields', 'admin'),
get_string('confighiddenuserfields', 'admin'), array(),
$string['configmaxevents'] = 'Events to Lookahead';
$string['configmessaging'] = 'Should the messaging system between site users be enabled?';
$string['configmymoodleredirect'] = 'This setting forces redirects to /my on login for non-admins and replaces the top level site breadcrumb with /my';
+$string['confignonmetacoursesyncroleids'] = 'By default all enrolments from child courses are synchronised to metacourses. Roles that are selected here will not be included in the synchronisation process.';
$string['confignoreplyaddress'] = 'Emails are sometimes sent out on behalf of a user (eg forum posts). The email address you specify here will be used as the \"From\" address in those cases when the recipients should not be able to reply directly to the user (eg when a user chooses to keep their address private).';
$string['confignotifyloginfailures'] = 'If login failures have been recorded, email notifications can be sent out. Who should see these notifications?';
$string['confignotifyloginthreshold'] = 'If notifications about failed logins are active, how many failed login attempts by one user or one IP address is it worth notifying about?';
$string['nolangupdateneeded'] = 'All your language packs are up to date, no update is needed';
$string['nonewsettings'] = 'No new settings were added during this upgrade.';
$string['nonexistentbookmark'] = 'The bookmark you requested does not exist.';
+$string['nonmetacoursesyncroleids'] = 'Roles that are not synchronised to metacourses';
$string['noreplyaddress'] = 'No-reply address';
$string['noresults'] = 'No results found.';
$string['notifications'] = 'Notifications';
return false;
}
+ // Get a list of roles that should not be synced.
+ if ($CFG->nonmetacoursesyncroleids) {
+ $roleexclusions = 'ra.roleid NOT IN (' . $CFG->nonmetacoursesyncroleids . ') AND';
+ } else {
+ $roleexclusions = '';
+ }
+
// Get the context of the metacourse.
$context = get_context_instance(CONTEXT_COURSE, $course->id); // SITEID can not be a metacourse
con.contextlevel = " . CONTEXT_COURSE . " AND
con.instanceid = cm.child_course AND
cm.parent_course = {$course->id} AND
+ $roleexclusions
NOT EXISTS (
SELECT 1 FROM
{$CFG->prefix}role_assignments ra2
{$CFG->prefix}role_assignments ra
WHERE
ra.contextid = {$context->id} AND
+ $roleexclusions
NOT EXISTS (
SELECT 1 FROM
{$CFG->prefix}role_assignments ra2,