-
Bug
-
Resolution: Fixed
-
Minor
-
2.6
-
- In the issue description there's a way to reproduce the issue. Apply those changes and check that the addons are shown only once.
-
MOODLE_26_STABLE
-
MOODLE_26_STABLE
The function $mmCoursesDelegate#updateNavHandlersForCourse is called twice per course when the user logins or starts the app: once for login event, and once when the site data is updated. This function empties the course handlers array and fills it again with the enabled addons.
In some addons, the call isEnabledForCourse is asynchronous (grades, course completion), and sometimes the following case happens:
- Login event, updateNavHandlers starts. Empty courseHandlers.
- Synchronous addons are added to the list, asynchronous ones are waiting for a response.
- The site data is updated, so updateNavHandlers starts again. courseHandlers is emptied now.
- Synchronous addons are added to the list, asynchronous ones are waiting for a response.
- The first call of asynchronous addons ends, so they're added to courseHandlers.
- The second call of asynchronous addons ends, so they're added to courseHandlers again.
With some changes in code this can be reproduced 100% of times:
- Modify $mmaGrades#isPluginEnabledForCourse and add a timeout in there to make it slower. I used a 1 second timeout.
- Modify $mmCoursesDelegate#updateNavHandler and add a timeout too. I used 1 second too.
With these 2 changes I always see the grades plugin 2-3 times.