Affects Version/s: 2.3
Fix Version/s: 2.3
Pull from Repository:
Pull Master Branch:
Pull Master Diff URL:
MDL-31096 (rewrite JS) is composed of two commits.
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:
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.
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.
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.