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

Problems with changing role when editing enrol_cohort instance

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.0.2
    • Fix Version/s: None
    • Component/s: Cohorts, Enrolments
    • Labels:
    • Affected Branches:
      MOODLE_30_STABLE

      Description

      Vide moodle\enrol\cohort\edit_form.php, ~ line 85.

      One of the controls in the form is for selecting the role to assign. When the form is editing an existing enrolment instance record, but the roleid in that record is not one of the choices for role as determined by the prior call of get_assignable_roles(), the intent of the following code is to append another choice.

              if ($instance->id and !isset($roles[$instance->roleid])) {
                  if ($role = $DB->get_record('role', array('id'=>$instance->roleid))) {
                      $roles = role_fix_names($roles, $coursecontext, ROLENAME_ALIAS, true);
                      $roles[$instance->roleid] = role_get_name($role, $coursecontext);
                  } else {
                      $roles[$instance->roleid] = get_string('error');
                  }
              }
      

      However, this block of code happens after the choices have already been provided to the selection control. Therefore, the block of code has no effect.

      If this block of code is still relevant, I suggest that it be moved to before the call of $mform->addElement(). For example:

              /* Block of code mentioned above should be here. */
              $mform->addElement('select', 'roleid', get_string('assignrole', 'enrol_cohort'), $roles);
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              leviculus Mike Finch
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: