Moodle
  1. Moodle
  2. MDL-26841

Import includes enrolment methods

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.1, 2.1.1, 2.2
    • Fix Version/s: 2.0.5, 2.1.2
    • Component/s: Backup
    • Labels:
      None
    • Database:
      MySQL
    • Testing Instructions:
      Hide

      1) Create 2 courses: "source" and "target"
      2) In "source" add various enrolment plugins (manual, guest, self...) and add 1-2 manual enrolments (students). Add also 1 forum and ignite some discussions with those students.
      3) In "target" add manual enrolment only with 1 student (different student from the ones in point 2).
      4) Logged as admin, perform one import in "target", picking "source" as origin. Select the forum activity and import.
      5) TEST: The operations ends without error.
      6) TEST: The forum activity has been imported but without any discussion.
      7) TEST: Look at "target" enrolment methods. Only the original "manual" is there and none of the enrolment methods in "source" have been imported.

      Show
      1) Create 2 courses: "source" and "target" 2) In "source" add various enrolment plugins (manual, guest, self...) and add 1-2 manual enrolments (students). Add also 1 forum and ignite some discussions with those students. 3) In "target" add manual enrolment only with 1 student (different student from the ones in point 2). 4) Logged as admin, perform one import in "target", picking "source" as origin. Select the forum activity and import. 5) TEST: The operations ends without error. 6) TEST: The forum activity has been imported but without any discussion. 7) TEST: Look at "target" enrolment methods. Only the original "manual" is there and none of the enrolment methods in "source" have been imported.
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Pull from Repository:
    • Pull Master Branch:
    • Rank:
      16504

      Description

      When importing resources enrolment methods are imported as well causing duplicate and not wanted enrolment methods.

        Issue Links

          Activity

          Hide
          Adam Olley added a comment -

          Fix I've implemented so far for this is to simply not perform the enrolment restore step when in MODE_IMPORT:
          https://github.com/aolley/moodle/commit/99f451a9f884d4ee73d786be523b5f0ae3cece6d

          Probably beneficial to do similar to the backup steps as well to not back up the enrolments in the first place when in MODE_IMPORT.

          Show
          Adam Olley added a comment - Fix I've implemented so far for this is to simply not perform the enrolment restore step when in MODE_IMPORT: https://github.com/aolley/moodle/commit/99f451a9f884d4ee73d786be523b5f0ae3cece6d Probably beneficial to do similar to the backup steps as well to not back up the enrolments in the first place when in MODE_IMPORT.
          Hide
          Bryant Saxon added a comment -

          Do you know where the enrolment info is stored in the DB? I would like to try to manually fix some of my courses that are effected by this bug.

          Here's how I am noticing it – after we import some aspects of one course into another, the users/students are seeing double "Enrol Me" buttons after clicking a course from the main menu (for courses that they are not enrolled). Obviously, we are using self enrolment also.

          Show
          Bryant Saxon added a comment - Do you know where the enrolment info is stored in the DB? I would like to try to manually fix some of my courses that are effected by this bug. Here's how I am noticing it – after we import some aspects of one course into another, the users/students are seeing double "Enrol Me" buttons after clicking a course from the main menu (for courses that they are not enrolled). Obviously, we are using self enrolment also.
          Hide
          Bryant Saxon added a comment -

          Nevermind! I found it. It's in the mdl_enrol table. I just sorted by course ID and looked for duplicates of the same type and removed the latest entry.

          Show
          Bryant Saxon added a comment - Nevermind! I found it. It's in the mdl_enrol table. I just sorted by course ID and looked for duplicates of the same type and removed the latest entry.
          Hide
          Mark Ward added a comment -

          An additional note, if you import from a course which has guest enrolment installed but disabled (which is the default) you end up with multiple instances of Guest Enrolment. I have just had to delete 45 instances from 6 courses, this shouldn't be possible!

          Show
          Mark Ward added a comment - An additional note, if you import from a course which has guest enrolment installed but disabled (which is the default) you end up with multiple instances of Guest Enrolment. I have just had to delete 45 instances from 6 courses, this shouldn't be possible!
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Note that there are really two issues here:

          1) Backup and restore handling IMPORT/HUB operations should not include enrolments information at all.

          This is going to be fixed by this, by radically avoiding enrol information to be processed under those modes.

          2) Some incorrect duplication checks lead to multiple instances of enrol plugins.

          This has been addressed @ MDL-29414 and will help fixing some issues like MDL-27061

          Said that, working on 1) right now.

          Show
          Eloy Lafuente (stronk7) added a comment - Note that there are really two issues here: 1) Backup and restore handling IMPORT/HUB operations should not include enrolments information at all. This is going to be fixed by this, by radically avoiding enrol information to be processed under those modes. 2) Some incorrect duplication checks lead to multiple instances of enrol plugins. This has been addressed @ MDL-29414 and will help fixing some issues like MDL-27061 Said that, working on 1) right now.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Sending to integration for 20, 21 and master.

          The fix prevents any enrolments information to be handled in any IMPORT and HUB operations + add one extra check to verify that the "enrolments.xml" is available before processing it on restore (this is necessary because that file, after this change, has become "optional").

          Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Sending to integration for 20, 21 and master. The fix prevents any enrolments information to be handled in any IMPORT and HUB operations + add one extra check to verify that the "enrolments.xml" is available before processing it on restore (this is necessary because that file, after this change, has become "optional"). Ciao
          Hide
          Sam Hemelryk added a comment -

          Thanks everyone, this has been integrated now and is up for testing.

          Cheers
          Sam

          Show
          Sam Hemelryk added a comment - Thanks everyone, this has been integrated now and is up for testing. Cheers Sam
          Hide
          Rossiani Wijaya added a comment -

          This works great.

          Test passed.

          ps: Thanks Aparup for testing this issue too but not fast enough to click the 'start testing' button

          Show
          Rossiani Wijaya added a comment - This works great. Test passed. ps: Thanks Aparup for testing this issue too but not fast enough to click the 'start testing' button
          Hide
          Eloy Lafuente (stronk7) added a comment -

          And this code has been spread to all Moodle git and cvs repositories. Many thanks! Closing.

          Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - And this code has been spread to all Moodle git and cvs repositories. Many thanks! Closing. Ciao

            People

            • Votes:
              4 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: