-
Bug
-
Resolution: Duplicate
-
Major
-
None
-
2.0.1
-
MOODLE_20_STABLE
When you restoring a course in Moodle 2.0.1 and you have students that are enrolled in the course using another enrolment plugin which is not 'manual', all student role assignment is not done.
If the users where assigned in the course using the manual enrolment, then you have no problem. All student role come just fine.
Looks like role_assignments is done before user enrolment. But other enrol plugins need the enrolid of the instance in the course to assign role which does not exist until the enrolment is done.
The should be a way to create the enrolment instance in the course first before doing role assignment.
Look into /backup/moodle2/restore_stepslib.php
Inside the <b>public function process_assignment($data) {</b>
This is the part that is failing
<pre>
if (empty($data->component))
else if ((strpos($data->component, 'enrol_') === 0)) {
// Deal with enrolment roles
error_log($data->component." - found ");
if ($enrolid = $this->get_mappingid('enrol', $data->itemid)) {
error_log("Found new value for ".$data->itemid . " as ". $enrolid);
if ($component = $DB->get_field('enrol', 'component', array('id'=>$enrolid))) {
</pre>
So for manual enrol, you use when component is empty which does not require an enrolment instance in the course before assigning roles. Hence works.
But for the rest, the section <b>if ($enrolid = $this->get_mappingid('enrol', $data->itemid)) {</b> fails since the enrol plugin is done later.
Please fix the order, unless l am missing something.