diff --git a/src/addon/competency/providers/course-option-handler.ts b/src/addon/competency/providers/course-option-handler.ts index 4aee5b3dc..6e7fbb562 100644 --- a/src/addon/competency/providers/course-option-handler.ts +++ b/src/addon/competency/providers/course-option-handler.ts @@ -24,7 +24,7 @@ import { AddonCompetencyProvider } from '../providers/competency'; @Injectable() export class AddonCompetencyCourseOptionHandler implements CoreCourseOptionsHandler { name = 'AddonCompetency'; - priority = 700; + priority = 300; constructor(private competencyProvider: AddonCompetencyProvider) {} diff --git a/src/core/course/providers/options-delegate.ts b/src/core/course/providers/options-delegate.ts index 7ba2d5ff5..961c61939 100644 --- a/src/core/course/providers/options-delegate.ts +++ b/src/core/course/providers/options-delegate.ts @@ -261,8 +261,9 @@ export class CoreCourseOptionsDelegate extends CoreDelegate { course.id = parseInt(course.id, 10); const accessData = { - type: isGuest ? CoreCourseProvider.ACCESS_GUEST : CoreCourseProvider.ACCESS_DEFAULT - }; + type: isGuest ? CoreCourseProvider.ACCESS_GUEST : CoreCourseProvider.ACCESS_DEFAULT + }, + handlersToDisplay: CoreCourseOptionsHandlerToDisplay[] = []; if (navOptions) { course.navOptions = navOptions; @@ -275,8 +276,7 @@ export class CoreCourseOptionsDelegate extends CoreDelegate { // Call getHandlersForAccess to make sure the handlers have been loaded. return this.getHandlersForAccess(course.id, refresh, accessData, course.navOptions, course.admOptions); }).then(() => { - const handlersToDisplay: CoreCourseOptionsHandlerToDisplay[] = [], - promises = []; + const promises = []; this.coursesHandlers[course.id].enabledHandlers.forEach((handler) => { promises.push(Promise.resolve(handler.getDisplayData(injector, course)).then((data) => { @@ -291,6 +291,9 @@ export class CoreCourseOptionsDelegate extends CoreDelegate { })); }); + return Promise.all(promises); + }).then(() => { + // Sort them by priority. handlersToDisplay.sort((a, b) => { return b.priority - a.priority;