From b302ea0d5aa436138fa4afe164e3ccc243d4444d Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 26 Jun 2019 08:58:48 +0200 Subject: [PATCH] MOBILE-2735 course: Log view when changing sections --- src/core/course/components/format/format.ts | 10 +++++++++- src/core/course/pages/section/section.ts | 5 ----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/core/course/components/format/format.ts b/src/core/course/components/format/format.ts index 0cc337fd4..f296406f5 100644 --- a/src/core/course/components/format/format.ts +++ b/src/core/course/components/format/format.ts @@ -82,7 +82,8 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { constructor(private cfDelegate: CoreCourseFormatDelegate, translate: TranslateService, private injector: Injector, private courseHelper: CoreCourseHelperProvider, private domUtils: CoreDomUtilsProvider, eventsProvider: CoreEventsProvider, private sitesProvider: CoreSitesProvider, private content: Content, - prefetchDelegate: CoreCourseModulePrefetchDelegate, private modalCtrl: ModalController) { + prefetchDelegate: CoreCourseModulePrefetchDelegate, private modalCtrl: ModalController, + private courseProvider: CoreCourseProvider) { this.selectOptions.title = translate.instant('core.course.sections'); this.completionChanged = new EventEmitter(); @@ -335,6 +336,13 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { } else { this.domUtils.scrollToTop(this.content, 0); } + + if (!previousValue || previousValue.id != newSection.id) { + // First load or section changed, add log in Moodle. + this.courseProvider.logView(this.course.id, newSection.section, undefined, this.course.fullname).catch(() => { + // Ignore errors. + }); + } } /** diff --git a/src/core/course/pages/section/section.ts b/src/core/course/pages/section/section.ts index 6ddb8b33b..efbd0d748 100644 --- a/src/core/course/pages/section/section.ts +++ b/src/core/course/pages/section/section.ts @@ -234,11 +234,6 @@ export class CoreCourseSectionPage implements OnDestroy { }).then((sections) => { let promise; - // Add log in Moodle. - this.courseProvider.logView(this.course.id, this.sectionNumber, undefined, this.course.fullname).catch(() => { - // Ignore errors. - }); - // Get the completion status. if (this.course.enablecompletion === false) { // Completion not enabled.