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

AJAX drag and drop move adjusts default section names when moving down but not up.

XMLWordPrintable

    • MOODLE_23_STABLE, MOODLE_24_STABLE
    • MOODLE_23_STABLE, MOODLE_24_STABLE
    • wip-MDL-34798_master-2
    • Hide

      With an empty test course comprising of ten sections, initially set to the 'Weekly' course format, editing on and AJAX enabled:

      1. Drag and drop section 2 to section 4. Observe that the dates are in the correct temporal sequence.
      2. Drag and drop section 4 to section 2. Observe that the dates are not in the correct temporal sequence.
      3. Change the course format to 'Topics' through the courses 'Edit Settings'.
      4. Drag and drop section 2 to section 4. Observe that the section numbers are in the correct numerical sequence.
      5. Drag and drop section 4 to section 2. Observe that the section numbers are not in the correct numerical sequence.
      6. Apply the code patch.
      7. Perform a 'Purge all caches'.
      8. Drag and drop section 2 to section 4. Observe that the section numbers are in the correct numerical sequence.
      9. Drag and drop section 4 to section 2. Observe that the section numbers are in the correct numerical sequence.
      10. Change the course format to 'Weekly' through the courses 'Edit Settings'.
      11. Drag and drop section 2 to section 4. Observe that the dates are in the correct temporal sequence.
      12. Drag and drop section 4 to section 2. Observe that the dates are in the correct temporal sequence.

      Show
      With an empty test course comprising of ten sections, initially set to the 'Weekly' course format, editing on and AJAX enabled: 1. Drag and drop section 2 to section 4. Observe that the dates are in the correct temporal sequence. 2. Drag and drop section 4 to section 2. Observe that the dates are not in the correct temporal sequence. 3. Change the course format to 'Topics' through the courses 'Edit Settings'. 4. Drag and drop section 2 to section 4. Observe that the section numbers are in the correct numerical sequence. 5. Drag and drop section 4 to section 2. Observe that the section numbers are not in the correct numerical sequence. 6. Apply the code patch. 7. Perform a 'Purge all caches'. 8. Drag and drop section 2 to section 4. Observe that the section numbers are in the correct numerical sequence. 9. Drag and drop section 4 to section 2. Observe that the section numbers are in the correct numerical sequence. 10. Change the course format to 'Weekly' through the courses 'Edit Settings'. 11. Drag and drop section 2 to section 4. Observe that the dates are in the correct temporal sequence. 12. Drag and drop section 4 to section 2. Observe that the dates are in the correct temporal sequence.

      When AJAX drag and drop move is used with either the Topics or Weeks course formats and the sections (say on a new blank course) are moved down the default section names are updated correctly, however when the sections are moved up they do not.

      Investigation of 'format.js' in the course format folder reveals that:

      M.course.format.process_sections = function(Y, sectionlist, response, sectionfrom, sectionto) {
          var CSS = {
              SECTIONNAME : 'sectionname'
          };
       
          if (response.action == 'move') {
              // update titles in all affected sections
              for (var i = sectionfrom; i <= sectionto; i++) {
                  sectionlist.item(i).one('.'+CSS.SECTIONNAME).setContent(response.sectiontitles[i]);
              }
          }
      }

      Therefore the code should deal with the circumstance when 'sectionfrom' is greater than 'sectionto' which is the case when moving up (as proved though placement of debugging 'alert' statements).

      Therefore the code should become:

      M.course.format.process_sections = function(Y, sectionlist, response, sectionfrom, sectionto) {
          var CSS = {
              SECTIONNAME : 'sectionname'
          };
       
          if (response.action == 'move') {
              if (sectionfrom > sectionto) {
                  // Swap.
                  var temp = sectionto;
                  sectionto = sectionfrom;
                  sectionfrom = temp;
              }
              // update titles in all affected sections
              for (var i = sectionfrom; i <= sectionto; i++) {
                  sectionlist.item(i).one('.'+CSS.SECTIONNAME).setContent(response.sectiontitles[i]);
              }
          }
      }

            gb2048 Gareth J Barnard
            gb2048 Gareth J Barnard
            Andrew Lyons Andrew Lyons
            Dan Poltawski Dan Poltawski
            Adrian Greeve Adrian Greeve
            Votes:
            4 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved:

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