-
Bug
-
Resolution: Fixed
-
Minor
-
4.2
-
MOODLE_402_STABLE
-
MOODLE_402_STABLE
-
MDL-77677-master -
-
HQ 2023 Sprint i1.3 Moppies
Since 4.2 the course/format/amd/src/local/content.js has 4 actions that trigger a _reloadCMmmethod:
- Changing visible attribute
- Changing stealth attribute
- Changing activity sectionid
- Changing activity indentation
In some scenarios, a user action can do more than one change, and the _reloadCm is executed twice. This is not a big problem, but it is completely unnecessary.
How to reproduce it in Moodle 4.2:
- Enable stealth activities
- Go to a topics format course with some activities
- Open the browser network monitor and filter connections by "fragment" text
- Hide one activity
- Check that the monitor shows one new "fragment" connection
- Now make available (stealth) the activity
- Expected: a new "fragment" connection should appear
- What happens: 2 new "fragment" connections appear, one from the visible attribute and one from the stealth.
Technical shaping
The content._reloadCm method is defined as various watchers in the "getWatcher" method. This is the reason why it is triggered several times. In this case, all cm refresh is centralised in a single method. This complicates the debouncing process because each CM could be refreshed simultaneously, for example, when updated section visibility.
The _reloadCm should use a map of debounced refresh methods to prevent executing unnecessary calls to fragment. One per each CM id.