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

Flatfile Enrol: If someone has more than one role in a particular course, and you delete one of those roles with a flatfile, ALL the roles are deleted.



    • Bug
    • Status: Closed
    • Minor
    • Resolution: Duplicate
    • 2.3.1, 2.3.2
    • None
    • Enrolments


      When using flatfile enrolments, if you add someone to a course and they have more than one role in the course, and then you use a flatfile to remove one of the roles, the person ends up being completely removed from a course (ALL roles removed).

      To reproduce:
      1. Add someone into a course with a flatfile, giving them more than one role. For example, "student" (the normal student role) and "waitlist" (which is a custom role we created). So the flatfile would have two lines for that student:
      add, waitlist, studentid, courseid
      add, student, studentid, courseid
      These lines would of course be in two different flatfiles, run at different times (since someone is usually in a waitlist first before becoming a real student in a course).

      2. In another flatfile, remove just one of the roles. So the flatfile would have this line:
      del, waitlist, studentid, courseid

      3. After the "del" line is run in that flatfile, the student will be completely removed from the course, losing both roles.

      What should happen is that the student keeps the "student" role and remains in the course, but this is not the case.

      I've looked into this a bit, and traced it to the lib/enrollib.php file. Line 1346 is the start of the function unenrol_user(), and I believe that is where the problem begins. The function role_unassign_all() is called from there, which resides in lib/accesslib.php on line 1708, and that's where the roles are being removed. I would edit these functions to try to fix it, but I'd rather not mess with core at this point. Plus, I could be wrong about that being the source of the problem!


        Issue Links



              skodak Petr Skoda
              d4m0 Damon Blanchette
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              9 Vote for this issue
              3 Start watching this issue