Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-26222

Course restore does not restore user roles when enrol plugin is not manual

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • None
    • 2.0.1
    • Enrolments
    • 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))

      { // assign standard manual roles // TODO: role_assign() needs one userid param to be able to specify our restore userid role_assign($newroleid, $newuserid, $contextid); }

      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.

            skodak Petr Skoda
            bazaar Mawuli Kuivi (Inactive)
            Votes:
            8 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.