From 962cd43d9e842ff177cf7cbf07060e982df77ac4 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 5 May 2021 16:12:28 +0200 Subject: [PATCH] MOBILE-3757 course: Display activity dates in course page --- .../course/components/format/core-course-format.html | 3 ++- .../course/components/module/core-course-module.html | 11 ++++++++--- .../features/course/components/module/module.scss | 8 ++++---- src/core/features/course/components/module/module.ts | 9 ++++++++- src/core/features/course/services/course.ts | 6 ++++++ src/core/features/courses/services/courses.ts | 6 ++++++ 6 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/core/features/course/components/format/core-course-format.html b/src/core/features/course/components/format/core-course-format.html index 8f7e56516..0200201de 100644 --- a/src/core/features/course/components/format/core-course-format.html +++ b/src/core/features/course/components/format/core-course-format.html @@ -146,7 +146,8 @@ + (statusChanged)="onModuleStatusChange()" [showActivityDates]="course?.showactivitydates" + [showCompletionConditions]="course?.showcompletionconditions"> diff --git a/src/core/features/course/components/module/core-course-module.html b/src/core/features/course/components/module/core-course-module.html index 453f5098c..9d19cb47c 100644 --- a/src/core/features/course/components/module/core-course-module.html +++ b/src/core/features/course/components/module/core-course-module.html @@ -6,7 +6,7 @@ (click)="moduleClicked($event)" [attr.aria-label]="module.handlerData.a11yTitle" [ngClass]="{ - 'has-module-description': module.description, + 'has-module-info': hasInfo, 'item-media': module.handlerData.icon, 'item-dimmed': module.visible === 0 || module.uservisible === false }" @@ -74,9 +74,9 @@ +
+

+ {{ date.label }} {{ date.timestamp * 1000 | coreFormatDate:'strftimedatetime' }} +

+
diff --git a/src/core/features/course/components/module/module.scss b/src/core/features/course/components/module/module.scss index 017a6d617..369c22a54 100644 --- a/src/core/features/course/components/module/module.scss +++ b/src/core/features/course/components/module/module.scss @@ -31,7 +31,7 @@ } } - .core-module-module-description { + .core-module-module-info { ion-badge { text-align: start; } @@ -51,15 +51,15 @@ clear: both; } - .core-module-main-item + .core-module-module-description ion-label { + .core-module-main-item + .core-module-module-info ion-label { margin-top: 0px; } - .core-module-main-item.has-module-description { + .core-module-main-item.has-module-info { --inner-border-width: 0; } - .core-module-module-description ion-label { + .core-module-module-info ion-label { margin-inline-start: 50px; } diff --git a/src/core/features/course/components/module/module.ts b/src/core/features/course/components/module/module.ts index abe5646e4..9a19926bc 100644 --- a/src/core/features/course/components/module/module.ts +++ b/src/core/features/course/components/module/module.ts @@ -47,6 +47,8 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy { @Input() module!: CoreCourseModule; // The module to render. @Input() courseId?: number; // The course the module belongs to. @Input() section?: CoreCourseSection; // The section the module belongs to. + @Input() showActivityDates = false; // Whether to show activity dates. + @Input() showCompletionConditions = false; // Whether to show activity completion conditions. // eslint-disable-next-line @angular-eslint/no-input-rename @Input('downloadEnabled') set enabled(value: boolean) { this.downloadEnabled = value; @@ -61,7 +63,7 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy { // Get current status to decide which icon should be shown. this.calculateAndShowStatus(); - }; + } @Output() completionChanged = new EventEmitter(); // Notify when module completion changes. @Output() statusChanged = new EventEmitter(); // Notify when the download status changes. @@ -71,6 +73,7 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy { spinner?: boolean; // Whether to display a loading spinner. downloadEnabled?: boolean; // Whether the download of sections and modules is enabled. modNameTranslated = ''; + hasInfo = false; protected prefetchHandler?: CoreCourseModulePrefetchHandler; protected statusObserver?: CoreEventObserver; @@ -89,6 +92,10 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy { } this.module.handlerData.a11yTitle = this.module.handlerData.a11yTitle ?? this.module.handlerData.title; + this.hasInfo = !!( + this.module.description || + (this.showActivityDates && this.module.dates && this.module.dates.length) + ); if (this.module.handlerData.showDownloadButton) { // Listen for changes on this module status, even if download isn't enabled. diff --git a/src/core/features/course/services/course.ts b/src/core/features/course/services/course.ts index 4be90a405..f0548ec0e 100644 --- a/src/core/features/course/services/course.ts +++ b/src/core/features/course/services/course.ts @@ -1262,6 +1262,8 @@ export type CoreCourseSummary = { timeaccess?: number; // @since 3.6. Timeaccess. showshortname: boolean; // @since 3.6. Showshortname. coursecategory: string; // @since 3.7. Coursecategory. + showactivitydates: boolean | null; // @since 3.11. Whether the activity dates are shown or not. + showcompletionconditions: boolean | null; // @since 3.11. Whether the activity completion conditions are shown or not. }; /** @@ -1442,6 +1444,10 @@ export type CoreCourseWSModule = { completion?: number; // Type of completion tracking: 0 means none, 1 manual, 2 automatic. completiondata?: CoreCourseModuleWSCompletionData; // Module completion data. contents: CoreCourseModuleContentFile[]; + dates?: { + label: string; + timestamp: number; + }[]; // @since 3.11. Activity dates. contentsinfo?: { // Contents summary information. filescount: number; // Total number of files. filessize: number; // Total files size. diff --git a/src/core/features/courses/services/courses.ts b/src/core/features/courses/services/courses.ts index acf54ef00..b0a2df9d0 100644 --- a/src/core/features/courses/services/courses.ts +++ b/src/core/features/courses/services/courses.ts @@ -1264,6 +1264,8 @@ export type CoreEnrolledCourseData = CoreEnrolledCourseBasicData & { isfavourite?: boolean; // If the user marked this course a favourite. hidden?: boolean; // If the user hide the course from the dashboard. overviewfiles?: CoreWSExternalFile[]; + showactivitydates?: boolean; // @since 3.11. Whether the activity dates are shown or not. + showcompletionconditions?: boolean; // @since 3.11. Whether the activity completion conditions are shown or not. }; /** @@ -1281,6 +1283,8 @@ export type CoreCourseBasicSearchedData = CoreCourseBasicData & { }[]; enrollmentmethods: string[]; // Enrollment methods list. customfields?: CoreCourseCustomField[]; // Custom fields and associated values. + showactivitydates?: boolean; // @since 3.11. Whether the activity dates are shown or not. + showcompletionconditions?: boolean; // @since 3.11. Whether the activity completion conditions are shown or not. }; export type CoreCourseSearchedData = CoreCourseBasicSearchedData & { @@ -1342,6 +1346,8 @@ export type CoreCourseGetCoursesData = CoreEnrolledCourseBasicData & { forcetheme?: string; // Name of the force theme. courseformatoptions?: CoreCourseFormatOption[]; // Additional options for particular course format. customfields?: CoreCourseCustomField[]; // Custom fields and associated values. + showactivitydates?: boolean; // @since 3.11. Whether the activity dates are shown or not. + showcompletionconditions?: boolean; // @since 3.11. Whether the activity completion conditions are shown or not. }; /**