diff --git a/src/addon/mod/scorm/components/index/addon-mod-scorm-index.html b/src/addon/mod/scorm/components/index/addon-mod-scorm-index.html index c96072bb2..7f6dcdbc8 100644 --- a/src/addon/mod/scorm/components/index/addon-mod-scorm-index.html +++ b/src/addon/mod/scorm/components/index/addon-mod-scorm-index.html @@ -23,7 +23,7 @@
- +

{{ 'addon.mod_scorm.attempts' | translate }}

diff --git a/src/core/course/formats/singleactivity/providers/handler.ts b/src/core/course/formats/singleactivity/providers/handler.ts index 977ada030..8a4a3d776 100644 --- a/src/core/course/formats/singleactivity/providers/handler.ts +++ b/src/core/course/formats/singleactivity/providers/handler.ts @@ -113,4 +113,15 @@ export class CoreCourseFormatSingleActivityHandler implements CoreCourseFormatHa getCourseFormatComponent(injector: Injector, course: any): any | Promise { return CoreCourseFormatSingleActivityComponent; } + + /** + * Whether the view should be refreshed when completion changes. If your course format doesn't display + * activity completion then you should return false. + * + * @param {any} course The course. + * @return {boolean|Promise} Whether course view should be refreshed when an activity completion changes. + */ + shouldRefreshWhenCompletionChanges(course: any): boolean | Promise { + return false; + } } diff --git a/src/core/course/pages/section/section.ts b/src/core/course/pages/section/section.ts index 020741e74..ba066057f 100644 --- a/src/core/course/pages/section/section.ts +++ b/src/core/course/pages/section/section.ts @@ -80,9 +80,14 @@ export class CoreCourseSectionPage implements OnDestroy { this.displayEnableDownload = courseFormatDelegate.displayEnableDownload(this.course); this.downloadCourseEnabled = !this.coursesProvider.isDownloadCourseDisabledInSite(); - this.completionObserver = eventsProvider.on(CoreEventsProvider.COMPLETION_MODULE_VIEWED, (data) => { - if (data && data.courseId == this.course.id) { - this.refreshAfterCompletionChange(); + // Check if the course format requires the view to be refreshed when completion changes. + courseFormatDelegate.shouldRefreshWhenCompletionChanges(this.course).then((shouldRefresh) => { + if (shouldRefresh) { + this.completionObserver = eventsProvider.on(CoreEventsProvider.COMPLETION_MODULE_VIEWED, (data) => { + if (data && data.courseId == this.course.id) { + this.refreshAfterCompletionChange(); + } + }); } }); diff --git a/src/core/course/providers/default-format.ts b/src/core/course/providers/default-format.ts index f83dd2057..45bcfe551 100644 --- a/src/core/course/providers/default-format.ts +++ b/src/core/course/providers/default-format.ts @@ -157,4 +157,15 @@ export class CoreCourseFormatDefaultHandler implements CoreCourseFormatHandler { openCourse(navCtrl: NavController, course: any): Promise { return navCtrl.push('CoreCourseSectionPage', { course: course }); } + + /** + * Whether the view should be refreshed when completion changes. If your course format doesn't display + * activity completion then you should return false. + * + * @param {any} course The course. + * @return {boolean|Promise} Whether course view should be refreshed when an activity completion changes. + */ + shouldRefreshWhenCompletionChanges(course: any): boolean | Promise { + return true; + } } diff --git a/src/core/course/providers/format-delegate.ts b/src/core/course/providers/format-delegate.ts index 218a9bfdf..4a2b476c4 100644 --- a/src/core/course/providers/format-delegate.ts +++ b/src/core/course/providers/format-delegate.ts @@ -158,6 +158,15 @@ export interface CoreCourseFormatHandler extends CoreDelegateHandler { * @return {Promise} Promise resolved when the data is invalidated. */ invalidateData?(course: any, sections: any[]): Promise; + + /** + * Whether the view should be refreshed when completion changes. If your course format doesn't display + * activity completion then you should return false. + * + * @param {any} course The course. + * @return {boolean|Promise} Whether course view should be refreshed when an activity completion changes. + */ + shouldRefreshWhenCompletionChanges?(course: any): boolean | Promise; } /** @@ -337,4 +346,15 @@ export class CoreCourseFormatDelegate extends CoreDelegate { openCourse(navCtrl: NavController, course: any): Promise { return this.executeFunctionOnEnabled(course.format, 'openCourse', [navCtrl, course]); } + + /** + * Whether the view should be refreshed when completion changes. If your course format doesn't display + * activity completion then you should return false. + * + * @param {any} course The course. + * @return {Promise} Whether course view should be refreshed when an activity completion changes. + */ + shouldRefreshWhenCompletionChanges(course: any): Promise { + return Promise.resolve(this.executeFunctionOnEnabled(course.format, 'shouldRefreshWhenCompletionChanges', [course])); + } } diff --git a/src/core/question/classes/base-question-component.ts b/src/core/question/classes/base-question-component.ts index 49642e774..f0ab76a35 100644 --- a/src/core/question/classes/base-question-component.ts +++ b/src/core/question/classes/base-question-component.ts @@ -297,6 +297,8 @@ export class CoreQuestionBaseComponent { this.question.input.correctClass = 'core-question-correct'; } else if (input.classList.contains('partiallycorrect')) { this.question.input.correctClass = 'core-question-partiallycorrect'; + } else { + this.question.input.correctClass = ''; } }