diff --git a/src/addon/block/recentlyaccesseditems/components/recentlyaccesseditems/addon-block-recentlyaccesseditems.html b/src/addon/block/recentlyaccesseditems/components/recentlyaccesseditems/addon-block-recentlyaccesseditems.html index dbf92f587..cfa2892d6 100644 --- a/src/addon/block/recentlyaccesseditems/components/recentlyaccesseditems/addon-block-recentlyaccesseditems.html +++ b/src/addon/block/recentlyaccesseditems/components/recentlyaccesseditems/addon-block-recentlyaccesseditems.html @@ -7,7 +7,7 @@ -

+

diff --git a/src/addon/block/timeline/components/events/addon-block-timeline-events.html b/src/addon/block/timeline/components/events/addon-block-timeline-events.html index 22e5445f7..832c4902d 100644 --- a/src/addon/block/timeline/components/events/addon-block-timeline-events.html +++ b/src/addon/block/timeline/components/events/addon-block-timeline-events.html @@ -5,7 +5,7 @@ -

+

diff --git a/src/addon/calendar/pages/edit-event/edit-event.ts b/src/addon/calendar/pages/edit-event/edit-event.ts index 18f0e5feb..04027cae0 100644 --- a/src/addon/calendar/pages/edit-event/edit-event.ts +++ b/src/addon/calendar/pages/edit-event/edit-event.ts @@ -31,7 +31,7 @@ import { AddonCalendarOfflineProvider } from '../../providers/calendar-offline'; import { AddonCalendarHelperProvider } from '../../providers/helper'; import { AddonCalendarSyncProvider } from '../../providers/calendar-sync'; import { CoreSite } from '@classes/site'; -import { CoreFilterProvider } from '@core/filter/providers/filter'; +import { CoreFilterHelperProvider } from '@core/filter/providers/helper'; /** * Page that displays a form to create/edit an event. @@ -93,7 +93,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy { private calendarSync: AddonCalendarSyncProvider, private fb: FormBuilder, private syncProvider: CoreSyncProvider, - private filterProvider: CoreFilterProvider, + private filterHelper: CoreFilterHelperProvider, @Optional() private svComponent: CoreSplitViewComponent) { this.eventId = navParams.get('eventId'); @@ -244,7 +244,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy { // Format the name of the courses. const subPromises = []; courses.forEach((course) => { - subPromises.push(this.filterProvider.getFiltersAndFormatText(course.fullname, 'course', course.id) + subPromises.push(this.filterHelper.getFiltersAndFormatText(course.fullname, 'course', course.id) .then((text) => { course.fullname = text; }).catch(() => { diff --git a/src/addon/competency/components/course/addon-competency-course.html b/src/addon/competency/components/course/addon-competency-course.html index 4ccccd2bc..74722c707 100644 --- a/src/addon/competency/components/course/addon-competency-course.html +++ b/src/addon/competency/components/course/addon-competency-course.html @@ -69,7 +69,7 @@

- +
diff --git a/src/addon/competency/pages/competency/competency.html b/src/addon/competency/pages/competency/competency.html index 1835fb1bc..664ca9393 100644 --- a/src/addon/competency/pages/competency/competency.html +++ b/src/addon/competency/pages/competency/competency.html @@ -48,7 +48,7 @@

- + diff --git a/src/addon/messages/providers/mainmenu-handler.ts b/src/addon/messages/providers/mainmenu-handler.ts index 84cec9984..1544ce7a1 100644 --- a/src/addon/messages/providers/mainmenu-handler.ts +++ b/src/addon/messages/providers/mainmenu-handler.ts @@ -24,7 +24,7 @@ import { CoreLocalNotificationsProvider } from '@providers/local-notifications'; import { CorePushNotificationsProvider } from '@core/pushnotifications/providers/pushnotifications'; import { CorePushNotificationsDelegate } from '@core/pushnotifications/providers/delegate'; import { CoreEmulatorHelperProvider } from '@core/emulator/providers/helper'; -import { CoreFilterProvider } from '@core/filter/providers/filter'; +import { CoreFilterHelperProvider } from '@core/filter/providers/helper'; /** * Handler to inject an option into main menu. @@ -49,7 +49,7 @@ export class AddonMessagesMainMenuHandler implements CoreMainMenuHandler, CoreCr constructor(private messagesProvider: AddonMessagesProvider, private sitesProvider: CoreSitesProvider, eventsProvider: CoreEventsProvider, private appProvider: CoreAppProvider, - private localNotificationsProvider: CoreLocalNotificationsProvider, private filterProvider: CoreFilterProvider, + private localNotificationsProvider: CoreLocalNotificationsProvider, private filterHelper: CoreFilterHelperProvider, private pushNotificationsProvider: CorePushNotificationsProvider, utils: CoreUtilsProvider, pushNotificationsDelegate: CorePushNotificationsDelegate, private emulatorHelper: CoreEmulatorHelperProvider) { @@ -297,7 +297,7 @@ export class AddonMessagesMainMenuHandler implements CoreMainMenuHandler, CoreCr title: message.name || message.userfromfullname, }; - return this.filterProvider.getFiltersAndFormatText(message.text, 'system', this.sitesProvider.getCurrentSiteHomeId(), + return this.filterHelper.getFiltersAndFormatText(message.text, 'system', this.sitesProvider.getCurrentSiteHomeId(), {clean: true, singleLine: true}).catch(() => { return message.text; }).then((formattedText) => { diff --git a/src/addon/mod/assign/components/feedback-plugin/addon-mod-assign-feedback-plugin.html b/src/addon/mod/assign/components/feedback-plugin/addon-mod-assign-feedback-plugin.html index 131ee1bd6..daa72e7d8 100644 --- a/src/addon/mod/assign/components/feedback-plugin/addon-mod-assign-feedback-plugin.html +++ b/src/addon/mod/assign/components/feedback-plugin/addon-mod-assign-feedback-plugin.html @@ -8,7 +8,7 @@ {{ 'addon.mod_assign.feedbacknotsupported' | translate }}

- +

diff --git a/src/addon/mod/assign/components/index/addon-mod-assign-index.html b/src/addon/mod/assign/components/index/addon-mod-assign-index.html index a13be748d..eb716eebb 100644 --- a/src/addon/mod/assign/components/index/addon-mod-assign-index.html +++ b/src/addon/mod/assign/components/index/addon-mod-assign-index.html @@ -17,7 +17,7 @@ - + diff --git a/src/addon/mod/assign/components/index/index.ts b/src/addon/mod/assign/components/index/index.ts index 23be9881f..1d37fe6ac 100644 --- a/src/addon/mod/assign/components/index/index.ts +++ b/src/addon/mod/assign/components/index/index.ts @@ -134,7 +134,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo if (this.assign && (this.description || this.assign.introattachments)) { this.textUtils.expandText(this.translate.instant('core.description'), this.description, this.component, - this.module.id, this.assign.introattachments, true, 'module', this.module.id); + this.module.id, this.assign.introattachments, true, 'module', this.module.id, this.courseId); } } diff --git a/src/addon/mod/assign/components/submission-plugin/addon-mod-assign-submission-plugin.html b/src/addon/mod/assign/components/submission-plugin/addon-mod-assign-submission-plugin.html index 6a6a9dfe8..d7223bfc7 100644 --- a/src/addon/mod/assign/components/submission-plugin/addon-mod-assign-submission-plugin.html +++ b/src/addon/mod/assign/components/submission-plugin/addon-mod-assign-submission-plugin.html @@ -8,7 +8,7 @@ {{ 'addon.mod_assign.submissionnotsupported' | translate }}

- +

diff --git a/src/addon/mod/assign/feedback/comments/component/addon-mod-assign-feedback-comments.html b/src/addon/mod/assign/feedback/comments/component/addon-mod-assign-feedback-comments.html index bb23e20a9..6a2fff370 100644 --- a/src/addon/mod/assign/feedback/comments/component/addon-mod-assign-feedback-comments.html +++ b/src/addon/mod/assign/feedback/comments/component/addon-mod-assign-feedback-comments.html @@ -2,7 +2,7 @@

{{ plugin.name }}

- +

diff --git a/src/addon/mod/assign/feedback/comments/component/comments.ts b/src/addon/mod/assign/feedback/comments/component/comments.ts index 4da125a41..27eb0baa1 100644 --- a/src/addon/mod/assign/feedback/comments/component/comments.ts +++ b/src/addon/mod/assign/feedback/comments/component/comments.ts @@ -66,7 +66,7 @@ export class AddonModAssignFeedbackCommentsComponent extends AddonModAssignFeedb if (this.text) { // Open a new state with the text. this.textUtils.expandText(this.plugin.name, this.text, this.component, this.assign.cmid, undefined, true, - 'module', this.assign.cmid); + 'module', this.assign.cmid, this.assign.course); } }); } else if (this.edit) { diff --git a/src/addon/mod/assign/pages/edit/edit.html b/src/addon/mod/assign/pages/edit/edit.html index 8549419ff..c85acfcf9 100644 --- a/src/addon/mod/assign/pages/edit/edit.html +++ b/src/addon/mod/assign/pages/edit/edit.html @@ -1,6 +1,6 @@ - +
@@ -56,7 +56,7 @@

- +

diff --git a/src/addon/mod/chat/pages/index/index.html b/src/addon/mod/chat/pages/index/index.html index 234abae0e..52c0b1f3c 100644 --- a/src/addon/mod/chat/pages/index/index.html +++ b/src/addon/mod/chat/pages/index/index.html @@ -1,6 +1,6 @@ - + diff --git a/src/addon/mod/chat/pages/session-messages/session-messages.html b/src/addon/mod/chat/pages/session-messages/session-messages.html index f75385d59..0b662db80 100644 --- a/src/addon/mod/chat/pages/session-messages/session-messages.html +++ b/src/addon/mod/chat/pages/session-messages/session-messages.html @@ -40,7 +40,7 @@ {{ message.timestamp * 1000 | coreFormatDate:"strftimetime" }} - {{ message.userfullname }} + {{ message.userfullname }}
@@ -53,7 +53,7 @@

- +

diff --git a/src/addon/mod/choice/components/index/addon-mod-choice-index.html b/src/addon/mod/choice/components/index/addon-mod-choice-index.html index f4c0d5ac2..5857d522a 100644 --- a/src/addon/mod/choice/components/index/addon-mod-choice-index.html +++ b/src/addon/mod/choice/components/index/addon-mod-choice-index.html @@ -14,7 +14,7 @@ - + @@ -24,7 +24,7 @@ -

{{ 'addon.mod_choice.yourselection' | translate }}

+

{{ 'addon.mod_choice.yourselection' | translate }}

{{ 'addon.mod_choice.expired' | translate:{$a: closeTimeReadable} }}

@@ -43,13 +43,13 @@ - {{ 'addon.mod_choice.full' | translate }} + {{ 'addon.mod_choice.full' | translate }} - {{ 'addon.mod_choice.full' | translate }} + {{ 'addon.mod_choice.full' | translate }} @@ -73,13 +73,13 @@ {{ 'addon.mod_choice.resultsnotsynced' | translate }} - + -

+

{{ 'addon.mod_choice.numberofuser' | translate }}: {{ result.numberofuser }} ({{ 'core.percentagenumber' | translate: {$a: result.percentageamountfixed} }})

diff --git a/src/addon/mod/choice/pages/index/index.html b/src/addon/mod/choice/pages/index/index.html index a9b19d1e4..3feab085c 100644 --- a/src/addon/mod/choice/pages/index/index.html +++ b/src/addon/mod/choice/pages/index/index.html @@ -1,6 +1,6 @@ - + diff --git a/src/addon/mod/data/components/action/addon-mod-data-action.html b/src/addon/mod/data/components/action/addon-mod-data-action.html index b6c9e9924..74d2afd56 100644 --- a/src/addon/mod/data/components/action/addon-mod-data-action.html +++ b/src/addon/mod/data/components/action/addon-mod-data-action.html @@ -22,15 +22,15 @@ - + {{ entry.timecreated * 1000 | coreFormatDate }} {{ entry.timemodified * 1000 | coreFormatDate }} - + -{{entry.fullname}} +{{entry.fullname}} diff --git a/src/addon/mod/data/components/index/addon-mod-data-index.html b/src/addon/mod/data/components/index/addon-mod-data-index.html index c06e0cc8e..1376b8249 100644 --- a/src/addon/mod/data/components/index/addon-mod-data-index.html +++ b/src/addon/mod/data/components/index/addon-mod-data-index.html @@ -19,7 +19,7 @@ - +
diff --git a/src/addon/mod/data/fields/textarea/component/addon-mod-data-field-textarea.html b/src/addon/mod/data/fields/textarea/component/addon-mod-data-field-textarea.html index 709a96669..02ce6f367 100644 --- a/src/addon/mod/data/fields/textarea/component/addon-mod-data-field-textarea.html +++ b/src/addon/mod/data/fields/textarea/component/addon-mod-data-field-textarea.html @@ -6,4 +6,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/addon/mod/data/pages/edit/edit.html b/src/addon/mod/data/pages/edit/edit.html index 92b0571aa..d5865e7e3 100644 --- a/src/addon/mod/data/pages/edit/edit.html +++ b/src/addon/mod/data/pages/edit/edit.html @@ -1,6 +1,6 @@ - + diff --git a/src/addon/mod/glossary/pages/entry/entry.html b/src/addon/mod/glossary/pages/entry/entry.html index 2c9fc51e0..7a9741482 100644 --- a/src/addon/mod/glossary/pages/entry/entry.html +++ b/src/addon/mod/glossary/pages/entry/entry.html @@ -1,6 +1,6 @@ - + @@ -12,7 +12,7 @@ -

+

{{ entry.timemodified | coreDateDayOrTime }}

{{ entry.userfullname }}

@@ -21,7 +21,7 @@ {{ entry.timemodified | coreDateDayOrTime }} - +
diff --git a/src/addon/mod/glossary/pages/index/index.html b/src/addon/mod/glossary/pages/index/index.html index 35ce44b11..bd651f76a 100644 --- a/src/addon/mod/glossary/pages/index/index.html +++ b/src/addon/mod/glossary/pages/index/index.html @@ -1,6 +1,6 @@ - + diff --git a/src/addon/mod/imscp/components/index/addon-mod-imscp-index.html b/src/addon/mod/imscp/components/index/addon-mod-imscp-index.html index 435cf919a..4e431dbfd 100644 --- a/src/addon/mod/imscp/components/index/addon-mod-imscp-index.html +++ b/src/addon/mod/imscp/components/index/addon-mod-imscp-index.html @@ -16,7 +16,7 @@
- +
diff --git a/src/addon/mod/imscp/pages/index/index.html b/src/addon/mod/imscp/pages/index/index.html index f31c63425..b99777991 100644 --- a/src/addon/mod/imscp/pages/index/index.html +++ b/src/addon/mod/imscp/pages/index/index.html @@ -1,6 +1,6 @@ - + diff --git a/src/addon/mod/lesson/components/index/addon-mod-lesson-index.html b/src/addon/mod/lesson/components/index/addon-mod-lesson-index.html index 98c3eaf5d..d7549ccb4 100644 --- a/src/addon/mod/lesson/components/index/addon-mod-lesson-index.html +++ b/src/addon/mod/lesson/components/index/addon-mod-lesson-index.html @@ -18,7 +18,7 @@ - +
diff --git a/src/addon/mod/lesson/pages/index/index.html b/src/addon/mod/lesson/pages/index/index.html index d90832113..691bb7d19 100644 --- a/src/addon/mod/lesson/pages/index/index.html +++ b/src/addon/mod/lesson/pages/index/index.html @@ -1,6 +1,6 @@ - + diff --git a/src/addon/mod/lesson/pages/menu-modal/menu-modal.html b/src/addon/mod/lesson/pages/menu-modal/menu-modal.html index deeeaca2c..a3fe189bc 100644 --- a/src/addon/mod/lesson/pages/menu-modal/menu-modal.html +++ b/src/addon/mod/lesson/pages/menu-modal/menu-modal.html @@ -26,7 +26,7 @@ diff --git a/src/addon/mod/lesson/pages/player/player.html b/src/addon/mod/lesson/pages/player/player.html index 5e351352b..13c7e7f0b 100644 --- a/src/addon/mod/lesson/pages/player/player.html +++ b/src/addon/mod/lesson/pages/player/player.html @@ -1,6 +1,6 @@ - +
diff --git a/src/addon/mod/quiz/pages/review/review.html b/src/addon/mod/quiz/pages/review/review.html index 15bafe825..21491de5d 100644 --- a/src/addon/mod/quiz/pages/review/review.html +++ b/src/addon/mod/quiz/pages/review/review.html @@ -54,7 +54,7 @@

{{ data.title }}

- +
@@ -77,7 +77,7 @@ - +
diff --git a/src/addon/mod/resource/components/index/addon-mod-resource-index.html b/src/addon/mod/resource/components/index/addon-mod-resource-index.html index d8172c08b..57c634f15 100644 --- a/src/addon/mod/resource/components/index/addon-mod-resource-index.html +++ b/src/addon/mod/resource/components/index/addon-mod-resource-index.html @@ -13,7 +13,7 @@ - + diff --git a/src/addon/mod/resource/pages/index/index.html b/src/addon/mod/resource/pages/index/index.html index 59b962225..d52cc3f30 100644 --- a/src/addon/mod/resource/pages/index/index.html +++ b/src/addon/mod/resource/pages/index/index.html @@ -1,6 +1,6 @@ - + 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 8d86b0309..27e83c61e 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 @@ -14,7 +14,7 @@ - +
@@ -98,8 +98,8 @@

- - + +

diff --git a/src/addon/mod/scorm/pages/index/index.html b/src/addon/mod/scorm/pages/index/index.html index 1bd6f15a8..9a0b2d855 100644 --- a/src/addon/mod/scorm/pages/index/index.html +++ b/src/addon/mod/scorm/pages/index/index.html @@ -1,6 +1,6 @@ - + diff --git a/src/addon/mod/scorm/pages/player/player.html b/src/addon/mod/scorm/pages/player/player.html index 848a18bc9..6d7874bad 100644 --- a/src/addon/mod/scorm/pages/player/player.html +++ b/src/addon/mod/scorm/pages/player/player.html @@ -1,6 +1,6 @@ - + - + @@ -56,7 +56,7 @@ - + diff --git a/src/core/comments/pages/viewer/viewer.ts b/src/core/comments/pages/viewer/viewer.ts index 63f88471b..b17d39f17 100644 --- a/src/core/comments/pages/viewer/viewer.ts +++ b/src/core/comments/pages/viewer/viewer.ts @@ -47,6 +47,7 @@ export class CoreCommentsViewerPage implements OnDestroy { area: string; page: number; title: string; + courseId: number; canLoadMore = false; loadMoreError = false; canAddComments = false; @@ -74,6 +75,7 @@ export class CoreCommentsViewerPage implements OnDestroy { this.itemId = navParams.get('itemId'); this.area = navParams.get('area') || ''; this.title = navParams.get('title') || this.translate.instant('core.comments.comments'); + this.courseId = navParams.get('courseId'); this.page = 0; // Refresh data if comments are synchronized automatically. diff --git a/src/core/course/classes/main-resource-component.ts b/src/core/course/classes/main-resource-component.ts index 2233f893a..87691f7d8 100644 --- a/src/core/course/classes/main-resource-component.ts +++ b/src/core/course/classes/main-resource-component.ts @@ -237,7 +237,7 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy, */ expandDescription(): void { this.textUtils.expandText(this.translate.instant('core.description'), this.description, this.component, this.module.id, - [], true, 'module', this.module.id); + [], true, 'module', this.module.id, this.courseId); } /** diff --git a/src/core/course/components/module-completion/module-completion.ts b/src/core/course/components/module-completion/module-completion.ts index ff3f265d1..a2db476ad 100644 --- a/src/core/course/components/module-completion/module-completion.ts +++ b/src/core/course/components/module-completion/module-completion.ts @@ -17,7 +17,7 @@ import { TranslateService } from '@ngx-translate/core'; import { CoreDomUtilsProvider } from '@providers/utils/dom'; import { CoreUserProvider } from '@core/user/providers/user'; import { CoreCourseProvider } from '../../providers/course'; -import { CoreFilterProvider } from '@core/filter/providers/filter'; +import { CoreFilterHelperProvider } from '@core/filter/providers/helper'; /** * Component to handle activity completion. It shows a checkbox with the current status, and allows manually changing @@ -41,7 +41,7 @@ export class CoreCourseModuleCompletionComponent implements OnChanges { completionImage: string; completionDescription: string; - constructor(private filterProvider: CoreFilterProvider, private domUtils: CoreDomUtilsProvider, + constructor(private filterHelper: CoreFilterHelperProvider, private domUtils: CoreDomUtilsProvider, private translate: TranslateService, private courseProvider: CoreCourseProvider, private userProvider: CoreUserProvider) { this.completionChanged = new EventEmitter(); @@ -138,8 +138,8 @@ export class CoreCourseModuleCompletionComponent implements OnChanges { } if (moduleName) { - this.filterProvider.getFiltersAndFormatText(moduleName, 'module', this.moduleId, - {clean: true, singleLine: true, shortenLength: 50}).then((modName) => { + this.filterHelper.getFiltersAndFormatText(moduleName, 'module', this.moduleId, + {clean: true, singleLine: true, shortenLength: 50, courseId: this.completion.courseId}).then((modName) => { let promise; diff --git a/src/core/course/components/module-description/core-course-module-description.html b/src/core/course/components/module-description/core-course-module-description.html index af4e525b3..7cb12666b 100644 --- a/src/core/course/components/module-description/core-course-module-description.html +++ b/src/core/course/components/module-description/core-course-module-description.html @@ -1,6 +1,6 @@ - + {{ note }} diff --git a/src/core/course/components/module-description/module-description.ts b/src/core/course/components/module-description/module-description.ts index eaa08a1b0..c17f51609 100644 --- a/src/core/course/components/module-description/module-description.ts +++ b/src/core/course/components/module-description/module-description.ts @@ -42,6 +42,7 @@ export class CoreCourseModuleDescriptionComponent { @Input() showFull?: string | boolean; // Whether to always display the full description. @Input() contextLevel?: string; // The context level. @Input() contextInstanceId?: number; // The instance ID related to the context. + @Input() courseId?: number; // Course ID the text belongs to. It can be used to improve performance with filters. constructor() { // Nothing to do. diff --git a/src/core/course/components/module/core-course-module.html b/src/core/course/components/module/core-course-module.html index 4d9a4021d..3c57e9abb 100644 --- a/src/core/course/components/module/core-course-module.html +++ b/src/core/course/components/module/core-course-module.html @@ -2,7 +2,7 @@
- +
@@ -27,9 +27,9 @@ {{ 'core.course.hiddenoncoursepage' | translate }}
{{ 'core.restricted' | translate }} - +
{{ 'core.course.manualcompletionnotsynced' | translate }}
- + \ No newline at end of file diff --git a/src/core/course/components/unsupported-module/core-course-unsupported-module.html b/src/core/course/components/unsupported-module/core-course-unsupported-module.html index f1796de2e..e28fe05c8 100644 --- a/src/core/course/components/unsupported-module/core-course-unsupported-module.html +++ b/src/core/course/components/unsupported-module/core-course-unsupported-module.html @@ -1,5 +1,5 @@
- +

{{ 'core.whoops' | translate }}

{{ 'core.uhoh' | translate }}

diff --git a/src/core/course/components/unsupported-module/unsupported-module.ts b/src/core/course/components/unsupported-module/unsupported-module.ts index c606d4658..6a0cfdd2c 100644 --- a/src/core/course/components/unsupported-module/unsupported-module.ts +++ b/src/core/course/components/unsupported-module/unsupported-module.ts @@ -24,7 +24,7 @@ import { CoreCourseModuleDelegate } from '../../providers/module-delegate'; templateUrl: 'core-course-unsupported-module.html', }) export class CoreCourseUnsupportedModuleComponent implements OnInit { - @Input() course: any; // The course to module belongs to. + @Input() courseId: number; // The course to module belongs to. @Input() module: any; // The module to render. isDisabledInSite: boolean; diff --git a/src/core/course/pages/section/section.ts b/src/core/course/pages/section/section.ts index 5590b1c27..de9e1cdf2 100644 --- a/src/core/course/pages/section/section.ts +++ b/src/core/course/pages/section/section.ts @@ -29,7 +29,7 @@ import { CoreCourseOptionsDelegate, CoreCourseOptionsHandlerToDisplay, CoreCourseOptionsMenuHandlerToDisplay } from '../../providers/options-delegate'; import { CoreCourseSyncProvider } from '../../providers/sync'; import { CoreCourseFormatComponent } from '../../components/format/format'; -import { CoreFilterProvider } from '@core/filter/providers/filter'; +import { CoreFilterHelperProvider } from '@core/filter/providers/helper'; /** * Page that displays the list of courses the user is enrolled in. @@ -75,7 +75,7 @@ export class CoreCourseSectionPage implements OnDestroy { constructor(navParams: NavParams, private courseProvider: CoreCourseProvider, private domUtils: CoreDomUtilsProvider, private courseFormatDelegate: CoreCourseFormatDelegate, private courseOptionsDelegate: CoreCourseOptionsDelegate, private translate: TranslateService, private courseHelper: CoreCourseHelperProvider, eventsProvider: CoreEventsProvider, - private coursesProvider: CoreCoursesProvider, private filterProvider: CoreFilterProvider, + private coursesProvider: CoreCoursesProvider, private filterHelper: CoreFilterHelperProvider, sitesProvider: CoreSitesProvider, private navCtrl: NavController, private injector: Injector, private prefetchDelegate: CoreCourseModulePrefetchDelegate, private syncProvider: CoreCourseSyncProvider, private utils: CoreUtilsProvider) { @@ -263,7 +263,7 @@ export class CoreCourseSectionPage implements OnDestroy { // Format the name of each section and check if it has content. this.sections = sections.map((section) => { - this.filterProvider.getFiltersAndFormatText(section.name.trim(), 'course', this.course.id, + this.filterHelper.getFiltersAndFormatText(section.name.trim(), 'course', this.course.id, {clean: true, singleLine: true}).then((name) => { section.formattedName = name; }); diff --git a/src/core/course/pages/unsupported-module/unsupported-module.html b/src/core/course/pages/unsupported-module/unsupported-module.html index c0ae5285a..21a839390 100644 --- a/src/core/course/pages/unsupported-module/unsupported-module.html +++ b/src/core/course/pages/unsupported-module/unsupported-module.html @@ -1,6 +1,6 @@ - + @@ -11,5 +11,5 @@ - + diff --git a/src/core/course/pages/unsupported-module/unsupported-module.ts b/src/core/course/pages/unsupported-module/unsupported-module.ts index 6e4c87008..a28a2dde6 100644 --- a/src/core/course/pages/unsupported-module/unsupported-module.ts +++ b/src/core/course/pages/unsupported-module/unsupported-module.ts @@ -27,9 +27,11 @@ import { CoreTextUtilsProvider } from '@providers/utils/text'; }) export class CoreCourseUnsupportedModulePage { module: any; + courseId: number; constructor(navParams: NavParams, private translate: TranslateService, private textUtils: CoreTextUtilsProvider) { this.module = navParams.get('module') || {}; + this.courseId = navParams.get('courseId'); } /** @@ -37,6 +39,6 @@ export class CoreCourseUnsupportedModulePage { */ expandDescription(): void { this.textUtils.expandText(this.translate.instant('core.description'), this.module.description, undefined, undefined, - [], true, 'module', this.module.id); + [], true, 'module', this.module.id, this.courseId); } } diff --git a/src/core/course/providers/default-module.ts b/src/core/course/providers/default-module.ts index c69e280a6..bfa297f11 100644 --- a/src/core/course/providers/default-module.ts +++ b/src/core/course/providers/default-module.ts @@ -55,7 +55,7 @@ export class CoreCourseModuleDefaultHandler implements CoreCourseModuleHandler { event.preventDefault(); event.stopPropagation(); - navCtrl.push('CoreCourseUnsupportedModulePage', { module: module }, options); + navCtrl.push('CoreCourseUnsupportedModulePage', { module: module, courseId: courseId }, options); } }; diff --git a/src/core/filter/filter.module.ts b/src/core/filter/filter.module.ts index 20b0073c0..81c898f55 100644 --- a/src/core/filter/filter.module.ts +++ b/src/core/filter/filter.module.ts @@ -16,11 +16,13 @@ import { NgModule } from '@angular/core'; import { CoreFilterProvider } from './providers/filter'; import { CoreFilterDelegate } from './providers/delegate'; import { CoreFilterDefaultHandler } from './providers/default-filter'; +import { CoreFilterHelperProvider } from './providers/helper'; // List of providers (without handlers). export const CORE_FILTER_PROVIDERS: any[] = [ CoreFilterProvider, - CoreFilterDelegate + CoreFilterDelegate, + CoreFilterHelperProvider ]; @NgModule({ @@ -31,7 +33,8 @@ export const CORE_FILTER_PROVIDERS: any[] = [ providers: [ CoreFilterProvider, CoreFilterDelegate, - CoreFilterDefaultHandler + CoreFilterHelperProvider, + CoreFilterDefaultHandler, ] }) export class CoreFilterModule { } diff --git a/src/core/filter/providers/filter.ts b/src/core/filter/providers/filter.ts index ca8e77078..8092d01c4 100644 --- a/src/core/filter/providers/filter.ts +++ b/src/core/filter/providers/filter.ts @@ -247,65 +247,6 @@ export class CoreFilterProvider { }); } - /** - * Get the filters in a certain context, performing some checks like the site version. - * It's recommended to use this function instead of canGetAvailableInContext because this function will check if - * it's really needed to call the WS. - * - * @param contextLevel The context level. - * @param instanceId Instance ID related to the context. - * @param options Options for format text. - * @param siteId Site ID. If not defined, current site. - * @return Promise resolved with the filters. - */ - getFilters(contextLevel: string, instanceId: number, options?: CoreFilterFormatTextOptions, siteId?: string) - : Promise { - - options.contextLevel = contextLevel; - options.instanceId = instanceId; - options.filter = false; - - return this.canGetAvailableInContext(siteId).then((canGet) => { - if (!canGet) { - options.filter = true; - - // We cannot check which filters are available, apply them all. - return this.filterDelegate.getEnabledFilters(contextLevel, instanceId); - } - - // Check if site has any filter to treat. - return this.siteHasFiltersToTreat(options, siteId).then((hasFilters) => { - if (hasFilters) { - options.filter = true; - - return this.getAvailableInContext(contextLevel, instanceId, siteId); - } - - return []; - }).catch(() => { - return []; - }); - }); - } - - /** - * Get filters and format text. - * - * @param text Text to filter. - * @param contextLevel The context level. - * @param instanceId Instance ID related to the context. - * @param options Options for format text. - * @param siteId Site ID. If not defined, current site. - * @return Promise resolved with the formatted text. - */ - getFiltersAndFormatText(text: string, contextLevel: string, instanceId: number, options?: CoreFilterFormatTextOptions, - siteId?: string): Promise { - - return this.getFilters(contextLevel, instanceId, options, siteId).then((filters) => { - return this.formatText(text, options, filters, siteId); - }); - } - /** * Invalidates all available in context WS calls. * @@ -342,26 +283,6 @@ export class CoreFilterProvider { invalidateAvailableInContext(contextLevel: string, instanceId: number, siteId?: string): Promise { return this.invalidateAvailableInContexts([{contextlevel: contextLevel, instanceid: instanceId}], siteId); } - - /** - * Check if site has available any filter that should be treated by the app. - * - * @param options Options passed to the filters. - * @param siteId Site ID. If not defined, current site. - * @return Promise resolved with boolean: whether it has filters to treat. - */ - siteHasFiltersToTreat(options?: CoreFilterFormatTextOptions, siteId?: string): Promise { - options = options || {}; - - return this.sitesProvider.getSite(siteId).then((site) => { - - // Get filters at site level. - return this.getAvailableInContext('system', site.getSiteHomeId(), site.getId()).then((filters) => { - - return this.filterDelegate.shouldBeApplied(filters, options, site); - }); - }); - } } /** @@ -396,4 +317,5 @@ export type CoreFilterFormatTextOptions = { shortenLength?: number; // Number of characters to shorten the text. highlight?: string; // Text to highlight. wsNotFiltered?: boolean; // If true it means the WS didn't filter the text for some reason. + courseId?: number; // Course ID the text belongs to. It can be used to improve performance. }; diff --git a/src/core/filter/providers/helper.ts b/src/core/filter/providers/helper.ts new file mode 100644 index 000000000..06c4a7b83 --- /dev/null +++ b/src/core/filter/providers/helper.ts @@ -0,0 +1,171 @@ +// (C) Copyright 2015 Martin Dougiamas +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { Injectable } from '@angular/core'; +import { CoreLoggerProvider } from '@providers/logger'; +import { CoreSitesProvider } from '@providers/sites'; +import { CoreFilterDelegate } from './delegate'; +import { CoreFilterProvider, CoreFilterFilter, CoreFilterFormatTextOptions } from './filter'; +import { CoreCourseProvider } from '@core/course/providers/course'; +import { CoreSite } from '@classes/site'; + +/** + * Helper service to provide filter functionalities. + */ +@Injectable() +export class CoreFilterHelperProvider { + + protected logger; + + constructor(logger: CoreLoggerProvider, + private sitesProvider: CoreSitesProvider, + private filterDelegate: CoreFilterDelegate, + private courseProvider: CoreCourseProvider, + private filterProvider: CoreFilterProvider) { + this.logger = logger.getInstance('CoreFilterHelperProvider'); + } + + /** + * Get the contexts of all course modules in a course. + * + * @param courseId Course ID. + * @param siteId Site ID. If not defined, current site. + * @return Promise resolved with the contexts. + */ + getCourseModulesContexts(courseId: number, siteId?: string): Promise<{contextlevel: string, instanceid: number}[]> { + + return this.courseProvider.getSections(courseId, false, true, {omitExpires: true}, siteId).then((sections) => { + const contexts: {contextlevel: string, instanceid: number}[] = []; + + sections.forEach((section) => { + if (section.modules) { + section.modules.forEach((module) => { + if (module.uservisible) { + contexts.push({ + contextlevel: 'module', + instanceid: module.id + }); + } + }); + } + }); + + return contexts; + }); + } + + /** + * Get the filters in a certain context, performing some checks like the site version. + * It's recommended to use this function instead of canGetAvailableInContext because this function will check if + * it's really needed to call the WS. + * + * @param contextLevel The context level. + * @param instanceId Instance ID related to the context. + * @param options Options for format text. + * @param siteId Site ID. If not defined, current site. + * @return Promise resolved with the filters. + */ + getFilters(contextLevel: string, instanceId: number, options?: CoreFilterFormatTextOptions, siteId?: string) + : Promise { + + let site: CoreSite; + + options.contextLevel = contextLevel; + options.instanceId = instanceId; + options.filter = false; + + return this.sitesProvider.getSite(siteId).then((s) => { + site = s; + + return this.filterProvider.canGetAvailableInContext(siteId); + }).then((canGet) => { + if (!canGet) { + options.filter = true; + + // We cannot check which filters are available, apply them all. + return this.filterDelegate.getEnabledFilters(contextLevel, instanceId); + } + + let promise: Promise; + + if (instanceId == site.getSiteHomeId() && (contextLevel == 'system' || contextLevel == 'course')) { + // No need to check the site filters because we're requesting the same context, so we'd do the same twice. + promise = Promise.resolve(true); + } else { + // Check if site has any filter to treat. + promise = this.siteHasFiltersToTreat(options, siteId); + } + + return promise.then((hasFilters) => { + if (hasFilters) { + options.filter = true; + + if (contextLevel == 'module' && options.courseId) { + // Get all the modules filters with a single call to decrease the number of WS calls. + return this.getCourseModulesContexts(options.courseId, site.getId()).then((contexts) => { + + return this.filterProvider.getAvailableInContexts(contexts, site.getId()).then((filters) => { + return filters[contextLevel][instanceId] || []; + }); + }); + } + + return this.filterProvider.getAvailableInContext(contextLevel, instanceId, siteId); + } + + return []; + }).catch(() => { + return []; + }); + }); + } + + /** + * Get filters and format text. + * + * @param text Text to filter. + * @param contextLevel The context level. + * @param instanceId Instance ID related to the context. + * @param options Options for format text. + * @param siteId Site ID. If not defined, current site. + * @return Promise resolved with the formatted text. + */ + getFiltersAndFormatText(text: string, contextLevel: string, instanceId: number, options?: CoreFilterFormatTextOptions, + siteId?: string): Promise { + + return this.getFilters(contextLevel, instanceId, options, siteId).then((filters) => { + return this.filterProvider.formatText(text, options, filters, siteId); + }); + } + + /** + * Check if site has available any filter that should be treated by the app. + * + * @param options Options passed to the filters. + * @param siteId Site ID. If not defined, current site. + * @return Promise resolved with boolean: whether it has filters to treat. + */ + siteHasFiltersToTreat(options?: CoreFilterFormatTextOptions, siteId?: string): Promise { + options = options || {}; + + return this.sitesProvider.getSite(siteId).then((site) => { + + // Get filters at site level. + return this.filterProvider.getAvailableInContext('system', site.getSiteHomeId(), site.getId()).then((filters) => { + + return this.filterDelegate.shouldBeApplied(filters, options, site); + }); + }); + } +} diff --git a/src/core/login/pages/sites/sites.ts b/src/core/login/pages/sites/sites.ts index 1ed6b49c2..8283f15be 100644 --- a/src/core/login/pages/sites/sites.ts +++ b/src/core/login/pages/sites/sites.ts @@ -20,7 +20,7 @@ import { CoreSitesProvider, CoreSiteBasicInfo } from '@providers/sites'; import { CoreDomUtilsProvider } from '@providers/utils/dom'; import { CorePushNotificationsProvider } from '@core/pushnotifications/providers/pushnotifications'; import { CoreLoginHelperProvider } from '../../providers/helper'; -import { CoreFilterProvider } from '@core/filter/providers/filter'; +import { CoreFilterHelperProvider } from '@core/filter/providers/helper'; /** * Page that displays the list of stored sites. @@ -35,7 +35,7 @@ export class CoreLoginSitesPage { showDelete: boolean; protected logger; - constructor(private domUtils: CoreDomUtilsProvider, private filterProvider: CoreFilterProvider, + constructor(private domUtils: CoreDomUtilsProvider, private filterHelper: CoreFilterHelperProvider, private sitesProvider: CoreSitesProvider, private loginHelper: CoreLoginHelperProvider, logger: CoreLoggerProvider, private translate: TranslateService, private pushNotificationsProvider: CorePushNotificationsProvider) { this.logger = logger.getInstance('CoreLoginSitesPage'); @@ -86,7 +86,7 @@ export class CoreLoginSitesPage { const site = this.sites[index], siteName = site.siteName; - this.filterProvider.getFiltersAndFormatText(siteName, 'system', site.siteHomeId, {clean: true, singleLine: true}, site.id) + this.filterHelper.getFiltersAndFormatText(siteName, 'system', site.siteHomeId, {clean: true, singleLine: true}, site.id) .then((siteName) => { this.domUtils.showConfirm(this.translate.instant('core.login.confirmdeletesite', { sitename: siteName })).then(() => { diff --git a/src/core/pushnotifications/providers/pushnotifications.ts b/src/core/pushnotifications/providers/pushnotifications.ts index 652647f3e..982041ac2 100644 --- a/src/core/pushnotifications/providers/pushnotifications.ts +++ b/src/core/pushnotifications/providers/pushnotifications.ts @@ -34,6 +34,7 @@ import { ILocalNotification } from '@ionic-native/local-notifications'; import { SQLiteDB, SQLiteDBTableSchema } from '@classes/sqlitedb'; import { CoreSite } from '@classes/site'; import { CoreFilterProvider } from '@core/filter/providers/filter'; +import { CoreFilterDelegate } from '@core/filter/providers/delegate'; /** * Data needed to register a device in a Moodle site. @@ -178,7 +179,7 @@ export class CorePushNotificationsProvider { private utils: CoreUtilsProvider, private textUtils: CoreTextUtilsProvider, private push: Push, private configProvider: CoreConfigProvider, private device: Device, private zone: NgZone, private translate: TranslateService, private platform: Platform, private sitesFactory: CoreSitesFactoryProvider, - private filterProvider: CoreFilterProvider) { + private filterProvider: CoreFilterProvider, private filterDelegate: CoreFilterDelegate) { this.logger = logger.getInstance('CorePushNotificationsProvider'); this.appDB = appProvider.getDB(); this.appDB.createTablesFromSchema(this.appTablesSchema); @@ -448,46 +449,67 @@ export class CorePushNotificationsProvider { text: '', channel: 'PushPluginChannel' }, - promises = [], + options = { + clean: true, + singleLine: true, + contextLevel: 'system', + instanceId: site.getSiteHomeId(), + filter: true + }, isAndroid = this.platform.is('android'), extraFeatures = this.utils.isTrueOrOne(data.extrafeatures); - // Apply formatText to title and message. - promises.push(this.filterProvider.getFiltersAndFormatText(notification.title, 'system', site.getSiteHomeId(), - {clean: true, singleLine: true}, site.getId()).then((title) => { - localNotif.title = title; - }).catch(() => { - localNotif.title = notification.title; - })); - - promises.push(this.filterProvider.getFiltersAndFormatText(notification.message, 'system', site.getSiteHomeId(), - {clean: true, singleLine: true}, site.getId()).catch(() => { - // Error formatting, use the original message. - return notification.message; - }).then((formattedMessage) => { - if (extraFeatures && isAndroid && this.utils.isFalseOrZero(data.notif)) { - // It's a message, use messaging style. Ionic Native doesn't specify this option. - ( localNotif).text = [ - { - message: formattedMessage, - person: data.conversationtype == 2 ? data.userfromfullname : '' - } - ]; - } else { - localNotif.text = formattedMessage; + // Get the filters to apply to text and message. Don't use FIlterHelper to prevent circular dependencies. + this.filterProvider.canGetAvailableInContext(site.getId()).then((canGet) => { + if (!canGet) { + // We cannot check which filters are available, apply them all. + return this.filterDelegate.getEnabledFilters(options.contextLevel, options.instanceId); } - })); - if (extraFeatures && isAndroid) { - // Use a different icon if needed. - localNotif.icon = notification.image; - // This feature isn't supported by the official plugin, we use a fork. - ( localNotif).iconType = data['image-type']; - } + return this.filterProvider.getAvailableInContext(options.contextLevel, options.instanceId, site.getId()); + }).catch(() => { + return []; + }).then((filters) => { + const promises = []; + + // Apply formatText to title and message. + promises.push(this.filterProvider.formatText(notification.title, options, filters, site.getId()) + .then((title) => { + localNotif.title = title; + }).catch(() => { + localNotif.title = notification.title; + })); + + promises.push(this.filterProvider.formatText(notification.message, options, filters, site.getId()) + .catch(() => { + // Error formatting, use the original message. + return notification.message; + }).then((formattedMessage) => { + if (extraFeatures && isAndroid && this.utils.isFalseOrZero(data.notif)) { + // It's a message, use messaging style. Ionic Native doesn't specify this option. + ( localNotif).text = [ + { + message: formattedMessage, + person: data.conversationtype == 2 ? data.userfromfullname : '' + } + ]; + } else { + localNotif.text = formattedMessage; + } + })); + + if (extraFeatures && isAndroid) { + // Use a different icon if needed. + localNotif.icon = notification.image; + // This feature isn't supported by the official plugin, we use a fork. + ( localNotif).iconType = data['image-type']; + } + + Promise.all(promises).then(() => { + this.localNotificationsProvider.schedule(localNotif, CorePushNotificationsProvider.COMPONENT, data.site, + true); + }); - Promise.all(promises).then(() => { - this.localNotificationsProvider.schedule(localNotif, CorePushNotificationsProvider.COMPONENT, data.site, - true); }); } diff --git a/src/core/question/classes/base-question-component.ts b/src/core/question/classes/base-question-component.ts index 9f6f51be1..bb0ca438a 100644 --- a/src/core/question/classes/base-question-component.ts +++ b/src/core/question/classes/base-question-component.ts @@ -29,6 +29,7 @@ export class CoreQuestionBaseComponent { @Input() offlineEnabled?: boolean | string; // Whether the question can be answered in offline. @Input() contextLevel?: string; // The context level. @Input() contextInstanceId?: number; // The instance ID related to the context. + @Input() courseId?: number; // The course the question belongs to (if any). @Output() buttonClicked: EventEmitter; // Should emit an event when a behaviour button is clicked. @Output() onAbort: EventEmitter; // Should emit an event if the question should be aborted. diff --git a/src/core/question/components/question/core-question.html b/src/core/question/components/question/core-question.html index 2124c94d4..005a3ce7d 100644 --- a/src/core/question/components/question/core-question.html +++ b/src/core/question/components/question/core-question.html @@ -23,10 +23,10 @@ -

