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

enrol/database - sync_courses should get distinct list

XMLWordPrintable

    • MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • MOODLE_22_STABLE, MOODLE_23_STABLE
    • master_MDL-35557
    • Hide

      set up an external table with shortname/fullname/idnumber for some courses to add.
      make sure some of those rows are complete duplicates - more than 2 duplicates will help with testing.
      Connect external db enrol to that table
      run cli script /enrol/database/cli/sync.php using -v for verbose output.

      before the patch (and a fresh run with none of the courses in your external table created) you will see on each duplicate a message to say the course exists already.

      after the patch on fresh run (make sure you delete any courses previously created by the script) it will show 1 sucessful add and no duplicate messages for the same course.

      Note: - the duplicates must duplicate shortname/idnumber/description - if one of those fields is different then it will still report a duplicate was found. This is correct behaviour.

      Show
      set up an external table with shortname/fullname/idnumber for some courses to add. make sure some of those rows are complete duplicates - more than 2 duplicates will help with testing. Connect external db enrol to that table run cli script /enrol/database/cli/sync.php using -v for verbose output. before the patch (and a fresh run with none of the courses in your external table created) you will see on each duplicate a message to say the course exists already. after the patch on fresh run (make sure you delete any courses previously created by the script) it will show 1 sucessful add and no duplicate messages for the same course. Note: - the duplicates must duplicate shortname/idnumber/description - if one of those fields is different then it will still report a duplicate was found. This is correct behaviour.

      The sync_courses function in enrol/database/lib.php uses the following call to get a list of the courses that need to be imported:
      $sql = $this->db_get_sql($table, array(), $sqlfields);

      if the same table is used that contains the enrolment data this will return all rows in the table and the code iterates over each one to see if it needs to create the course - db_get_sql(enrol/database function) has a 4th param $distinct which is used in sync_enrolments already so we should use it here as well.

      It would improve performance of the sync_courses function a lot if we only obtained the records that we needed from the table by using the extra distinct param.

            danmarsden Dan Marsden
            danmarsden Dan Marsden
            Dan Poltawski Dan Poltawski
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Tim Barker Tim Barker
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.