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

Duplicating section should use backup-restore API correctly



    • Bug
    • Resolution: Unresolved
    • Minor
    • None
    • 4.2.6, 4.3.3
    • Course


      Duplicate section functionality was introduced in MDL-40600 and it was not implemented right. It should really use the backup/restore API (backup the section and restore the section).

      It kind of does it, core_courseformat\base::duplicate_section() calls the function duplicate_module() which is a wrapper over backup and restore a module. But instead there should be a wrapper around backup and restore of the section.

      Multiple problems arise with the current implementation:

      Problem 1 - performance

      duplicate_module() was never intended to be called in a loop and it rebuilds the course cache. This means that when you duplicate a section with 10 modules, it will try to rebuild the course cache 10 (or even 11) times. This will most likely time out the normal PHP script execution.

      Problem 2 - module dependency

      Section S1 contains modules M1 and M2. Module M2 has availability restriction of completion of module M1. When section S1 is duplicated, the section S2 with modules M3 and M4 is created. However M4 depends on completion of M1, where the user wouild expect that it would depend on completion of M3.

      Problem 3 - section data

      When the section data is duplicated, currently only the record from the course_section table is copied. Things that are not copied are:

      • files embedded in the section description (in any course format, including the topics/weeks)
      • any course section format options that are defined by the course format (standard course formats do not use them but custom course formats do)
      • any file areas added by the course formats, for example, the section image


      This all is already implemented by the backup/restore API. All we needed is not to call duplicate_module() function but create a similar wrapper over section backup/restore.


        Issue Links



              Unassigned Unassigned
              marina Marina Glancy
              0 Vote for this issue
              5 Start watching this issue




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