diff --git a/src/core/course/components/format/format.ts b/src/core/course/components/format/format.ts index 9bbb939b8..7b1072f51 100644 --- a/src/core/course/components/format/format.ts +++ b/src/core/course/components/format/format.ts @@ -325,13 +325,14 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { * * @param {any} [refresher] Refresher. * @param {Function} [done] Function to call when done. + * @param {boolean} [afterCompletionChange] Whether the refresh is due to a completion change. * @return {Promise} Promise resolved when done. */ - doRefresh(refresher?: any, done?: () => void): Promise { + doRefresh(refresher?: any, done?: () => void, afterCompletionChange?: boolean): Promise { const promises = []; this.dynamicComponents.forEach((component) => { - promises.push(Promise.resolve(component.callComponentFunction('doRefresh', [refresher, done]))); + promises.push(Promise.resolve(component.callComponentFunction('doRefresh', [refresher, done, afterCompletionChange]))); }); return Promise.all(promises); diff --git a/src/core/course/formats/singleactivity/components/singleactivity.ts b/src/core/course/formats/singleactivity/components/singleactivity.ts index d00223548..fb2a21924 100644 --- a/src/core/course/formats/singleactivity/components/singleactivity.ts +++ b/src/core/course/formats/singleactivity/components/singleactivity.ts @@ -66,9 +66,15 @@ export class CoreCourseFormatSingleActivityComponent implements OnChanges { * * @param {any} [refresher] Refresher. * @param {Function} [done] Function to call when done. + * @param {boolean} [afterCompletionChange] Whether the refresh is due to a completion change. * @return {Promise} Promise resolved when done. */ - doRefresh(refresher?: any, done?: () => void): Promise { + doRefresh(refresher?: any, done?: () => void, afterCompletionChange?: boolean): Promise { + if (afterCompletionChange) { + // Don't refresh the view after a completion change since completion isn't displayed. + return Promise.resolve(); + } + return Promise.resolve(this.dynamicComponent.callComponentFunction('doRefresh', [refresher, done])); } diff --git a/src/core/course/pages/section/section.ts b/src/core/course/pages/section/section.ts index ba066057f..59b92d6f6 100644 --- a/src/core/course/pages/section/section.ts +++ b/src/core/course/pages/section/section.ts @@ -307,7 +307,9 @@ export class CoreCourseSectionPage implements OnDestroy { this.dataLoaded = false; this.content.scrollToTop(); // Scroll top so the spinner is seen. - this.loadData().finally(() => { + this.loadData().then(() => { + return this.formatComponent.doRefresh(undefined, undefined, true); + }).finally(() => { this.dataLoaded = true; // Wait for new content height to be calculated and scroll without animation. diff --git a/src/core/siteplugins/components/course-format/course-format.ts b/src/core/siteplugins/components/course-format/course-format.ts index 93aaad071..9673a7a26 100644 --- a/src/core/siteplugins/components/course-format/course-format.ts +++ b/src/core/siteplugins/components/course-format/course-format.ts @@ -86,9 +86,10 @@ export class CoreSitePluginsCourseFormatComponent implements OnChanges { * * @param {any} [refresher] Refresher. * @param {Function} [done] Function to call when done. + * @param {boolean} [afterCompletionChange] Whether the refresh is due to a completion change. * @return {Promise} Promise resolved when done. */ - doRefresh(refresher?: any, done?: () => void): Promise { - return Promise.resolve(this.content.refreshContent(false)); + doRefresh(refresher?: any, done?: () => void, afterCompletionChange?: boolean): Promise { + return Promise.resolve(this.content.refreshContent(afterCompletionChange)); } }