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

End of session enrol/database enrollments not removed

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8
    • Fix Version/s: 2.0
    • Component/s: Enrolments
    • Labels:
      None
    • Database:
      Any
    • Affected Branches:
      MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      If there are no remaining course enrollments for a particular role, the enrol/database logic will not terminate enrollments for the most recently ended class(es).

      Take the end of the semester for example. Assume a block schedule without overlapping terms. On the last day of the semester, a large group of students are enrolled in various courses. The semester ends, and all enrollments are removed in the external database table, leaving no enrollments for the student role. Since a query on the external database reveals no enrollments for that role, the current logic simply skips to the next role. The code should, however, still purge any remaining enrollments for that role.

      In enrol/database/enrol.php, v 1.37 line 208 and following, the if conditional is the culprit:
      208 if ( $rs->RecordCount() == 0 )

      { // no courses! outta here... 209 return true; 210 }

      This conditional should probably be inverted and surround the subsequent while loop, closing before.
      354 rs_close($rs); //Close the main course recordset

      The begin_sql() call will need to be moved up in this solution. E.g.

      begin_sql();
      if ( $rs->RecordCount() != 0 ) { // only fetch if courses found....
      $extcourses = array();
      while ($extcourse_obj = rs_fetch_next_record($rs))

      { // there are more course records ... etc ... }

      // end while course records
      }
      rs_close($rs); //Close the main course recordset

      Please verify this code... I haven't tested it enough to move it to our production server yet.

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  24/Nov/10