+

-

+

diff --git a/src/core/question/components/question/question.ts b/src/core/question/components/question/question.ts index 5890dc9d5..ce43dbf13 100644 --- a/src/core/question/components/question/question.ts +++ b/src/core/question/components/question/question.ts @@ -38,6 +38,7 @@ export class CoreQuestionComponent implements OnInit { @Input() offlineEnabled?: boolean | string; // Whether the question can be answered in offline. @Input() contextLevel?: string; // The context level. @Input() contextInstanceId?: number; // The instance ID related to the context. + @Input() courseId?: number; // Course ID the question belongs to (if any). It can be used to improve performance with filters. @Output() buttonClicked: EventEmitter; // Will emit an event when a behaviour button is clicked. @Output() onAbort: EventEmitter; // Will emit an event if the question should be aborted. @@ -86,6 +87,7 @@ export class CoreQuestionComponent implements OnInit { offlineEnabled: this.offlineEnabled, contextLevel: this.contextLevel, contextInstanceId: this.contextInstanceId, + courseId: this.courseId, buttonClicked: this.buttonClicked, onAbort: this.onAbort }; diff --git a/src/core/question/providers/helper.ts b/src/core/question/providers/helper.ts index 6a2a257b4..4b7da5ea3 100644 --- a/src/core/question/providers/helper.ts +++ b/src/core/question/providers/helper.ts @@ -693,9 +693,10 @@ export class CoreQuestionHelperProvider { * @param componentId An ID to use in conjunction with the component. * @param contextLevel The context level. * @param contextInstanceId Instance ID related to the context. + * @param courseId Course ID the text belongs to. It can be used to improve performance with filters. */ treatCorrectnessIconsClicks(element: HTMLElement, component?: string, componentId?: number, contextLevel?: string, - contextInstanceId?: number): void { + contextInstanceId?: number, courseId?: number): void { const icons = Array.from(element.querySelectorAll('i.icon.questioncorrectnessicon[tappable]')), title = this.translate.instant('core.question.feedback'); @@ -708,7 +709,7 @@ export class CoreQuestionHelperProvider { // There's a hidden feedback, show it when the icon is clicked. icon.addEventListener('click', (event) => { this.textUtils.expandText(title, span.innerHTML, component, componentId, [], true, contextLevel, - contextInstanceId); + contextInstanceId, courseId); }); } }); diff --git a/src/core/settings/pages/space-usage/space-usage.ts b/src/core/settings/pages/space-usage/space-usage.ts index 61b75b041..8ce241df8 100644 --- a/src/core/settings/pages/space-usage/space-usage.ts +++ b/src/core/settings/pages/space-usage/space-usage.ts @@ -20,7 +20,7 @@ import { CoreFilepoolProvider } from '@providers/filepool'; import { CoreSitesProvider } from '@providers/sites'; import { CoreDomUtilsProvider } from '@providers/utils/dom'; import { CoreCourseProvider } from '@core/course/providers/course'; -import { CoreFilterProvider } from '@core/filter/providers/filter'; +import { CoreFilterHelperProvider } from '@core/filter/providers/helper'; /** * Page that displays the space usage settings. @@ -39,7 +39,7 @@ export class CoreSettingsSpaceUsagePage { totalEntries = 0; constructor(private filePoolProvider: CoreFilepoolProvider, - private sitesProvider: CoreSitesProvider, private filterProvider: CoreFilterProvider, + private sitesProvider: CoreSitesProvider, private filterHelper: CoreFilterHelperProvider, private translate: TranslateService, private domUtils: CoreDomUtilsProvider, appProvider: CoreAppProvider, private courseProvider: CoreCourseProvider) { this.currentSiteId = this.sitesProvider.getCurrentSiteId(); @@ -162,7 +162,7 @@ export class CoreSettingsSpaceUsagePage { * @param siteData Site object with space usage. */ deleteSiteStorage(siteData: any): void { - this.filterProvider.getFiltersAndFormatText(siteData.siteName, 'system', siteData.siteHomeId, + this.filterHelper.getFiltersAndFormatText(siteData.siteName, 'system', siteData.siteHomeId, {clean: true, singleLine: true}, siteData.id).then((siteName) => { const title = this.translate.instant('core.settings.deletesitefilestitle'); diff --git a/src/core/siteplugins/components/module-index/module-index.ts b/src/core/siteplugins/components/module-index/module-index.ts index d65486a00..a9f9dfeed 100644 --- a/src/core/siteplugins/components/module-index/module-index.ts +++ b/src/core/siteplugins/components/module-index/module-index.ts @@ -146,7 +146,7 @@ export class CoreSitePluginsModuleIndexComponent implements OnInit, OnDestroy, C */ expandDescription(): void { this.textUtils.expandText(this.translate.instant('core.description'), this.description, this.component, this.module.id, - [], true, 'module', this.module.id); + [], true, 'module', this.module.id, this.courseId); } /** diff --git a/src/core/user/components/user-profile-field/user-profile-field.ts b/src/core/user/components/user-profile-field/user-profile-field.ts index 41c4a1e64..b00acfb20 100644 --- a/src/core/user/components/user-profile-field/user-profile-field.ts +++ b/src/core/user/components/user-profile-field/user-profile-field.ts @@ -31,6 +31,7 @@ export class CoreUserProfileFieldComponent implements OnInit { @Input() registerAuth?: string; // Register auth method. E.g. 'email'. @Input() contextLevel?: string; // The context level. @Input() contextInstanceId?: number; // The instance ID related to the context. + @Input() courseId?: number; // Course ID the field belongs to (if any). It can be used to improve performance with filters. componentClass: any; // The class of the component to render. data: any = {}; // Data to pass to the component. @@ -55,6 +56,7 @@ export class CoreUserProfileFieldComponent implements OnInit { this.data.registerAuth = this.registerAuth; this.data.contextLevel = this.contextLevel; this.data.contextInstanceId = this.contextInstanceId; + this.data.courseId = this.courseId; } } } diff --git a/src/core/user/pages/about/about.html b/src/core/user/pages/about/about.html index fd73bfdc8..42fa04ce2 100644 --- a/src/core/user/pages/about/about.html +++ b/src/core/user/pages/about/about.html @@ -56,7 +56,7 @@

{{ 'core.user.interests' | translate}}

{{ user.interests }}

- + {{ 'core.user.description' | translate}} diff --git a/src/core/viewer/pages/text/text.html b/src/core/viewer/pages/text/text.html index f73c58612..410063705 100644 --- a/src/core/viewer/pages/text/text.html +++ b/src/core/viewer/pages/text/text.html @@ -10,7 +10,7 @@ - + diff --git a/src/core/viewer/pages/text/text.ts b/src/core/viewer/pages/text/text.ts index 912c9ccff..6c8c1b6f8 100644 --- a/src/core/viewer/pages/text/text.ts +++ b/src/core/viewer/pages/text/text.ts @@ -33,6 +33,7 @@ export class CoreViewerTextPage { filter: boolean; // Whether to filter the text. contextLevel: string; // The context level. instanceId: number; // The instance ID related to the context. + courseId: number; // Course ID the text belongs to. It can be used to improve performance with filters. constructor(private viewCtrl: ViewController, params: NavParams, textUtils: CoreTextUtilsProvider) { this.title = params.get('title'); @@ -43,6 +44,7 @@ export class CoreViewerTextPage { this.filter = params.get('filter'); this.contextLevel = params.get('contextLevel'); this.instanceId = params.get('instanceId'); + this.courseId = params.get('courseId'); } /** diff --git a/src/directives/format-text.ts b/src/directives/format-text.ts index 644812107..cffef5187 100644 --- a/src/directives/format-text.ts +++ b/src/directives/format-text.ts @@ -31,6 +31,7 @@ import { CoreExternalContentDirective } from '../directives/external-content'; import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper'; import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { CoreFilterProvider } from '@core/filter/providers/filter'; +import { CoreFilterHelperProvider } from '@core/filter/providers/helper'; /** * Directive to format text rendered. It renders the HTML and treats all links and media, using CoreLinkDirective @@ -61,6 +62,7 @@ export class CoreFormatTextDirective implements OnChanges { @Input() filter?: boolean | string; // Whether to filter the text. If not defined, true if contextLevel and instanceId are set. @Input() contextLevel?: string; // The context level of the text. @Input() contextInstanceId?: number; // The instance ID related to the context. + @Input() courseId?: number; // Course ID the text belongs to. It can be used to improve performance with filters. @Input() wsNotFiltered?: boolean | string; // If true it means the WS didn't filter the text for some reason. @Output() afterRender?: EventEmitter; // Called when the data is rendered. @@ -75,7 +77,7 @@ export class CoreFormatTextDirective implements OnChanges { private contentLinksHelper: CoreContentLinksHelperProvider, @Optional() private navCtrl: NavController, @Optional() private content: Content, @Optional() private svComponent: CoreSplitViewComponent, private iframeUtils: CoreIframeUtilsProvider, private eventsProvider: CoreEventsProvider, - private filterProvider: CoreFilterProvider) { + private filterProvider: CoreFilterProvider, private filterHelper: CoreFilterHelperProvider) { this.element = element.nativeElement; this.element.classList.add('opacity-hide'); // Hide contents until they're treated. this.afterRender = new EventEmitter(); @@ -286,7 +288,7 @@ export class CoreFormatTextDirective implements OnChanges { const filter = this.utils.isTrueOrOne(this.filter); this.textUtils.expandText(this.fullTitle || this.translate.instant('core.description'), this.text, - this.component, this.componentId, undefined, filter, this.contextLevel, this.contextInstanceId); + this.component, this.componentId, undefined, filter, this.contextLevel, this.contextInstanceId, this.courseId); } } @@ -383,11 +385,12 @@ export class CoreFormatTextDirective implements OnChanges { clean: this.utils.isTrueOrOne(this.clean), singleLine: this.utils.isTrueOrOne(this.singleLine), highlight: this.highlight, + courseId: this.courseId, wsNotFiltered: this.utils.isTrueOrOne(this.wsNotFiltered) }; if (this.filter) { - return this.filterProvider.getFiltersAndFormatText(this.text, this.contextLevel, this.contextInstanceId, options, + return this.filterHelper.getFiltersAndFormatText(this.text, this.contextLevel, this.contextInstanceId, options, site.getId()); } else { return this.filterProvider.formatText(this.text, options); diff --git a/src/providers/utils/text.ts b/src/providers/utils/text.ts index 50593fc93..9a244b6f7 100644 --- a/src/providers/utils/text.ts +++ b/src/providers/utils/text.ts @@ -352,9 +352,10 @@ export class CoreTextUtilsProvider { * @param filter Whether the text should be filtered. * @param contextLevel The context level. * @param instanceId The instance ID related to the context. + * @param courseId Course ID the text belongs to. It can be used to improve performance with filters. */ expandText(title: string, text: string, component?: string, componentId?: string | number, files?: any[], - filter?: boolean, contextLevel?: string, instanceId?: number): void { + filter?: boolean, contextLevel?: string, instanceId?: number, courseId?: number): void { if (text.length > 0) { const params: any = { title: title, @@ -364,7 +365,8 @@ export class CoreTextUtilsProvider { files: files, filter: filter, contextLevel: contextLevel, - instanceId: instanceId + instanceId: instanceId, + courseId: courseId }; // Open a modal with the contents.