From 1311e8b9e27d8e31190127b89a5037959490711c Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 4 Jul 2018 10:53:12 +0200 Subject: [PATCH 1/3] MOBILE-2462 scorm: Fix SCORM with displayattemptstatus false --- src/addon/mod/scorm/components/index/addon-mod-scorm-index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 }}

From 16c153850696c74ac058578ed02bec44a16fc324 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 4 Jul 2018 11:13:42 +0200 Subject: [PATCH 2/3] MOBILE-2462 course: Don't refresh singleactivity when completion changes --- .../singleactivity/providers/handler.ts | 11 ++++++++++ src/core/course/pages/section/section.ts | 11 +++++++--- src/core/course/providers/default-format.ts | 11 ++++++++++ src/core/course/providers/format-delegate.ts | 20 +++++++++++++++++++ 4 files changed, 50 insertions(+), 3 deletions(-) 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 9c3bb2e47..10f4ac04f 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])); + } } From 1d4d6107ba23de584aaadfc397bbe3822394694f Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 4 Jul 2018 11:14:14 +0200 Subject: [PATCH 3/3] MOBILE-2462 question: Fix ngClass error if class is undefined --- src/core/question/classes/base-question-component.ts | 2 ++ 1 file changed, 2 insertions(+) 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 = ''; } }