Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Won't Fix
    • Affects Version/s: 1.9.9
    • Fix Version/s: None
    • Component/s: Course
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Rank:
      1546

      Description

      Synopsis:
      -A student X was accidentally added as an instructor to a child course.
      -Moodle synced the meta course enrollments, thus adding X as an instructor in the meta course.
      -X was removed as an instructor in enrollments and the enrollments were synced.
      -X remained as an instructor for the meta course.

      Diagnosis:
      -In moodle/enrol/database/enrol_database_sync.php there is a function sync_metacourses().
      -This function is in moodle/lib/moodlelib.php and calls sync_metacourse().
      -In sync_metacourse, there are several things to note:

      1. It grabs users with the capability to managemetacourse

      if ($users = get_users_by_capability($context, 'moodle/course:managemetacourse')) {
      $managers = array_keys($users);
      } else {
      $managers = array();
      }

      1. It "Get assignments of a user to a role that exist in a child course, but not in the meta coure. That is, get a list of the assignments that need to be made."
      2. It "Get assignments of a user to a role that exist in the meta course, but not in any child courses. That is, get a list of the unassignments that need to be made."
      3. Go through unassignment lists, and if the user is not capable of managemetacourse, remove them from the meta course.
      4. Go through assignment lists, and assign the user to the metacourse.

      Issue:
      The problem occurs in the unassignment logic - if a user is accidentally given a managemetacourse role in the child course, then the logic will not remove them even if they are removed from the child course.

      Solution:
      When role_assign() is called to automatically enrol people from the child course to the meta course, it will either default the modifier id to

      $ra->modifierid = empty($USER->id) ? 0 : $USER->id;

      and the enrol to 'manual'.

      Thus, if sync_metacourses() is called via a cron job, the $USER variable should not be set. Otherwise, it should have the field set.

      Thus, to solve this issue, we need to change the logic for unassigning from

      ...
      if (!in_array($unassignment->userid, $ r))
      ...

      to

      ...
      if (!in_array($unassignment->userid, $ r) || ($unassignment->modifierid == 0 && $unassignment->enrol == 'manual'))
      ...

        Activity

        Hide
        Petr Škoda added a comment -

        hello, I have remove the link to 2.x issue because it was not related.

        Show
        Petr Škoda added a comment - hello, I have remove the link to 2.x issue because it was not related.
        Hide
        Michael de Raadt added a comment -

        Thanks for reporting this issue.

        We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported.

        If you believe that this issue is still relevant to current versions (2.3 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

        Michael d;

        4d6f6f646c6521

        Show
        Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.3 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d; 4d6f6f646c6521
        Hide
        Michael de Raadt added a comment -

        I'm closing this issue as it has been inactive for over a year has been recorded as affecting versions that are no longer supported.

        If you still believe this is an issue in supported versions, please report a new issue.

        Show
        Michael de Raadt added a comment - I'm closing this issue as it has been inactive for over a year has been recorded as affecting versions that are no longer supported. If you still believe this is an issue in supported versions, please report a new issue.

          People

          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: