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

Database enrolment doesn't unenrol LAST user from course when unenrol action is set to do so

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.3
    • Component/s: Enrolments
    • Labels:
    • Testing Instructions:
      Hide

      1/ set up ext db enrolment with "full unenrolment" action
      2/ add some users to external db and sync
      3/ remove ALL users from ext db
      4/ sync - expected warning message explaining that there MUST be at least one user in ext DB

      previously this warning was only in verbose mode

      Show
      1/ set up ext db enrolment with "full unenrolment" action 2/ add some users to external db and sync 3/ remove ALL users from ext db 4/ sync - expected warning message explaining that there MUST be at least one user in ext DB previously this warning was only in verbose mode
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      w12_MDL-32046_m23_lastdbuser

      Description

      1/ setup the external database enrolment plugin to enrol against a db table and enable the plugin.
      I created the following table in my moodle install:

      mysql> select * from xx_enrol_danp;
      +----------+--------+---------+
      | courseid | userid | role    |
      +----------+--------+---------+
      |      2   |      4 | student |
      +----------+--------+---------+
      1 row in set (0.00 sec)

      2/ Set the 'External unenrol action' to 'Unenrol user from course'
      2/ run enrol/database/cli/sync.php
      3/ Confirm user 4 is enrolled in courseid 2
      4/ Delete the enrollment from external db:

      mysql> delete from xx_enrol_danp where course = 2;
      Query OK, 0 rows affected (0.00 sec)
      mysql> select * from xx_enrol_danp;
      Empty set (0.00 sec)

      4/ Run enrol/database/cli/sync.php again

      Expected result
      ================

      • User is unenrolled from course

      Actual Result
      =============
      User is still enrolled and enrollment is unaffected

      Note: If unernol action is set to disable enrolment this works ok

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            skodak Petr Skoda added a comment -

            very weird, hmmm, I will have to write unit tests for this asap after phpunit introduction

            Show
            skodak Petr Skoda added a comment - very weird, hmmm, I will have to write unit tests for this asap after phpunit introduction
            Hide
            skodak Petr Skoda added a comment -

            OH! was it your last account in ext DB? There is a hardcoded hack that stops execution of sync if there is nobody in ext db. It should shout in verbose mode, I am going to review it and add extra notice if necessary...

            Show
            skodak Petr Skoda added a comment - OH! was it your last account in ext DB? There is a hardcoded hack that stops execution of sync if there is nobody in ext db. It should shout in verbose mode, I am going to review it and add extra notice if necessary...
            Hide
            samhemelryk Sam Hemelryk added a comment -

            Thanks Petr - it now shouts a little louder

            Show
            samhemelryk Sam Hemelryk added a comment - Thanks Petr - it now shouts a little louder
            Hide
            poltawski Dan Poltawski added a comment -

            Verified this was the problem and this fixes it, thanks

            Show
            poltawski Dan Poltawski added a comment - Verified this was the problem and this fixes it, thanks
            Hide
            samhemelryk Sam Hemelryk added a comment -

            Congratulations are in order, you've made it, or at least your code has!
            It's now part of Moodle and both the git and cvs repositories have been updated.

            This issue is being marked as fixed and closed.

            Thank you.

            Show
            samhemelryk Sam Hemelryk added a comment - Congratulations are in order, you've made it, or at least your code has! It's now part of Moodle and both the git and cvs repositories have been updated. This issue is being marked as fixed and closed. Thank you.

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  25/Jun/12