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

Deprecate stateactions::section_move method

XMLWordPrintable

    • MOODLE_402_STABLE
    • MOODLE_404_STABLE
    • MDL-77038-master
    • Hide

      Scenario setup

      1. Set debug level to developer (using mdk is: mdk run mindev.php)
      2. Create a course in topic format with at least four topics.
      3. Log in as admin and go to the course in edit mode.
      4. Open the browser console (F12 in Chrome) and find a log message like: Registering new reactive instance "M.reactive.CourseEditorCOURSEID" (where COURSEID is the current course id).
        1. Copy the M.reactive.CourseEditorXXX, you will need it later.
      5. Rename Topic 3 as "Renamed topic".
      6. Note some section IDs. You will need them later. You can get the section ID if you open the section action dropdown and click the "permalink" action, the ID is next to "#sectionid-" in the url.
        1. Note down the "Renamed topic" ID
        2. Note down the "Topic 3" ID

      Test dragging sections

      1. Drag the Renamed topic name and drop over Topic 1
        1. Check Renamed topic moves after Topic 1
        2. Check no new warnings or errors appear in the browser console log
      2. Drag again the Renamed topic name and try dropping over Topic 1
        1. Check nothing happens.
        2. Check no new warnings or errors appear in the browser console log
      3. Drag the Renamed topic and drop over Topic 4
        1. Check the Renamed topic moves after Topic 3 (Topic 4 has been renamed to Topic 3)
        2. Check no new warnings or errors appear in the browser console log
      4. Drag the Renamed topic and drop over the General topic
        1. Check the Renamed topic moves after General topic
        2. Check no new warnings or errors appear in the browser console log
      5. Try dragging the General topic and drop it over Topic 3
        1. Check nothing happens because General topic is not draggable
        2. Check no new warnings or errors appear in the browser console log

      Test deprecated mutation

      For this test, COURSEID is the course ID, NAMEDID is the "named topic" ID, and T3ID is the "Topic 3" ID you note down in the scenario setup.

      1. Type in the browser console (NOTE: the square braces are important): M.reactive.CourseEditorCOURSEID.dispatch('sectionMove', [NAMEDID], T3ID)
        1. Check the console has a new warning: sectionMove() is deprecated. Use sectionMoveAfter() instead
        2. Check the Renamed topic moves after Topic 3
      Show
      Scenario setup Set debug level to developer (using mdk is: mdk run mindev.php) Create a course in topic format with at least four topics. Log in as admin and go to the course in edit mode. Open the browser console (F12 in Chrome) and find a log message like: Registering new reactive instance "M.reactive.CourseEditorCOURSEID" (where COURSEID is the current course id). Copy the M.reactive.CourseEditorXXX, you will need it later. Rename Topic 3 as "Renamed topic". Note some section IDs. You will need them later. You can get the section ID if you open the section action dropdown and click the "permalink" action, the ID is next to "#sectionid-" in the url. Note down the "Renamed topic" ID Note down the "Topic 3" ID Test dragging sections Drag the Renamed topic name and drop over Topic 1 Check Renamed topic moves after Topic 1 Check no new warnings or errors appear in the browser console log Drag again the Renamed topic name and try dropping over Topic 1 Check nothing happens. Check no new warnings or errors appear in the browser console log Drag the Renamed topic and drop over Topic 4 Check the Renamed topic moves after Topic 3 (Topic 4 has been renamed to Topic 3) Check no new warnings or errors appear in the browser console log Drag the Renamed topic and drop over the General topic Check the Renamed topic moves after General topic Check no new warnings or errors appear in the browser console log Try dragging the General topic and drop it over Topic 3 Check nothing happens because General topic is not draggable Check no new warnings or errors appear in the browser console log Test deprecated mutation For this test, COURSEID is the course ID, NAMEDID is the "named topic" ID, and T3ID is the "Topic 3" ID you note down in the scenario setup. Type in the browser console ( NOTE: the square braces are important): M.reactive.CourseEditorCOURSEID.dispatch('sectionMove', [NAMEDID] , T3ID) Check the console has a new warning: sectionMove() is deprecated. Use sectionMoveAfter() instead Check the Renamed topic moves after Topic 3
    • 2
    • HQ 2023 Sprint I4.1 Moppies

      A bit of context

      Since 4.0 the new course editor actions go through a standardized webservice called core_courseformat_update_course. All the actions available in this webservices are implemented as something called "state actions," and all of them use an object called "state updates" to generate the webservice return data structure.

      One of the actions was called "section_move" which emulates the previous course editor behavior, and it is used for both moving sections with the dropdown "move" action and for drag&drop a section header.

      The problem

      The current "section_move" is quite ambiguous in its definition because the moved section will go below or above the target section, depending on its relative position. If the target section is below the moved section, it will go above while if the target is below the moved section will go below. This way of moving a section was ok for the limitations of the previous course editor but added extra complexity to the new one, especially with the introduction of bulk editing.

      Since MDL-76894 the move section modal has a new design to make it consistent with the bulk action. This change requires the move modal always move the section under the target one using a new "section_move_under" action.

      After MDL-76894 there are 2 different actions for moving a section:

      • section_move: used only for drag&drop a section
      • section_move_under:  for moving a section using the individual section move action or the bulk move section action.

      Needless to say that having two almost identical methods is not ideal or necessary. Apart, the definition of "section_move" was ambiguous compareted to "section_move_under".

      Solution

      The solution has two steps:

      • Migrate the current section drag&drop to the move_seciton_under. This has the extra benefit that will improve the UX of the course editor as the section zero will start being an active dropzone (with the section_move, section zero should be excluded as a section item dropzone because it produces unexpected results).
      • Start the process for deprecating the previous section_move. This action is not needed anymore and it is hardly improbable any third party format plugin uses it (and even then it is easily replaceable by the new one)

       

            tusefomal Ferran Recio
            tusefomal Ferran Recio
            Carlos Escobedo Carlos Escobedo
            Amaia Anabitarte Amaia Anabitarte
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 2 hours, 59 minutes
                1d 2h 59m

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