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

update Course AJAX/javascript to YUI3 and replace section_classes.js

XMLWordPrintable

    • MOODLE_23_STABLE
    • MOODLE_23_STABLE
    • MDL-31052-js-rewrite
    • Difficult
    • Hide

      See the individual bugs for the actual test instructions

      • MDL-31222 has no test insructions as it is not possible to test this in isolation
      • MDL-31216 has test instructions for the drag/drop moving
      • MDL-31096 has test instructions for the rest of the resources and sections toolbox areas
      Show
      See the individual bugs for the actual test instructions MDL-31222 has no test insructions as it is not possible to test this in isolation MDL-31216 has test instructions for the drag/drop moving MDL-31096 has test instructions for the rest of the resources and sections toolbox areas

      MDL-31096 (rewrite JS) is composed of two commits.
      https://git.luns.net.uk/?p=moodle.git;a=commit;h=9eb9fb1e07c10610aa7ad5a41bfd5a2ae83f2bb6

      The first adds a new coursebase JS module which allows JS modules to register themselves and be called later. This will be important later on when Davo adds dynamic creation of files within the course. He'll be able to simply extend moodle-course-coursebase and then call:

      // code to create new course module
      var newmodule = Y.Node.create(response.newmodule);
      M.course.coursebase.invoke_function('setup_for_resource', newmodule);

      which will then call any registered JS module which defines setup_for_resource. At present both the general toolbox and the drag/drop module do so. There's also a function for setup_for_section so that a new dynamically created section can also be handled appropriately.
      https://git.luns.net.uk/?p=moodle.git;a=commit;h=2e7630c1c5aed537396daa004e297dd8c1cef9c1
The second commit is a complete rewrite of the old javascript including:

      • lib/ajax/ajaxcourse.js
        * lib/ajax/section_classes.js


      both of which have been removed entirely.

      The original drag/drop functionality is completed removed in these patches, but is added back later by Ruslan's commits.

      https://git.luns.net.uk/?p=moodle.git;a=commit;h=aed1c3facfb5abc2c0340641c22d0851fab994e9

      We've also included a master-only patch for MDL-25990. Another patch should be written for current stable branches.

      MDL-31222 Create a core YUI3 Module for drag-drop
      This patch creates a core drag-drop module M.core.dragdrop that can be used from everywhere (where drag-drop is required), it provides some methods with general functionality, like creating the dragger element, locking it when dragging is not allowed, making initial setup for dragging element, tracking moving direction, visually shifting elements to insert a draggable one in between.

      MDL-31216 Create dragdrop course module

      This patch is applying new drag-drop module to the course page. It contains two modules, both of which is extending M.core.dragdrop. The first one is applying dragdrop to sections. Its init method goes through each existing section and making them draggable and drop target. drop_hit is doing ajax request to update the section order on back-end, and then resort sections order on the frontend. The second module making resources (modules) draggable and also makes each section a drop target, so that resource can be dragged to empty section. Each module is using a separate drag-drop group, so that YUI will not get confused and insert resource between sections for example.

      MDL-31720 Refactor course/rest.php
      This just makes course/rest.php cleanser and removes obsolete bits of code.

      MDL-31263 Apply dragdrop to course blocks
      Relatively large thing, but well-commented hopefully. This allows to drag blocks. It works on the course page for the moment, but on a way to be used everywhere (as you may guess from the way how it is initialised). It is implemented the similar way to section/resources dragdrop. The tricky bit is back-end to store the result, looks pretty hacky attempting to deceive Moodle that we deal with the normal page with blocks, etc., if you have suggestion how to simplify, please let me know . Another tricky bit is drop_over, which is checking if the block region is empty (last block has been dragged out) and the opposite scenario when block is being dragged towards empty region.
      A big TODO is to write wiki pages for drag-drop and Andrew's COURSEBASE stuff, so that people would know how to use it and start using straight away.

            dobedobedoh Andrew Lyons
            dobedobedoh Andrew Lyons
            Dan Poltawski Dan Poltawski
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Dan Poltawski Dan Poltawski
            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.