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 Bug
    • Status: Closed
    • Priority: Minor 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
    • Rank:
      38729

      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

        Issue Links

          Activity

          Hide
          Petr Škoda added a comment -

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

          Show
          Petr Škoda added a comment - very weird, hmmm, I will have to write unit tests for this asap after phpunit introduction
          Hide
          Petr Škoda 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
          Petr Škoda 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
          Sam Hemelryk added a comment -

          Thanks Petr - it now shouts a little louder

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

          Verified this was the problem and this fixes it, thanks

          Show
          Dan Poltawski added a comment - Verified this was the problem and this fixes it, thanks
          Hide
          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
          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: