Moodle
  1. Moodle
  2. MDL-3912

database enrolment unenrols manual enroled people

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.2
    • Fix Version/s: None
    • Component/s: Enrolments
    • Labels:
      None
    • Environment:
      All
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_15_STABLE
    • Rank:
      8513

      Description

      Database enrolments appears to remove people you have added manually. This is easily corrected with the new database field 'enrol'. Changing the call to enrol_student and checking for that before you call unenrol_student will prevent the problem.

      enrol_student($user->id, $course->id, 0, 0, 'database'); /// Enrol the student

      // only unenrol if the person was a database enrolee, auto won't remove a manual enrol

      $selection = userid = .$user->id. and enrol = 'database';

      if(get_record_select(user_students,$selection))

      { unenrol_student($user->id, $courseid); /// Unenrol the student unset($user->student[$course->id]); /// Remove from old list }

        Activity

        Hide
        Martin Dougiamas added a comment -

        From Scott Krajewski (krajewsk at augsburg.edu) Saturday, 13 August 2005, 04:44 AM:

        2 more fixes I just noticed

        Need to check the course too!

        $selection = userid = .$user->id. and course=.$courseid.and enrol = 'database';

        and change how manual enrolment is recorded in course/student.php

        if (! enrol_student($addstudent, $course->id, $timestart, $timeend, 'manual')) {

        From Scott Krajewski (krajewsk at augsburg.edu) Monday, 15 August 2005, 10:22 PM:

        typo in $selection

        $selection = userid = .$user->id. and course=.$courseid. and enrol = 'database';

        missing space after second 'and'

        From barron koralesky (koralesky at gmail.com) Tuesday, 16 August 2005, 06:16 AM:

        I tried Scott's modifications.

        The enrol entry in mdl_user_students was changed to 'manual' when an admin/teacher added a user to the course. However, this value was overwritten when the user logged in and out again. Thus the user was still removed for our site.

        On a possibly related note, when a user enrols themselves to a course using the key, for us their enrol value is set to 'database' instead of 'manual', thus they are removed from the course when they log back in. It is possible that whatever routine writes 'database' here, is what is overwriting 'manual' above.

        Thank you for looking at this!

        From Martin Langhoff (martin at catalyst.net.nz) Friday, 26 August 2005, 02:14 PM:

        Thanks a lot for the patches and clear description of the problem!

        I've reworked them a bit, tested and they are now in MOODLE_15_STABLE. The fix covers MDL-3974 and MDL-3912 – different symptoms of the same problem.

        From barron koralesky (koralesky at gmail.com) Thursday, 1 September 2005, 09:07 PM:

        http://moodle.org/mod/forum/discuss.php?d=28884

        From Martin Langhoff (martin at catalyst.net.nz) Friday, 2 September 2005, 03:48 AM:

        Ack - I'm still wokring on it.

        From barron koralesky (koralesky at gmail.com) Friday, 2 September 2005, 11:18 AM:

        Absolutely no disrespect intended. I just wanted to make sure that the discussion was linked to the bug report (and vice-versa).

        Thank you!

        From Martin Langhoff (martin at catalyst.net.nz) Wednesday, 7 September 2005, 02:45 PM:

        I had a good chance to go over this, reproduce the problem, and fix it for good. The code in CVS was already preserving the data in the user_students table correctly. It was only failing to repopulate it in the session.

        The fix for this is identical to the Option B that I had posted. It had worked for me before, and is working for me again. The users are not asked to re-enrol when they visit the course either.

        To Barron - I have the feeling that the last round of tests (testing the option A and option B submitted to the forum) you may have had something cached mucking up the results. However, there may be something else in this – so I'll leave it open for you to confirm.

        Please make double sure you are using the latest code in CVS. This is fixed in v1.7.2.3 of the enrol/database/enrol.php file.

        From Howard Miller (howard.miller at udcf.gla.ac.uk) Thursday, 6 October 2005, 10:51 PM:

        Is there any progress / fix / on this? Basically will installing 1.5.2+ solve the problem?

        From Martin Langhoff (martin at catalyst.net.nz) Friday, 7 October 2005, 01:52 AM:

        This one has been fixed. My initial fix had a typo that led to a small bug on postgres, and a huge unworkable bug with mysql. Once I found it and fixed it, the issue was resolved.

        closing.

        Show
        Martin Dougiamas added a comment - From Scott Krajewski (krajewsk at augsburg.edu) Saturday, 13 August 2005, 04:44 AM: 2 more fixes I just noticed Need to check the course too! $selection = userid = .$user->id. and course=.$courseid.and enrol = 'database'; and change how manual enrolment is recorded in course/student.php if (! enrol_student($addstudent, $course->id, $timestart, $timeend, 'manual')) { From Scott Krajewski (krajewsk at augsburg.edu) Monday, 15 August 2005, 10:22 PM: typo in $selection $selection = userid = .$user->id. and course=.$courseid. and enrol = 'database'; missing space after second 'and' From barron koralesky (koralesky at gmail.com) Tuesday, 16 August 2005, 06:16 AM: I tried Scott's modifications. The enrol entry in mdl_user_students was changed to 'manual' when an admin/teacher added a user to the course. However, this value was overwritten when the user logged in and out again. Thus the user was still removed for our site. On a possibly related note, when a user enrols themselves to a course using the key, for us their enrol value is set to 'database' instead of 'manual', thus they are removed from the course when they log back in. It is possible that whatever routine writes 'database' here, is what is overwriting 'manual' above. Thank you for looking at this! From Martin Langhoff (martin at catalyst.net.nz) Friday, 26 August 2005, 02:14 PM: Thanks a lot for the patches and clear description of the problem! I've reworked them a bit, tested and they are now in MOODLE_15_STABLE. The fix covers MDL-3974 and MDL-3912 – different symptoms of the same problem. From barron koralesky (koralesky at gmail.com) Thursday, 1 September 2005, 09:07 PM: http://moodle.org/mod/forum/discuss.php?d=28884 From Martin Langhoff (martin at catalyst.net.nz) Friday, 2 September 2005, 03:48 AM: Ack - I'm still wokring on it. From barron koralesky (koralesky at gmail.com) Friday, 2 September 2005, 11:18 AM: Absolutely no disrespect intended. I just wanted to make sure that the discussion was linked to the bug report (and vice-versa). Thank you! From Martin Langhoff (martin at catalyst.net.nz) Wednesday, 7 September 2005, 02:45 PM: I had a good chance to go over this, reproduce the problem, and fix it for good. The code in CVS was already preserving the data in the user_students table correctly. It was only failing to repopulate it in the session. The fix for this is identical to the Option B that I had posted. It had worked for me before, and is working for me again. The users are not asked to re-enrol when they visit the course either. To Barron - I have the feeling that the last round of tests (testing the option A and option B submitted to the forum) you may have had something cached mucking up the results. However, there may be something else in this – so I'll leave it open for you to confirm. Please make double sure you are using the latest code in CVS. This is fixed in v1.7.2.3 of the enrol/database/enrol.php file. From Howard Miller (howard.miller at udcf.gla.ac.uk) Thursday, 6 October 2005, 10:51 PM: Is there any progress / fix / on this? Basically will installing 1.5.2+ solve the problem? From Martin Langhoff (martin at catalyst.net.nz) Friday, 7 October 2005, 01:52 AM: This one has been fixed. My initial fix had a typo that led to a small bug on postgres, and a huge unworkable bug with mysql. Once I found it and fixed it, the issue was resolved. closing.
        Hide
        Michael Blake added a comment -

        assign to a valid user

        Show
        Michael Blake added a comment - assign to a valid user

          People

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

            Dates

            • Created:
              Updated:
              Resolved: