Merge pull request #3651 from dpalou/MOBILE-4275

MOBILE-4275 course: Fix course completion not updated in some cases
main
Pau Ferrer Ocaña 2023-05-04 09:55:35 +02:00 committed by GitHub
commit 041a8d1778
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -391,11 +391,23 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
* @returns Promise resolved when done.
*/
protected async fetchModule(): Promise<void> {
const previousCompletion = this.module.completiondata;
const module = await CoreCourse.getModule(this.module.id, this.courseId);
await CoreCourseHelper.loadModuleOfflineCompletion(this.courseId, module);
this.module = module;
// @todo: Temporary fix to update course page completion. This should be refactored in MOBILE-4326.
if (previousCompletion && module.completiondata && previousCompletion.state !== module.completiondata.state) {
await CoreUtils.ignoreErrors(CoreCourse.invalidateSections(this.courseId));
CoreEvents.trigger(CoreEvents.COMPLETION_MODULE_VIEWED, {
courseId: this.courseId,
cmId: module.completiondata.cmid,
});
}
}
/**