From 68e57c0f1722d39f8fb49dbed24e7417c3603767 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 3 Sep 2021 11:51:26 +0200 Subject: [PATCH] MOBILE-3819 core: Remove code specific for Moodle 3.1-3.4 --- src/addons/badges/services/badges.ts | 4 +- .../calendarmonth/services/block-handler.ts | 4 +- .../services/block-handler.ts | 4 +- .../block/timeline/services/timeline.ts | 9 +- src/addons/blog/services/blog.ts | 3 +- src/addons/calendar/calendar-lazy.module.ts | 7 - src/addons/calendar/pages/event/event.html | 2 +- src/addons/calendar/pages/event/event.page.ts | 39 +- src/addons/calendar/pages/list/list.html | 96 --- src/addons/calendar/pages/list/list.module.ts | 60 -- src/addons/calendar/pages/list/list.page.ts | 643 ------------------ src/addons/calendar/pages/list/list.scss | 5 - src/addons/calendar/services/calendar.ts | 150 +--- .../calendar/services/handlers/mainmenu.ts | 2 +- .../calendar/services/handlers/view-link.ts | 8 +- .../airnotifier/services/airnotifier.ts | 11 - .../services/handlers/messageoutput.ts | 5 +- src/addons/messages/messages-lazy.module.ts | 4 +- .../pages/discussion/discussion.page.ts | 71 +- .../pages/discussions-35/discussions.html | 2 +- .../pages/discussions-35/discussions.page.ts | 2 - .../messages/services/handlers/mainmenu.ts | 5 +- .../messages/services/handlers/settings.ts | 4 +- src/addons/messages/services/messages.ts | 85 +-- .../index/addon-mod-assign-index.html | 16 +- .../mod/assign/components/index/index.ts | 9 +- .../components/submission/submission.ts | 17 +- .../submission-list/submission-list.html | 7 - .../submission-list/submission-list.page.ts | 11 - .../mod/assign/services/assign-helper.ts | 29 +- src/addons/mod/assign/services/assign-sync.ts | 11 +- src/addons/mod/assign/services/assign.ts | 192 +----- .../mod/assign/services/handlers/module.ts | 3 +- .../mod/assign/services/handlers/prefetch.ts | 14 +- .../submission/comments/services/handler.ts | 21 +- .../submission/onlinetext/services/handler.ts | 7 +- src/addons/mod/book/services/book.ts | 2 +- .../index/addon-mod-chat-index.html | 2 +- src/addons/mod/chat/components/index/index.ts | 3 - src/addons/mod/chat/services/chat.ts | 17 +- .../mod/chat/services/handlers/module.ts | 13 +- .../mod/chat/services/handlers/prefetch.ts | 7 - src/addons/mod/choice/services/choice.ts | 2 +- src/addons/mod/data/services/data.ts | 13 - .../data/services/handlers/approve-link.ts | 3 +- .../mod/data/services/handlers/delete-link.ts | 3 +- .../mod/data/services/handlers/edit-link.ts | 3 +- .../mod/data/services/handlers/index-link.ts | 8 - .../mod/data/services/handlers/list-link.ts | 8 - .../mod/data/services/handlers/module.ts | 5 +- .../mod/data/services/handlers/prefetch.ts | 7 - .../mod/data/services/handlers/show-link.ts | 3 +- .../mod/data/services/handlers/tag-area.ts | 3 +- src/addons/mod/feedback/services/feedback.ts | 14 - .../services/handlers/analysis-link.ts | 3 +- .../services/handlers/complete-link.ts | 3 +- .../feedback/services/handlers/index-link.ts | 14 - .../feedback/services/handlers/list-link.ts | 8 - .../mod/feedback/services/handlers/module.ts | 5 +- .../feedback/services/handlers/prefetch.ts | 7 - .../feedback/services/handlers/print-link.ts | 3 +- .../feedback/services/handlers/push-click.ts | 3 +- .../services/handlers/show-entries-link.ts | 3 +- .../handlers/show-non-respondents-link.ts | 3 +- .../mod/folder/components/index/index.ts | 18 +- src/addons/mod/folder/services/folder.ts | 10 - .../mod/folder/services/handlers/prefetch.ts | 5 +- .../new-discussion/new-discussion.page.ts | 7 +- src/addons/mod/forum/services/forum.ts | 9 - .../mod/glossary/components/index/index.ts | 2 +- src/addons/mod/glossary/services/glossary.ts | 16 - .../glossary/services/handlers/prefetch.ts | 8 +- .../mod/h5pactivity/services/h5pactivity.ts | 3 +- .../mod/label/services/handlers/prefetch.ts | 12 +- src/addons/mod/label/services/label.ts | 26 - .../lesson/services/handlers/grade-link.ts | 15 - .../lesson/services/handlers/index-link.ts | 15 - .../mod/lesson/services/handlers/list-link.ts | 11 - .../mod/lesson/services/handlers/module.ts | 5 +- .../mod/lesson/services/handlers/prefetch.ts | 9 - .../lesson/services/handlers/report-link.ts | 3 +- src/addons/mod/lesson/services/lesson.ts | 13 - src/addons/mod/lti/services/lti.ts | 2 +- src/addons/mod/page/components/index/index.ts | 23 +- .../mod/page/services/handlers/prefetch.ts | 5 +- src/addons/mod/page/services/page.ts | 10 - src/addons/mod/quiz/components/index/index.ts | 9 +- .../mod/quiz/services/handlers/prefetch.ts | 9 +- src/addons/mod/quiz/services/quiz.ts | 4 +- .../mod/resource/components/index/index.ts | 26 +- .../mod/resource/services/handlers/module.ts | 2 +- .../resource/services/handlers/prefetch.ts | 5 +- src/addons/mod/resource/services/resource.ts | 10 - src/addons/mod/scorm/services/scorm.ts | 5 - src/addons/mod/survey/services/survey.ts | 2 +- src/addons/mod/url/components/index/index.ts | 8 +- .../mod/url/services/handlers/module.ts | 4 +- src/addons/mod/url/services/url.ts | 10 - src/addons/mod/wiki/services/wiki.ts | 4 +- .../workshop/services/handlers/index-link.ts | 9 +- .../workshop/services/handlers/list-link.ts | 10 - .../mod/workshop/services/handlers/module.ts | 5 +- .../workshop/services/handlers/prefetch.ts | 7 - src/addons/mod/workshop/services/workshop.ts | 15 +- src/addons/notifications/pages/list/list.ts | 12 +- .../pages/settings/settings.html | 179 +++-- .../notifications/pages/settings/settings.ts | 8 +- .../notifications/services/handlers/cron.ts | 5 +- .../services/handlers/settings.ts | 5 +- .../services/notifications-helper.ts | 15 +- .../notifications/services/notifications.ts | 97 +-- src/addons/privatefiles/pages/index/index.ts | 11 +- .../privatefiles/services/privatefiles.ts | 22 - .../ddimageortext/component/ddimageortext.ts | 2 +- .../qtype/ddmarker/component/ddmarker.ts | 2 +- src/core/classes/site.ts | 2 +- src/core/directives/external-content.ts | 2 +- src/core/directives/format-text.ts | 13 +- .../features/comments/services/comments.ts | 2 +- .../components/format/core-course-format.html | 2 +- .../components/module/core-course-module.html | 2 +- .../course/components/module/module.ts | 2 - .../course/pages/contents/contents.ts | 2 +- .../course/pages/preview/preview.page.ts | 7 +- .../features/course/services/course-helper.ts | 33 +- .../services/course-options-delegate.ts | 3 +- src/core/features/course/services/course.ts | 28 +- .../services/handlers/default-format.ts | 3 - .../services/module-prefetch-delegate.ts | 32 +- .../courses/pages/my-courses/my-courses.ts | 12 +- .../courses/services/courses-helper.ts | 21 +- src/core/features/courses/services/courses.ts | 27 +- .../services/handlers/courses-index-link.ts | 12 +- src/core/features/filter/services/filter.ts | 23 +- .../features/grades/services/grades-helper.ts | 33 +- src/core/features/grades/services/grades.ts | 32 +- .../login/pages/site-policy/site-policy.ts | 4 +- .../features/login/services/login-helper.ts | 5 - .../features/rating/components/rate/rate.ts | 2 +- src/core/features/rating/services/rating.ts | 8 +- .../features/sitehome/services/sitehome.ts | 4 +- .../siteplugins/services/siteplugins.ts | 13 +- src/core/features/tag/services/tag.ts | 1 + .../user/pages/profile/profile.page.ts | 1 - .../features/user/services/user-delegate.ts | 21 +- src/core/features/user/services/user.ts | 18 +- src/core/services/sites.ts | 5 - 147 files changed, 436 insertions(+), 2398 deletions(-) delete mode 100644 src/addons/calendar/pages/list/list.html delete mode 100644 src/addons/calendar/pages/list/list.module.ts delete mode 100644 src/addons/calendar/pages/list/list.page.ts delete mode 100644 src/addons/calendar/pages/list/list.scss diff --git a/src/addons/badges/services/badges.ts b/src/addons/badges/services/badges.ts index a807534a7..d95e4f733 100644 --- a/src/addons/badges/services/badges.ts +++ b/src/addons/badges/services/badges.ts @@ -39,7 +39,7 @@ export class AddonBadgesProvider { async isPluginEnabled(siteId?: string): Promise { const site = await CoreSites.getSite(siteId); - return site.canUseAdvancedFeature('enablebadges') && site.wsAvailable('core_course_get_user_navigation_options'); + return site.canUseAdvancedFeature('enablebadges'); } /** @@ -194,7 +194,7 @@ export type AddonBadgesUserBadge = { targetframework?: string; // Target framework. targetcode?: string; // Target code. }[]; - competencies?: { // @deprecated from 3.7. @since 3.6. In 3.7 it was renamed to alignment. + competencies?: { // @deprecatedonmoodle from 3.7. @since 3.6. In 3.7 it was renamed to alignment. id?: number; // Alignment id. badgeid?: number; // Badge id. targetname?: string; // Target name. diff --git a/src/addons/block/calendarmonth/services/block-handler.ts b/src/addons/block/calendarmonth/services/block-handler.ts index bf557dbdc..a29e04ba9 100644 --- a/src/addons/block/calendarmonth/services/block-handler.ts +++ b/src/addons/block/calendarmonth/services/block-handler.ts @@ -16,10 +16,10 @@ import { Injectable } from '@angular/core'; import { CoreBlockHandlerData } from '@features/block/services/block-delegate'; import { CoreBlockOnlyTitleComponent } from '@features/block/components/only-title-block/only-title-block'; import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler'; -import { AddonCalendar } from '@/addons/calendar/services/calendar'; import { CoreCourseBlock } from '@features/course/services/course'; import { Params } from '@angular/router'; import { makeSingleton } from '@singletons'; +import { AddonCalendarMainMenuHandlerService } from '@addons/calendar/services/handlers/mainmenu'; /** * Block handler. @@ -45,7 +45,7 @@ export class AddonBlockCalendarMonthHandlerService extends CoreBlockBaseHandler title: 'addon.block_calendarmonth.pluginname', class: 'addon-block-calendar-month', component: CoreBlockOnlyTitleComponent, - link: AddonCalendar.getMainCalendarPagePath(), + link: AddonCalendarMainMenuHandlerService.PAGE_NAME, linkParams: linkParams, navOptions: { preferCurrentTab: false, diff --git a/src/addons/block/calendarupcoming/services/block-handler.ts b/src/addons/block/calendarupcoming/services/block-handler.ts index 4820df1f0..2201a1c32 100644 --- a/src/addons/block/calendarupcoming/services/block-handler.ts +++ b/src/addons/block/calendarupcoming/services/block-handler.ts @@ -16,10 +16,10 @@ import { Injectable } from '@angular/core'; import { CoreBlockHandlerData } from '@features/block/services/block-delegate'; import { CoreBlockOnlyTitleComponent } from '@features/block/components/only-title-block/only-title-block'; import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler'; -import { AddonCalendar } from '@/addons/calendar/services/calendar'; import { CoreCourseBlock } from '@features/course/services/course'; import { Params } from '@angular/router'; import { makeSingleton } from '@singletons'; +import { AddonCalendarMainMenuHandlerService } from '@addons/calendar/services/handlers/mainmenu'; /** * Block handler. @@ -46,7 +46,7 @@ export class AddonBlockCalendarUpcomingHandlerService extends CoreBlockBaseHandl title: 'addon.block_calendarupcoming.pluginname', class: 'addon-block-calendar-upcoming', component: CoreBlockOnlyTitleComponent, - link: AddonCalendar.getMainCalendarPagePath(), + link: AddonCalendarMainMenuHandlerService.PAGE_NAME, linkParams: linkParams, navOptions: { preferCurrentTab: false, diff --git a/src/addons/block/timeline/services/timeline.ts b/src/addons/block/timeline/services/timeline.ts index c50c5adef..c2e646f00 100644 --- a/src/addons/block/timeline/services/timeline.ts +++ b/src/addons/block/timeline/services/timeline.ts @@ -248,13 +248,8 @@ export class AddonBlockTimelineProvider { async isAvailable(siteId?: string): Promise { const site = await CoreSites.getSite(siteId); - // First check if dashboard is disabled. - if (CoreCoursesDashboard.isDisabledInSite(site)) { - return false; - } - - return site.wsAvailable('core_calendar_get_action_events_by_courses') && - site.wsAvailable('core_calendar_get_action_events_by_timesort'); + // Check if dashboard is disabled. + return !CoreCoursesDashboard.isDisabledInSite(site); } /** diff --git a/src/addons/blog/services/blog.ts b/src/addons/blog/services/blog.ts index 0b9e77ed8..8e1847d83 100644 --- a/src/addons/blog/services/blog.ts +++ b/src/addons/blog/services/blog.ts @@ -40,11 +40,12 @@ export class AddonBlogProvider { * * @param siteId Site ID. If not defined, current site. * @return Promise resolved with true if enabled, resolved with false or rejected otherwise. + * @since 3.6 */ async isPluginEnabled(siteId?: string): Promise { const site = await CoreSites.getSite(siteId); - return site.wsAvailable('core_blog_get_entries') &&site.canUseAdvancedFeature('enableblogs'); + return site.wsAvailable('core_blog_get_entries') && site.canUseAdvancedFeature('enableblogs'); } /** diff --git a/src/addons/calendar/calendar-lazy.module.ts b/src/addons/calendar/calendar-lazy.module.ts index 7c6e1658b..5ead2dbca 100644 --- a/src/addons/calendar/calendar-lazy.module.ts +++ b/src/addons/calendar/calendar-lazy.module.ts @@ -38,13 +38,6 @@ function buildRoutes(injector: Injector): Routes { }, loadChildren: () => import('@/addons/calendar/pages/index/index.module').then(m => m.AddonCalendarIndexPageModule), }, - { - path: 'list', - data: { - mainMenuTabRoot: AddonCalendarMainMenuHandlerService.PAGE_NAME, - }, - loadChildren: () => import('@/addons/calendar/pages/list/list.module').then(m => m.AddonCalendarListPageModule), - }, { path: 'settings', loadChildren: () => diff --git a/src/addons/calendar/pages/event/event.html b/src/addons/calendar/pages/event/event.html index 00acf2531..445329e5c 100644 --- a/src/addons/calendar/pages/event/event.html +++ b/src/addons/calendar/pages/event/event.html @@ -28,7 +28,7 @@ - { @@ -168,8 +162,6 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { * @return Promise resolved when done. */ async fetchEvent(sync = false, showErrors = false): Promise { - const currentSite = CoreSites.getCurrentSite(); - const canGetById = AddonCalendar.isGetEventByIdAvailableInSite(); let deleted = false; this.isOnline = CoreApp.isOnline(); @@ -209,13 +201,8 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { } try { - let event: AddonCalendarEvent | AddonCalendarEventBase | AddonCalendarGetEventsEvent; // Get the event data. - if (canGetById) { - event = await AddonCalendar.getEventById(this.eventId); - } else { - event = await AddonCalendar.getEvent(this.eventId); - } + const event = await AddonCalendar.getEventById(this.eventId); this.event = AddonCalendarHelper.formatEventData(event); try { @@ -254,9 +241,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { } // Get the module URL. - if (canGetById) { - this.moduleUrl = this.event!.url || ''; - } + this.moduleUrl = this.event!.url || ''; } const promises: Promise[] = []; @@ -264,24 +249,10 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { const courseId = this.event.courseid; if (courseId != this.siteHomeId) { // If the event belongs to a course, get the course name and the URL to view it. - if (canGetById && this.event.course) { + if (this.event.course) { this.courseId = this.event.course.id; this.courseName = this.event.course.fullname; this.courseUrl = this.event.course.viewurl; - } else if (!canGetById && this.event.courseid ) { - // Retrieve the course. - promises.push(CoreCourses.getUserCourse(this.event.courseid, true).then((course) => { - this.courseId = course.id; - this.courseName = course.fullname; - this.courseUrl = currentSite ? CoreTextUtils.concatenatePaths( - currentSite.siteUrl, - '/course/view.php?id=' + this.courseId, - ) : ''; - - return; - }).catch(() => { - // Error getting course, just don't show the course name. - })); } } @@ -299,7 +270,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { })); } - if (canGetById && this.event.iscategoryevent && this.event.category) { + if (this.event.iscategoryevent && this.event.category) { this.categoryPath = this.event.category.nestedname; } diff --git a/src/addons/calendar/pages/list/list.html b/src/addons/calendar/pages/list/list.html deleted file mode 100644 index 9e64554e4..000000000 --- a/src/addons/calendar/pages/list/list.html +++ /dev/null @@ -1,96 +0,0 @@ - - - - - -

{{ 'addon.calendar.calendarevents' | translate }}

- - - - - - - - - - -
-
- - - - - - - - - - {{ 'core.hasdatatosync' | translate:{$a: 'addon.calendar.calendar' | translate} }} - - - - - - - - - -

{{ event.timestart * 1000 | coreFormatDate: "strftimedayshort" }}

-
- - - - -

- - - {{ 'addon.calendar.type' + event.formattedType | translate }} - {{ event.iconTitle }} - - - -

-

- {{ event.timestart * 1000 | coreFormatDate: "strftimetime" }} - - - {{ (event.timestart + event.timeduration) * 1000 | coreFormatDate: "strftimetime" }} - - - - {{ (event.timestart + event.timeduration) * 1000 | coreFormatDate: "strftimedatetimeshort" }} - -

-
- - - {{ 'core.notsent' | translate }} - - - - {{ 'core.deletedoffline' | translate }} - -
-
-
- - - -
- - - - - - {{ 'addon.calendar.newevent' | translate }} - - -
diff --git a/src/addons/calendar/pages/list/list.module.ts b/src/addons/calendar/pages/list/list.module.ts deleted file mode 100644 index 751dfd235..000000000 --- a/src/addons/calendar/pages/list/list.module.ts +++ /dev/null @@ -1,60 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// 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 { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { AddonCalendarEventRoute, AddonCalendarEditRoute } from '@addons/calendar/calendar-lazy.module'; -import { conditionalRoutes } from '@/app/app-routing.module'; -import { CoreScreen } from '@services/screen'; - -import { CoreSharedModule } from '@/core/shared.module'; - -import { AddonCalendarListPage } from './list.page'; - -const splitviewRoutes = [AddonCalendarEditRoute, AddonCalendarEventRoute]; - -const mobileRoutes: Routes = [ - { - path: '', - component: AddonCalendarListPage, - }, - ...splitviewRoutes, -]; - -const tabletRoutes: Routes = [ - { - path: '', - component: AddonCalendarListPage, - children: [ - ...splitviewRoutes, - ], - }, -]; - -const routes: Routes = [ - ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), - ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), -]; - -@NgModule({ - imports: [ - RouterModule.forChild(routes), - CoreSharedModule, - ], - declarations: [ - AddonCalendarListPage, - ], - exports: [RouterModule], -}) -export class AddonCalendarListPageModule {} diff --git a/src/addons/calendar/pages/list/list.page.ts b/src/addons/calendar/pages/list/list.page.ts deleted file mode 100644 index 6cdf62469..000000000 --- a/src/addons/calendar/pages/list/list.page.ts +++ /dev/null @@ -1,643 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// 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 { Component, ViewChild, OnDestroy, OnInit } from '@angular/core'; -import { IonContent, IonRefresher } from '@ionic/angular'; -import { - AddonCalendarProvider, - AddonCalendar, - AddonCalendarEventToDisplay, -} from '../../services/calendar'; -import { AddonCalendarOffline } from '../../services/calendar-offline'; -import { AddonCalendarFilter, AddonCalendarHelper } from '../../services/calendar-helper'; -import { AddonCalendarSync, AddonCalendarSyncProvider } from '../../services/calendar-sync'; -import { CoreCategoryData, CoreCourses, CoreEnrolledCourseData } from '@features/courses/services/courses'; -import { CoreDomUtils } from '@services/utils/dom'; -import { CoreTimeUtils } from '@services/utils/time'; -import { CoreSites } from '@services/sites'; -import { CoreLocalNotifications } from '@services/local-notifications'; -import { CoreEventObserver, CoreEvents } from '@singletons/events'; -import { CoreApp } from '@services/app'; -import moment from 'moment'; -import { CoreConstants } from '@/core/constants'; -import { AddonCalendarFilterPopoverComponent } from '../../components/filter/filter'; -import { Params } from '@angular/router'; -import { Subscription } from 'rxjs'; -import { Network, NgZone } from '@singletons'; -import { CoreCoursesHelper } from '@features/courses/services/courses-helper'; -import { CoreUtils } from '@services/utils/utils'; -import { CoreNavigator } from '@services/navigator'; - -/** - * Page that displays the list of calendar events. - */ -@Component({ - selector: 'page-addon-calendar-list', - templateUrl: 'list.html', - styleUrls: ['../../calendar-common.scss', 'list.scss'], -}) -export class AddonCalendarListPage implements OnInit, OnDestroy { - - @ViewChild(IonContent) content?: IonContent; - - protected initialTime = 0; - protected daysLoaded = 0; - protected emptyEventsTimes = 0; // Variable to identify consecutive calls returning 0 events. - protected categoriesRetrieved = false; - protected getCategories = false; - protected categories: { [id: number]: CoreCategoryData } = {}; - protected siteHomeId: number; - protected currentSiteId: string; - protected onlineEvents: AddonCalendarEventToDisplay[] = []; - protected offlineEvents: AddonCalendarEventToDisplay[] = []; - protected deletedEvents: number [] = []; - - // Observers. - protected obsDefaultTimeChange?: CoreEventObserver; - protected newEventObserver: CoreEventObserver; - protected discardedObserver: CoreEventObserver; - protected editEventObserver: CoreEventObserver; - protected deleteEventObserver: CoreEventObserver; - protected undeleteEventObserver: CoreEventObserver; - protected syncObserver: CoreEventObserver; - protected manualSyncObserver: CoreEventObserver; - protected filterChangedObserver: CoreEventObserver; - protected onlineObserver: Subscription; - - eventId?: number; // Selected EventId on list - courses: Partial[] = []; - eventsLoaded = false; - events: AddonCalendarEventToDisplay[] = []; // Events (both online and offline). - notificationsEnabled = false; - filteredEvents: AddonCalendarEventToDisplay[] = []; - canLoadMore = false; - loadMoreError = false; - canCreate = false; - hasOffline = false; - isOnline = false; - syncIcon = CoreConstants.ICON_LOADING; - filter: AddonCalendarFilter = { - filtered: false, - courseId: undefined, - categoryId: undefined, - course: true, - group: true, - site: true, - user: true, - category: true, - }; - - constructor() { - - this.siteHomeId = CoreSites.getCurrentSiteHomeId(); - this.notificationsEnabled = CoreLocalNotifications.isAvailable(); - this.currentSiteId = CoreSites.getCurrentSiteId(); - - if (this.notificationsEnabled) { - // Re-schedule events if default time changes. - this.obsDefaultTimeChange = CoreEvents.on(AddonCalendarProvider.DEFAULT_NOTIFICATION_TIME_CHANGED, () => { - AddonCalendar.scheduleEventsNotifications(this.onlineEvents); - }, this.currentSiteId); - } - - // Listen for events added. When an event is added, reload the data. - this.newEventObserver = CoreEvents.on(AddonCalendarProvider.NEW_EVENT_EVENT, (data) => { - if (data && data.eventId) { - this.eventsLoaded = false; - this.refreshEvents(true, false); - } - }, this.currentSiteId); - - // Listen for new event discarded event. When it does, reload the data. - this.discardedObserver = CoreEvents.on(AddonCalendarProvider.NEW_EVENT_DISCARDED_EVENT, () => { - this.eventsLoaded = false; - this.refreshEvents(true, false); - }, this.currentSiteId); - - // Listen for events edited. When an event is edited, reload the data. - this.editEventObserver = CoreEvents.on(AddonCalendarProvider.EDIT_EVENT_EVENT, (data) => { - if (data && data.eventId) { - this.eventsLoaded = false; - this.refreshEvents(true, false); - } - }, this.currentSiteId); - - // Refresh data if calendar events are synchronized automatically. - this.syncObserver = CoreEvents.on(AddonCalendarSyncProvider.AUTO_SYNCED, () => { - this.eventsLoaded = false; - this.refreshEvents(); - }, this.currentSiteId); - - // Refresh data if calendar events are synchronized manually but not by this page. - this.manualSyncObserver = CoreEvents.on(AddonCalendarSyncProvider.MANUAL_SYNCED, (data) => { - if (data && data.source != 'list') { - this.eventsLoaded = false; - this.refreshEvents(); - } - }, this.currentSiteId); - - // Update the list when an event is deleted. - this.deleteEventObserver = CoreEvents.on( - AddonCalendarProvider.DELETED_EVENT_EVENT, - (data) => { - if (data && !data.sent) { - // Event was deleted in offline. Just mark it as deleted, no need to refresh. - this.markAsDeleted(data.eventId, true); - this.deletedEvents.push(data.eventId); - this.hasOffline = true; - } else { - // Event deleted, refresh the view. - this.eventsLoaded = false; - this.refreshEvents(); - } - }, - this.currentSiteId, - ); - - // Listen for events "undeleted" (offline). - this.undeleteEventObserver = CoreEvents.on( - AddonCalendarProvider.UNDELETED_EVENT_EVENT, - (data) => { - if (!data || !data.eventId) { - return; - } - - // Mark it as undeleted, no need to refresh. - this.markAsDeleted(data.eventId, false); - - // Remove it from the list of deleted events if it's there. - const index = this.deletedEvents.indexOf(data.eventId); - if (index != -1) { - this.deletedEvents.splice(index, 1); - } - - this.hasOffline = !!this.offlineEvents.length || !!this.deletedEvents.length; - }, - this.currentSiteId, - ); - - this.filterChangedObserver = - CoreEvents.on(AddonCalendarProvider.FILTER_CHANGED_EVENT, async (data) => { - this.filter = data; - - // Course viewed has changed, check if the user can create events for this course calendar. - this.canCreate = await AddonCalendarHelper.canEditEvents(this.filter.courseId); - - this.filterEvents(); - - this.content?.scrollToTop(); - }); - - // Refresh online status when changes. - this.onlineObserver = Network.onChange().subscribe(() => { - // Execute the callback in the Angular zone, so change detection doesn't stop working. - NgZone.run(() => { - this.isOnline = CoreApp.isOnline(); - }); - }); - } - - /** - * View loaded. - */ - async ngOnInit(): Promise { - this.filter.courseId = CoreNavigator.getRouteNumberParam('courseId'); - this.syncIcon = CoreConstants.ICON_LOADING; - - await this.fetchData(false, true, false); - } - - /** - * Fetch all the data required for the view. - * - * @param refresh Empty events array first. - * @param sync Whether it should try to synchronize offline events. - * @param showErrors Whether to show sync errors to the user. - * @return Promise resolved when done. - */ - async fetchData(refresh = false, sync = false, showErrors = false): Promise { - this.initialTime = CoreTimeUtils.timestamp(); - this.daysLoaded = 0; - this.emptyEventsTimes = 0; - this.isOnline = CoreApp.isOnline(); - - if (sync) { - // Try to synchronize offline events. - try { - const result = await AddonCalendarSync.syncEvents(); - if (result.warnings && result.warnings.length) { - CoreDomUtils.showErrorModal(result.warnings[0]); - } - - if (result.updated) { - // Trigger a manual sync event. - result.source = 'list'; - - CoreEvents.trigger( - AddonCalendarSyncProvider.MANUAL_SYNCED, - result, - this.currentSiteId, - ); - } - } catch (error) { - if (showErrors) { - CoreDomUtils.showErrorModalDefault(error, 'core.errorsync', true); - } - } - } - - try { - const promises: Promise[] = []; - - this.hasOffline = false; - - promises.push(AddonCalendarHelper.canEditEvents(this.filter.courseId).then((canEdit) => { - this.canCreate = canEdit; - - return; - })); - - // Load courses for the popover. - promises.push(CoreCoursesHelper.getCoursesForPopover(this.filter.courseId).then((result) => { - this.courses = result.courses; - - return this.fetchEvents(refresh); - })); - - // Get offline events. - promises.push(AddonCalendarOffline.getAllEditedEvents().then((offlineEvents) => { - this.hasOffline = this.hasOffline || !!offlineEvents.length; - - // Format data and sort by timestart. - const events: AddonCalendarEventToDisplay[] = offlineEvents.map((event) => - AddonCalendarHelper.formatOfflineEventData(event)); - - this.offlineEvents = AddonCalendarHelper.sortEvents(events); - - return; - })); - - // Get events deleted in offline. - promises.push(AddonCalendarOffline.getAllDeletedEventsIds().then((ids) => { - this.hasOffline = this.hasOffline || !!ids.length; - this.deletedEvents = ids; - - return; - })); - - await Promise.all(promises); - } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.calendar.errorloadevents', true); - } - - this.eventsLoaded = true; - this.syncIcon = CoreConstants.ICON_SYNC; - } - - /** - * Fetches the events and updates the view. - * - * @param refresh Empty events array first. - * @return Promise resolved when done. - */ - async fetchEvents(refresh = false): Promise { - this.loadMoreError = false; - - try { - const onlineEventsTemp = - await AddonCalendar.getEventsList(this.initialTime, this.daysLoaded, AddonCalendarProvider.DAYS_INTERVAL); - - if (onlineEventsTemp.length === 0) { - this.emptyEventsTimes++; - if (this.emptyEventsTimes > 5) { // Stop execution if we retrieve empty list 6 consecutive times. - this.canLoadMore = false; - if (refresh) { - this.onlineEvents = []; - this.filteredEvents = []; - this.events = this.offlineEvents; - } - } else { - // No events returned, load next events. - this.daysLoaded += AddonCalendarProvider.DAYS_INTERVAL; - - return this.fetchEvents(); - } - } else { - const onlineEvents = onlineEventsTemp.map((event) => AddonCalendarHelper.formatEventData(event)); - - // Get the merged events of this period. - const events = this.mergeEvents(onlineEvents); - - this.getCategories = this.shouldLoadCategories(onlineEvents); - - if (refresh) { - this.onlineEvents = onlineEvents; - this.events = events; - } else { - // Filter events with same ID. Repeated events are returned once per WS call, show them only once. - this.onlineEvents = CoreUtils.mergeArraysWithoutDuplicates(this.onlineEvents, onlineEvents, 'id'); - this.events = CoreUtils.mergeArraysWithoutDuplicates(this.events, events, 'id'); - } - this.filterEvents(); - - // Calculate which evemts need to display the date. - this.filteredEvents.forEach((event, index) => { - event.showDate = this.showDate(event, this.filteredEvents[index - 1]); - event.endsSameDay = this.endsSameDay(event); - }); - this.canLoadMore = true; - - // Schedule notifications for the events retrieved (might have new events). - AddonCalendar.scheduleEventsNotifications(this.onlineEvents); - - this.daysLoaded += AddonCalendarProvider.DAYS_INTERVAL; - } - } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.calendar.errorloadevents', true); - this.loadMoreError = true; // Set to prevent infinite calls with infinite-loading. - } - - // Success retrieving events. Get categories if needed. - if (this.getCategories) { - this.getCategories = false; - - return this.loadCategories(); - } - } - - /** - * Function to load more events. - * - * @param infiniteComplete Infinite scroll complete function. Only used from core-infinite-loading. - * @return Resolved when done. - */ - loadMoreEvents(infiniteComplete?: () => void ): void { - this.fetchEvents().finally(() => { - infiniteComplete && infiniteComplete(); - }); - } - - protected filterEvents(): void { - this.filteredEvents = AddonCalendarHelper.getFilteredEvents(this.events, this.filter, this.categories); - } - - /** - * Returns if the current state should load categories or not. - * - * @param events Events to parse. - * @return True if categories should be loaded. - */ - protected shouldLoadCategories(events: AddonCalendarEventToDisplay[]): boolean { - if (this.categoriesRetrieved || this.getCategories) { - // Use previous value - return this.getCategories; - } - - // Categories not loaded yet. We should get them if there's any category event. - const found = events.some((event) => typeof event.categoryid != 'undefined' && event.categoryid > 0); - - return found || this.getCategories; - } - - /** - * Load categories to be able to filter events. - * - * @return Promise resolved when done. - */ - protected async loadCategories(): Promise { - try { - const cats = await CoreCourses.getCategories(0, true); - this.categoriesRetrieved = true; - this.categories = {}; - // Index categories by ID. - cats.forEach((category) => { - this.categories[category.id] = category; - }); - } catch { - // Ignore errors. - } - } - - /** - * Merge a period of online events with the offline events of that period. - * - * @param onlineEvents Online events. - * @return Merged events. - */ - protected mergeEvents(onlineEvents: AddonCalendarEventToDisplay[]): AddonCalendarEventToDisplay[] { - if (!this.offlineEvents.length && !this.deletedEvents.length) { - // No offline events, nothing to merge. - return onlineEvents; - } - - const start = this.initialTime + (CoreConstants.SECONDS_DAY * this.daysLoaded); - const end = start + (CoreConstants.SECONDS_DAY * AddonCalendarProvider.DAYS_INTERVAL) - 1; - let result = onlineEvents; - - if (this.deletedEvents.length) { - // Mark as deleted the events that were deleted in offline. - result.forEach((event) => { - event.deleted = this.deletedEvents.indexOf(event.id) != -1; - }); - } - - if (this.offlineEvents.length) { - // Remove the online events that were modified in offline. - result = result.filter((event) => { - const offlineEvent = this.offlineEvents.find((ev) => ev.id == event.id); - - return !offlineEvent; - }); - } - - // Now get the offline events that belong to this period. - const periodOfflineEvents = this.offlineEvents.filter((event) => { - if (this.daysLoaded == 0 && event.timestart < start) { - // Display offline events that are previous to current time to allow editing them. - return true; - } - - return (event.timestart >= start || event.timestart + event.timeduration >= start) && event.timestart <= end; - }); - - // Merge both arrays and sort them. - result = result.concat(periodOfflineEvents); - - return AddonCalendarHelper.sortEvents(result); - } - - /** - * Refresh the data. - * - * @param refresher Refresher. - * @param done Function to call when done. - * @param showErrors Whether to show sync errors to the user. - * @return Promise resolved when done. - */ - async doRefresh(refresher?: IonRefresher, done?: () => void, showErrors?: boolean): Promise { - if (!this.eventsLoaded) { - return; - } - - await this.refreshEvents(true, showErrors).finally(() => { - refresher?.complete(); - done && done(); - }); - } - - /** - * Refresh the events. - * - * @param sync Whether it should try to synchronize offline events. - * @param showErrors Whether to show sync errors to the user. - * @return Promise resolved when done. - */ - async refreshEvents(sync?: boolean, showErrors?: boolean): Promise { - this.syncIcon = CoreConstants.ICON_LOADING; - - const promises: Promise[] = []; - - promises.push(AddonCalendar.invalidateEventsList()); - promises.push(AddonCalendar.invalidateAllowedEventTypes()); - - if (this.categoriesRetrieved) { - promises.push(CoreCourses.invalidateCategories(0, true)); - this.categoriesRetrieved = false; - } - - await Promise.all(promises).finally(() => this.fetchData(true, sync, showErrors)); - } - - /** - * Check date should be shown on event list for the current event. - * If date has changed from previous to current event it should be shown. - * - * @param event Current event where to show the date. - * @param prevEvent Previous event where to compare the date with. - * @return If date has changed and should be shown. - */ - protected showDate(event: AddonCalendarEventToDisplay, prevEvent?: AddonCalendarEventToDisplay): boolean { - if (!prevEvent) { - // First event, show it. - return true; - } - - // Check if day has changed. - return !moment(event.timestart * 1000).isSame(prevEvent.timestart * 1000, 'day'); - } - - /** - * Check if event ends the same date or not. - * - * @param event Event info. - * @return If date has changed and should be shown. - */ - protected endsSameDay(event: AddonCalendarEventToDisplay): boolean { - if (!event.timeduration) { - // No duration. - return true; - } - - // Check if day has changed. - return moment(event.timestart * 1000).isSame((event.timestart + event.timeduration) * 1000, 'day'); - } - - /** - * Show the context menu. - * - * @param event Event. - */ - async openFilter(event: MouseEvent): Promise { - await CoreDomUtils.openPopover({ - component: AddonCalendarFilterPopoverComponent, - componentProps: { - courses: this.courses, - filter: this.filter, - }, - event, - }); - } - - /** - * Open page to create/edit an event. - * - * @param eventId Event ID to edit. - */ - openEdit(eventId?: number): void { - this.eventId = undefined; - eventId = eventId || 0; - - const params: Params = {}; - - if (this.filter.courseId) { - params.courseId = this.filter.courseId; - } - - CoreNavigator.navigateToSitePath(`calendar/edit/${eventId}`, { params }); - } - - /** - * Open calendar events settings. - */ - openSettings(): void { - CoreNavigator.navigateToSitePath('/calendar/settings'); - } - - /** - * Navigate to a particular event. - * - * @param eventId Event to load. - */ - gotoEvent(eventId: number): void { - this.eventId = eventId; - - if (eventId <= 0) { - // It's an offline event, go to the edit page. - this.openEdit(eventId); - } else { - CoreNavigator.navigateToSitePath(`/calendar/event/${eventId}`); - } - } - - /** - * Find an event and mark it as deleted. - * - * @param eventId Event ID. - * @param deleted Whether to mark it as deleted or not. - */ - protected markAsDeleted(eventId: number, deleted: boolean): void { - const event = this.onlineEvents.find((event) => event.id == eventId); - - if (event) { - event.deleted = deleted; - } - } - - /** - * Page destroyed. - */ - ngOnDestroy(): void { - this.obsDefaultTimeChange?.off(); - this.newEventObserver?.off(); - this.discardedObserver?.off(); - this.editEventObserver?.off(); - this.deleteEventObserver?.off(); - this.undeleteEventObserver?.off(); - this.syncObserver?.off(); - this.manualSyncObserver?.off(); - this.filterChangedObserver?.off(); - this.onlineObserver?.unsubscribe(); - } - -} diff --git a/src/addons/calendar/pages/list/list.scss b/src/addons/calendar/pages/list/list.scss deleted file mode 100644 index 28505ddcb..000000000 --- a/src/addons/calendar/pages/list/list.scss +++ /dev/null @@ -1,5 +0,0 @@ -:host { - ion-note { - max-width: 30%; - } -} diff --git a/src/addons/calendar/services/calendar.ts b/src/addons/calendar/services/calendar.ts index 0d3c84412..b4ab29361 100644 --- a/src/addons/calendar/services/calendar.ts +++ b/src/addons/calendar/services/calendar.ts @@ -125,36 +125,6 @@ export class AddonCalendarProvider { }, ]; - /** - * Check if a certain site allows deleting events. - * - * @param siteId Site Id. If not defined, use current site. - * @return Promise resolved with true if can delete. - * @since 3.3 - */ - async canDeleteEvents(siteId?: string): Promise { - try { - const site = await CoreSites.getSite(siteId); - - return this.canDeleteEventsInSite(site); - } catch { - return false; - } - } - - /** - * Check if a certain site allows deleting events. - * - * @param site Site. If not defined, use current site. - * @return Whether events can be deleted. - * @since 3.3 - */ - canDeleteEventsInSite(site?: CoreSite): boolean { - site = site || CoreSites.getCurrentSite(); - - return !!site?.wsAvailable('core_calendar_delete_calendar_events'); - } - /** * Check if a certain site allows creating and editing events. * @@ -186,67 +156,6 @@ export class AddonCalendarProvider { return !!site?.isVersionGreaterEqualThan('3.7.1'); } - /** - * Check if a certain site allows viewing events in monthly view. - * - * @param siteId Site Id. If not defined, use current site. - * @return Promise resolved with true if monthly view is supported. - * @since 3.4 - */ - async canViewMonth(siteId?: string): Promise { - try { - const site = await CoreSites.getSite(siteId); - - return this.canViewMonthInSite(site); - } catch { - return false; - } - } - - /** - * Check if a certain site allows viewing events in monthly view. - * - * @param site Site. If not defined, use current site. - * @return Whether monthly view is supported. - * @since 3.4 - */ - canViewMonthInSite(site?: CoreSite): boolean { - site = site || CoreSites.getCurrentSite(); - - return !!site?.wsAvailable('core_calendar_get_calendar_monthly_view'); - } - - /** - * Gets the site main calendar page path. - * - * @param site Site. If not defined, use current site. - * @return Main calendar page path of the site. - */ - getMainCalendarPagePath(site?: CoreSite): string { - return AddonCalendarMainMenuHandlerService.PAGE_NAME + (this.canViewMonthInSite(site) ? '' : '/list'); - } - - /** - * Removes expired events from local DB. - * - * @param siteId ID of the site the event belongs to. If not defined, use current site. - * @return Promise resolved when done. - */ - async cleanExpiredEvents(siteId?: string): Promise { - const site = await CoreSites.getSite(siteId); - if (this.canViewMonthInSite(site)) { - // Site supports monthly view, don't clean expired events because user can see past events. - return; - } - const events = await site.getDb().getRecordsSelect( - EVENTS_TABLE, - 'timestart + timeduration < ?', - [CoreTimeUtils.timestamp()], - ); - - await Promise.all(events.map((event) => this.deleteLocalEvent(event.id!, siteId))); - } - /** * Delete an event. * @@ -367,12 +276,8 @@ export class AddonCalendarProvider { return; } - // Check which page we should load. - const site = await CoreSites.getSite(notification.siteId); - const pageName = this.getMainCalendarPagePath(site); - CoreNavigator.navigateToSitePath( - pageName, + AddonCalendarMainMenuHandlerService.PAGE_NAME, { siteId: notification.siteId, preferCurrentTab: false, @@ -695,7 +600,6 @@ export class AddonCalendarProvider { * @param id Event ID. * @param siteId ID of the site. If not defined, use current site. * @return Promise resolved when the event data is retrieved. - * @since 3.4 */ async getEventById(id: number, siteId?: string): Promise { const site = await CoreSites.getSite(siteId); @@ -742,10 +646,6 @@ export class AddonCalendarProvider { const record: AddonCalendarGetEventsEvent | AddonCalendarEvent | AddonCalendarEventDBRecord = await site.getDb().getRecord(EVENTS_TABLE, { id: id }); - if (!this.isGetEventByIdAvailableInSite(site)) { - return record as AddonCalendarGetEventsEvent; - } - const eventConverted = record as AddonCalendarEvent; const originalEvent = record as AddonCalendarGetEventsEvent; const recordAsRecord = record as AddonCalendarEventDBRecord; @@ -994,10 +894,6 @@ export class AddonCalendarProvider { }; const response: AddonCalendarGetCalendarEventsWSResponse = await site.read('core_calendar_get_calendar_events', params, preSets); - if (!this.canViewMonthInSite(site)) { - // Store events only in 3.1-3.3. In 3.4+ we'll use the new WS that return more info. - this.storeEventsInLocalDB(response.events, siteId); - } return response.events; } @@ -1059,12 +955,8 @@ export class AddonCalendarProvider { const params: AddonCalendarGetCalendarMonthlyViewWSParams = { year: year, month: month, + mini: true, // Set mini to 1 to prevent returning the course selector HTML. }; - // This parameter requires Moodle 3.5. - if (site.isVersionGreaterEqualThan('3.5')) { - // Set mini to 1 to prevent returning the course selector HTML. - params.mini = true; - } if (courseId) { params.courseid = courseId; } @@ -1406,36 +1298,6 @@ export class AddonCalendarProvider { return this.isCalendarDisabledInSite(site); } - /** - * Check if the get event by ID WS is available. - * - * @param siteId Site Id. If not defined, use current site. - * @return Promise resolved with true if available. - * @since 3.4 - */ - async isGetEventByIdAvailable(siteId?: string): Promise { - try { - const site = await CoreSites.getSite(siteId); - - return this.isGetEventByIdAvailableInSite(site); - } catch { - return false; - } - } - - /** - * Check if the get event by ID WS is available in a certain site. - * - * @param site Site. If not defined, use current site. - * @return Whether it's available. - * @since 3.4 - */ - isGetEventByIdAvailableInSite(site?: CoreSite): boolean { - site = site || CoreSites.getCurrentSite(); - - return !!site?.wsAvailable('core_calendar_get_calendar_event_by_id'); - } - /** * Get the next events for all the sites and schedules their notifications. * If an event notification time is 0, cancel its scheduled notification (if any). @@ -1450,7 +1312,7 @@ export class AddonCalendarProvider { const siteIds = await CoreSites.getSitesIds(); - const promises = siteIds.map((siteId: string) => this.cleanExpiredEvents(siteId).then(async() => { + const promises = siteIds.map((siteId: string) => async () => { if (notificationsEnabled) { // Check if calendar is disabled for the site. const disabled = await this.isDisabled(siteId); @@ -1462,7 +1324,7 @@ export class AddonCalendarProvider { } return; - })); + }); await Promise.all(promises); } @@ -1995,7 +1857,7 @@ export type AddonCalendarMonth = { date: CoreWSDate; periodname: string; // Periodname. includenavigation: boolean; // Includenavigation. - initialeventsloaded: boolean; // @since 3.5. Initialeventsloaded. + initialeventsloaded: boolean; // Initialeventsloaded. previousperiod: CoreWSDate; previousperiodlink: string; // Previousperiodlink. previousperiodname: string; // Previousperiodname. @@ -2151,7 +2013,7 @@ export type AddonCalendarGetEventsEvent = { description?: string; // Description. format: number; // Description format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN). courseid: number; // Course id. - categoryid?: number; // @since 3.4. Category id (only for category events). + categoryid?: number; // Category id (only for category events). groupid: number; // Group id. userid: number; // User id. repeatid: number; // Repeat id. diff --git a/src/addons/calendar/services/handlers/mainmenu.ts b/src/addons/calendar/services/handlers/mainmenu.ts index 5540b1149..2893888a5 100644 --- a/src/addons/calendar/services/handlers/mainmenu.ts +++ b/src/addons/calendar/services/handlers/mainmenu.ts @@ -46,7 +46,7 @@ export class AddonCalendarMainMenuHandlerService implements CoreMainMenuHandler return { icon: 'far-calendar', title: 'addon.calendar.calendar', - page: AddonCalendar.getMainCalendarPagePath(), + page: AddonCalendarMainMenuHandlerService.PAGE_NAME, class: 'addon-calendar-handler', }; } diff --git a/src/addons/calendar/services/handlers/view-link.ts b/src/addons/calendar/services/handlers/view-link.ts index e7a59019f..45914e697 100644 --- a/src/addons/calendar/services/handlers/view-link.ts +++ b/src/addons/calendar/services/handlers/view-link.ts @@ -111,13 +111,9 @@ export class AddonCalendarViewLinkHandlerService extends CoreContentLinksHandler return false; } - return AddonCalendar.isDisabled(siteId).then((disabled) => { - if (disabled) { - return false; - } + const disabled = await AddonCalendar.isDisabled(siteId); - return AddonCalendar.canViewMonth(siteId); - }); + return !disabled; } } diff --git a/src/addons/messageoutput/airnotifier/services/airnotifier.ts b/src/addons/messageoutput/airnotifier/services/airnotifier.ts index d52f8edf2..e84da309e 100644 --- a/src/addons/messageoutput/airnotifier/services/airnotifier.ts +++ b/src/addons/messageoutput/airnotifier/services/airnotifier.ts @@ -125,17 +125,6 @@ export class AddonMessageOutputAirnotifierProvider { return site.invalidateWsCacheForKey(this.getUserDevicesCacheKey()); } - /** - * Returns whether or not the plugin is enabled for the current site. - * - * @return True if enabled, false otherwise. - * @since 3.2 - */ - isEnabled(): boolean { - return CoreSites.wsAvailableInCurrentSite('message_airnotifier_enable_device') && - CoreSites.wsAvailableInCurrentSite('message_airnotifier_get_user_devices'); - } - } export const AddonMessageOutputAirnotifier = makeSingleton(AddonMessageOutputAirnotifierProvider); diff --git a/src/addons/messageoutput/airnotifier/services/handlers/messageoutput.ts b/src/addons/messageoutput/airnotifier/services/handlers/messageoutput.ts index 792a4322c..f83f8945c 100644 --- a/src/addons/messageoutput/airnotifier/services/handlers/messageoutput.ts +++ b/src/addons/messageoutput/airnotifier/services/handlers/messageoutput.ts @@ -15,7 +15,6 @@ import { Injectable } from '@angular/core'; import { AddonMessageOutputHandler, AddonMessageOutputHandlerData } from '@addons/messageoutput/services/messageoutput-delegate'; -import { AddonMessageOutputAirnotifierProvider } from '../airnotifier'; import { makeSingleton } from '@singletons'; /** @@ -29,15 +28,13 @@ export class AddonMessageOutputAirnotifierHandlerService implements AddonMessage name = 'AddonMessageOutputAirnotifier'; processorName = 'airnotifier'; - constructor(private airnotifierProvider: AddonMessageOutputAirnotifierProvider) {} - /** * Whether or not the module is enabled for the site. * * @return True if enabled, false otherwise. */ async isEnabled(): Promise { - return this.airnotifierProvider.isEnabled(); + return true; } /** diff --git a/src/addons/messages/messages-lazy.module.ts b/src/addons/messages/messages-lazy.module.ts index ae0d95b6c..061f8f1e1 100644 --- a/src/addons/messages/messages-lazy.module.ts +++ b/src/addons/messages/messages-lazy.module.ts @@ -27,12 +27,12 @@ export const AddonMessagesDiscussionRoute: Route = { function buildRoutes(injector: Injector): Routes { return [ { - path: 'index', // 3.5 or lower. + path: 'index', // 3.5. loadChildren: () => import('./pages/discussions-35/discussions.module').then(m => m.AddonMessagesDiscussions35PageModule), }, { - path: 'contacts-35', // 3.5 or lower. + path: 'contacts-35', // 3.5. loadChildren: () => import('./pages/contacts-35/contacts.module').then(m => m.AddonMessagesContacts35PageModule), }, { diff --git a/src/addons/messages/pages/discussion/discussion.page.ts b/src/addons/messages/pages/discussion/discussion.page.ts index 4617e2e3e..bb9689cd0 100644 --- a/src/addons/messages/pages/discussion/discussion.page.ts +++ b/src/addons/messages/pages/discussion/discussion.page.ts @@ -747,58 +747,37 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView */ protected async markMessagesAsRead(forceMark: boolean): Promise { let readChanged = false; + let messageUnreadFound = false; - if (AddonMessages.isMarkAllMessagesReadEnabled()) { - let messageUnreadFound = false; - - // Mark all messages at a time if there is any unread message. - if (forceMark) { - messageUnreadFound = true; - } else if (this.groupMessagingEnabled) { - messageUnreadFound = !!((this.conversation?.unreadcount && this.conversation?.unreadcount > 0) && - (this.conversationId && this.conversationId > 0)); - } else { - // If an unread message is found, mark all messages as read. - messageUnreadFound = this.messages.some((message) => - message.useridfrom != this.currentUserId && ('read' in message && !message.read)); - } - - if (messageUnreadFound) { - this.setUnreadLabelPosition(); - - if (this.groupMessagingEnabled) { - await AddonMessages.markAllConversationMessagesRead(this.conversationId!); - } else { - await AddonMessages.markAllMessagesRead(this.userId); - - // Mark all messages as read. - this.messages.forEach((message) => { - if ('read' in message) { - message.read = true; - } - }); - } - - readChanged = true; - } + // Mark all messages at a time if there is any unread message. + if (forceMark) { + messageUnreadFound = true; + } else if (this.groupMessagingEnabled) { + messageUnreadFound = !!((this.conversation?.unreadcount && this.conversation?.unreadcount > 0) && + (this.conversationId && this.conversationId > 0)); } else { + // If an unread message is found, mark all messages as read. + messageUnreadFound = this.messages.some((message) => + message.useridfrom != this.currentUserId && ('read' in message && !message.read)); + } + + if (messageUnreadFound) { this.setUnreadLabelPosition(); - const promises: Promise[] = []; - // Mark each message as read one by one. - this.messages.forEach((message) => { - // If the message is unread, call AddonMessages.markMessageRead. - if (message.useridfrom != this.currentUserId && 'read' in message && !message.read) { - promises.push(AddonMessages.markMessageRead(message.id).then(() => { - readChanged = true; + if (this.groupMessagingEnabled) { + await AddonMessages.markAllConversationMessagesRead(this.conversationId!); + } else { + await AddonMessages.markAllMessagesRead(this.userId); + + // Mark all messages as read. + this.messages.forEach((message) => { + if ('read' in message) { message.read = true; + } + }); + } - return; - })); - } - }); - - await Promise.all(promises); + readChanged = true; } if (readChanged) { diff --git a/src/addons/messages/pages/discussions-35/discussions.html b/src/addons/messages/pages/discussions-35/discussions.html index ed02b96d8..3e756130b 100644 --- a/src/addons/messages/pages/discussions-35/discussions.html +++ b/src/addons/messages/pages/discussions-35/discussions.html @@ -17,7 +17,7 @@ - diff --git a/src/addons/messages/pages/discussions-35/discussions.page.ts b/src/addons/messages/pages/discussions-35/discussions.page.ts index ee8c821e7..5c904cbae 100644 --- a/src/addons/messages/pages/discussions-35/discussions.page.ts +++ b/src/addons/messages/pages/discussions-35/discussions.page.ts @@ -56,7 +56,6 @@ export class AddonMessagesDiscussions35Page implements OnInit, OnDestroy { discussionUserId?: number; search = { - enabled: false, showResults: false, results: [], loading: '', @@ -179,7 +178,6 @@ export class AddonMessagesDiscussions35Page implements OnInit, OnDestroy { */ protected async fetchData(): Promise { this.loadingMessage = this.loadingMessages; - this.search.enabled = AddonMessages.isSearchMessagesEnabled(); const promises: Promise[] = []; diff --git a/src/addons/messages/services/handlers/mainmenu.ts b/src/addons/messages/services/handlers/mainmenu.ts index 45349eef3..7b19afaa5 100644 --- a/src/addons/messages/services/handlers/mainmenu.ts +++ b/src/addons/messages/services/handlers/mainmenu.ts @@ -45,7 +45,7 @@ export class AddonMessagesMainMenuHandlerService implements CoreMainMenuHandler, title: 'addon.messages.messages', page: AddonMessagesMainMenuHandlerService.PAGE_NAME, class: 'addon-messages-handler', - showBadge: true, // Do not check isMessageCountEnabled because we'll use fallback it not enabled. + showBadge: true, badge: '', badgeA11yText: 'addon.messages.unreadconversations', loading: true, @@ -199,8 +199,7 @@ export class AddonMessagesMainMenuHandlerService implements CoreMainMenuHandler, * @return True if is a sync process, false otherwise. */ isSync(): boolean { - // This is done to use only wifi if using the fallback function. - return !AddonMessages.isMessageCountEnabled() && !AddonMessages.isGroupMessagingEnabled(); + return false; } /** diff --git a/src/addons/messages/services/handlers/settings.ts b/src/addons/messages/services/handlers/settings.ts index 40f29b1e2..9f5662d61 100644 --- a/src/addons/messages/services/handlers/settings.ts +++ b/src/addons/messages/services/handlers/settings.ts @@ -34,9 +34,7 @@ export class AddonMessagesSettingsHandlerService implements CoreSettingsHandler * @return Whether or not the handler is enabled on a site level. */ async isEnabled(): Promise { - const messagingEnabled = await AddonMessages.isPluginEnabled(); - - return messagingEnabled && AddonMessages.isMessagePreferencesEnabled(); + return await AddonMessages.isPluginEnabled(); } /** diff --git a/src/addons/messages/services/messages.ts b/src/addons/messages/services/messages.ts index dd2ae0076..1498691b6 100644 --- a/src/addons/messages/services/messages.ts +++ b/src/addons/messages/services/messages.ts @@ -1567,9 +1567,8 @@ export class AddonMessagesProvider { self: result.types[AddonMessagesProvider.MESSAGE_CONVERSATION_TYPE_SELF] || 0, }; - } else if (this.isMessageCountEnabled()) { - // @since 3.2 - const params: { useridto: number } = { + } else { + const params: AddonMessageGetUnreadConversationsCountWSParams = { useridto: site.getUserId(), }; const preSets: CoreSiteWSPreSets = { @@ -1577,37 +1576,11 @@ export class AddonMessagesProvider { typeExpected: 'number', }; - const count: number = await site.read('core_message_get_unread_conversations_count', params, preSets); + const count = await site.read('core_message_get_unread_conversations_count', params, preSets); counts = { favourites: 0, individual: count, group: 0, self: 0 }; - } else { - // Fallback call. - const params: AddonMessagesGetMessagesWSParams = { - read: false, - limitfrom: 0, - limitnum: AddonMessagesProvider.LIMIT_MESSAGES + 1, - useridto: site.getUserId(), - useridfrom: 0, - }; - - const response = await this.getMessages(params, {}, siteId); - - // Count the discussions by filtering same senders. - const discussions = {}; - response.messages.forEach((message) => { - discussions[message.useridto] = 1; - }); - - const count = Object.keys(discussions).length; - - counts = { - favourites: 0, - individual: count, - group: 0, - self: 0, - orMore: count > AddonMessagesProvider.LIMIT_MESSAGES, - }; } + // Notify the new counts so all views are updated. CoreEvents.trigger(AddonMessagesProvider.UNREAD_CONVERSATION_COUNTS_EVENT, counts, site.id); @@ -1936,8 +1909,7 @@ export class AddonMessagesProvider { // @since 3.6 return site.invalidateWsCacheForKey(this.getCacheKeyForUnreadConversationCounts()); - } else if (this.isMessageCountEnabled()) { - // @since 3.2 + } else { return site.invalidateWsCacheForKey(this.getCacheKeyForMessageCount(site.getUserId())); } } @@ -2016,37 +1988,6 @@ export class AddonMessagesProvider { } } - /** - * Returns whether or not we can mark all messages as read. - * - * @return If related WS is available on current site. - * @since 3.2 - */ - isMarkAllMessagesReadEnabled(): boolean { - return CoreSites.wsAvailableInCurrentSite('core_message_mark_all_conversation_messages_as_read') || - CoreSites.wsAvailableInCurrentSite('core_message_mark_all_messages_as_read'); - } - - /** - * Returns whether or not we can count unread messages. - * - * @return True if enabled, false otherwise. - * @since 3.2 - */ - isMessageCountEnabled(): boolean { - return CoreSites.wsAvailableInCurrentSite('core_message_get_unread_conversations_count'); - } - - /** - * Returns whether or not the message preferences are enabled for the current site. - * - * @return True if enabled, false otherwise. - * @since 3.2 - */ - isMessagePreferencesEnabled(): boolean { - return CoreSites.wsAvailableInCurrentSite('core_message_get_user_message_preferences'); - } - /** * Returns whether or not messaging is enabled for a certain site. * @@ -2105,15 +2046,6 @@ export class AddonMessagesProvider { return site.canUseAdvancedFeature('messaging'); } - /** - * Returns whether or not we can search messages. - * - * @since 3.2 - */ - isSearchMessagesEnabled(): boolean { - return CoreSites.wsAvailableInCurrentSite('core_message_data_for_messagearea_search_messages'); - } - /** * Returns whether or not self conversation is supported in a certain site. * @@ -3691,6 +3623,13 @@ type AddonMessagesSetFavouriteConversationsWSParams = { conversations: number[]; }; +/** + * Params of core_message_get_unread_conversations_count WS. + */ +type AddonMessageGetUnreadConversationsCountWSParams = { + useridto: number; // The user id who received the message, 0 for any user. +}; + /** * Data sent by UNREAD_CONVERSATION_COUNTS_EVENT event. */ diff --git a/src/addons/mod/assign/components/index/addon-mod-assign-index.html b/src/addons/mod/assign/components/index/addon-mod-assign-index.html index ff8b08066..304f53c41 100644 --- a/src/addons/mod/assign/components/index/addon-mod-assign-index.html +++ b/src/addons/mod/assign/components/index/addon-mod-assign-index.html @@ -96,7 +96,7 @@

{{ 'addon.mod_assign.numberofteams' | translate }}

{{ 'addon.mod_assign.numberofparticipants' | translate }}

- + {{ 'addon.mod_assign.numberofparticipantscountdescription' | translate:{count: summary.participantcount} }} @@ -109,12 +109,12 @@

{{ 'addon.mod_assign.numberofdraftsubmissions' | translate }}

- + {{ 'addon.mod_assign.numberofdraftsubmissionscountdescription' | translate: @@ -125,12 +125,12 @@

{{ 'addon.mod_assign.numberofsubmittedassignments' | translate }}

- + {{ 'addon.mod_assign.numberofsubmittedassignmentscountdescription' | translate: @@ -140,7 +140,7 @@
- 0 && - this.currentSite!.isVersionGreaterEqualThan('3.2'); + this.needsGradingAvailable = (submissionStatus.gradingsummary?.submissionsneedgradingcount || 0) > 0; } /** @@ -308,7 +303,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo * @param hasSubmissions If the status has any submission. */ goToSubmissionList(status?: string, hasSubmissions = false): void { - if (typeof status != 'undefined' && !hasSubmissions && this.showNumbers) { + if (typeof status != 'undefined' && !hasSubmissions) { return; } diff --git a/src/addons/mod/assign/components/submission/submission.ts b/src/addons/mod/assign/components/submission/submission.ts index a59db45c3..4256c120a 100644 --- a/src/addons/mod/assign/components/submission/submission.ts +++ b/src/addons/mod/assign/components/submission/submission.ts @@ -649,7 +649,6 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can this.gradeInfo = await CoreCourse.getModuleBasicGradeInfo(this.moduleId); if (!this.gradeInfo) { - // It won't get gradeinfo on 3.1. return; } @@ -966,7 +965,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can } // Treat outcomes. - if (this.gradeInfo.outcomes && AddonModAssign.isOutcomesEditEnabled()) { + if (this.gradeInfo.outcomes) { this.gradeInfo.outcomes.forEach((outcome) => { if (outcome.scale) { outcome.options = @@ -981,8 +980,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can } // Get grade items. - const grades = - await CoreGradesHelper.getGradeModuleItems(this.courseId, this.moduleId, this.submitId); + const grades = await CoreGradesHelper.getGradeModuleItems(this.courseId, this.moduleId, this.submitId); const outcomes: AddonModAssignGradeOutcome[] = []; @@ -1091,16 +1089,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can submissionStatus.lastattempt.submissiongroupmemberswhoneedtosubmit ) { submissionStatus.lastattempt.submissiongroupmemberswhoneedtosubmit.forEach((member) => { - if (this.blindMarking) { - // Users not blinded! (Moodle < 3.1.1, 3.2). - promises.push(AddonModAssign.getAssignmentUserMappings(this.assign!.id, member, { - cmId: this.moduleId, - }).then((blindId) => { - this.membersToSubmitBlind.push(blindId); - - return; - })); - } else { + if (!this.blindMarking) { promises.push(CoreUser.getProfile(member, this.courseId).then((profile) => { this.membersToSubmit.push(profile); diff --git a/src/addons/mod/assign/pages/submission-list/submission-list.html b/src/addons/mod/assign/pages/submission-list/submission-list.html index 9f2ef968f..6485d2520 100644 --- a/src/addons/mod/assign/pages/submission-list/submission-list.html +++ b/src/addons/mod/assign/pages/submission-list/submission-list.html @@ -72,13 +72,6 @@ - - - - - {{ 'addon.mod_assign.notallparticipantsareshown' | translate }} - - diff --git a/src/addons/mod/assign/pages/submission-list/submission-list.page.ts b/src/addons/mod/assign/pages/submission-list/submission-list.page.ts index 911bbbba0..86443ad08 100644 --- a/src/addons/mod/assign/pages/submission-list/submission-list.page.ts +++ b/src/addons/mod/assign/pages/submission-list/submission-list.page.ts @@ -55,7 +55,6 @@ export class AddonModAssignSubmissionListPage implements AfterViewInit, OnDestro assign?: AddonModAssignAssign; // Assignment. submissions: AddonModAssignSubmissionListManager; // List of submissions loaded = false; // Whether data has been loaded. - haveAllParticipants = true; // Whether all participants have been loaded. groupId = 0; // Group ID to show. courseId!: number; // Course ID the assignment belongs to. moduleId!: number; // Module ID the submission belongs to. @@ -202,16 +201,6 @@ export class AddonModAssignSubmissionListPage implements AfterViewInit, OnDestro async setGroup(groupId: number): Promise { this.groupId = groupId; - this.haveAllParticipants = true; - - if (!CoreSites.getCurrentSite()?.wsAvailable('mod_assign_list_participants')) { - // Submissions are not displayed in Moodle 3.1 without the local plugin, see MOBILE-2968. - this.haveAllParticipants = false; - this.submissions.resetItems(); - - return; - } - // Fetch submissions and grades. const submissions = await AddonModAssignHelper.getSubmissionsUserData( diff --git a/src/addons/mod/assign/services/assign-helper.ts b/src/addons/mod/assign/services/assign-helper.ts index 196d7607f..739c93d47 100644 --- a/src/addons/mod/assign/services/assign-helper.ts +++ b/src/addons/mod/assign/services/assign-helper.ts @@ -398,13 +398,9 @@ export class AddonModAssignHelperProvider { groupId?: number, options: CoreSitesCommonWSOptions = {}, ): Promise { - // Create new options including all existing ones. - const modOptions: CoreCourseCommonModWSOptions = { cmId: assign.cmid, ...options }; - const parts = await this.getParticipants(assign, groupId, options); const blind = assign.blindmarking && !assign.revealidentities; - const promises: Promise[] = []; const result: AddonModAssignSubmissionFormatted[] = []; const participants: {[id: number]: AddonModAssignParticipant} = CoreUtils.arrayToObject(parts, 'id'); @@ -434,31 +430,12 @@ export class AddonModAssignHelperProvider { submission.groupname = participant.groupname; } - let promise = Promise.resolve(); - if (submission.userid && submission.userid > 0 && blind) { - // Blind but not blinded! (Moodle < 3.1.1, 3.2). - delete submission.userid; - - promise = AddonModAssign.getAssignmentUserMappings(assign.id, submission.submitid, modOptions) - .then((blindId) => { - submission.blindid = blindId; - - return; - }); + // Add to the list. + if (submission.userfullname || submission.blindid) { + result.push(submission); } - - promises.push(promise.then(() => { - // Add to the list. - if (submission.userfullname || submission.blindid) { - result.push(submission); - } - - return; - })); }); - await Promise.all(promises); - // Create a submission for each participant left in the list (the participants already treated were removed). CoreUtils.objectToArray(participants).forEach((participant: AddonModAssignParticipant) => { const submission = this.createEmptySubmission(); diff --git a/src/addons/mod/assign/services/assign-sync.ts b/src/addons/mod/assign/services/assign-sync.ts index 162165dee..e47429236 100644 --- a/src/addons/mod/assign/services/assign-sync.ts +++ b/src/addons/mod/assign/services/assign-sync.ts @@ -37,7 +37,7 @@ import { CoreCourseLogHelper } from '@features/course/services/log-helper'; import { CoreUtils } from '@services/utils/utils'; import { CoreApp } from '@services/app'; import { CoreNetworkError } from '@classes/errors/network-error'; -import { CoreGradesFormattedItem, CoreGradesFormattedRow, CoreGradesHelper } from '@features/grades/services/grades-helper'; +import { CoreGradesFormattedItem, CoreGradesHelper } from '@features/grades/services/grades-helper'; import { AddonModAssignSubmissionDelegate } from './submission-delegate'; import { AddonModAssignFeedbackDelegate } from './feedback-delegate'; @@ -457,21 +457,20 @@ export class AddonModAssignSyncProvider extends CoreCourseActivitySyncBaseProvid } // If grade has been modified from gradebook, do not use offline. - const grades: CoreGradesFormattedItem[] | CoreGradesFormattedRow[] = - await CoreGradesHelper.getGradeModuleItems(courseId, assign.cmid, userId, undefined, siteId, true); + const grades = await CoreGradesHelper.getGradeModuleItems(courseId, assign.cmid, userId, undefined, siteId, true); const gradeInfo = await CoreCourse.getModuleBasicGradeInfo(assign.cmid, siteId); // Override offline grade and outcomes based on the gradebook data. - grades.forEach((grade: CoreGradesFormattedItem | CoreGradesFormattedRow) => { - if ('gradedategraded' in grade && (grade.gradedategraded || 0) >= offlineData.timemodified) { + grades.forEach((grade: CoreGradesFormattedItem) => { + if ((grade.gradedategraded || 0) >= offlineData.timemodified) { if (!grade.outcomeid && !grade.scaleid) { if (gradeInfo && gradeInfo.scale) { offlineData.grade = this.getSelectedScaleId(gradeInfo.scale, grade.grade || ''); } else { offlineData.grade = parseFloat(grade.grade || ''); } - } else if (gradeInfo && grade.outcomeid && AddonModAssign.isOutcomesEditEnabled() && gradeInfo.outcomes) { + } else if (gradeInfo && grade.outcomeid && gradeInfo.outcomes) { gradeInfo.outcomes.forEach((outcome, index) => { if (outcome.scale && grade.itemnumber == index) { offlineData.outcomes[grade.itemnumber] = this.getSelectedScaleId( diff --git a/src/addons/mod/assign/services/assign.ts b/src/addons/mod/assign/services/assign.ts index d55024c97..b0b198c8b 100644 --- a/src/addons/mod/assign/services/assign.ts +++ b/src/addons/mod/assign/services/assign.ts @@ -90,8 +90,6 @@ export class AddonModAssignProvider { static readonly SUBMITTED_FOR_GRADING_EVENT = 'addon_mod_assign_submitted_for_grading'; static readonly GRADED_EVENT = 'addon_mod_assign_graded'; - protected gradingOfflineEnabled: {[siteId: string]: boolean} = {}; - /** * Check if the user can submit in offline. This should only be used if submissionStatus.lastattempt.cansubmit cannot * be used (offline usage). @@ -151,7 +149,7 @@ export class AddonModAssignProvider { return { isBlind: !userId ? false : !!isBlind, - groupId: site.isVersionGreaterEqualThan('3.5') ? groupId || 0 : 0, + groupId: groupId || 0, userId: userId || site.getUserId(), }; } @@ -662,10 +660,6 @@ export class AddonModAssignProvider { groupId = groupId || 0; const site = await CoreSites.getSite(options.siteId); - if (!site.wsAvailable('mod_assign_list_participants')) { - // Silently fail if is not available. (needs Moodle version >= 3.2) - throw new CoreError('mod_assign_list_participants WS is only available 3.2 onwards'); - } const params: AddonModAssignListParticipantsWSParams = { assignid: assignId, @@ -836,47 +830,6 @@ export class AddonModAssignProvider { await site.invalidateWsCacheForKeyStartingWith(this.listParticipantsPrefixCacheKey(assignId)); } - /** - * Convenience function to check if grading offline is enabled. - * - * @param siteId Site ID. If not defined, current site. - * @return Promise resolved with boolean: whether grading offline is enabled. - */ - protected async isGradingOfflineEnabled(siteId?: string): Promise { - siteId = siteId || CoreSites.getCurrentSiteId(); - - if (typeof this.gradingOfflineEnabled[siteId] != 'undefined') { - return this.gradingOfflineEnabled[siteId]; - } - - this.gradingOfflineEnabled[siteId] = await CoreGrades.isGradeItemsAvailable(siteId); - - return this.gradingOfflineEnabled[siteId]; - } - - /** - * Outcomes only can be edited if mod_assign_submit_grading_form is available. - * - * @param siteId Site ID. If not defined, current site. - * @return Promise resolved with true if outcomes edit is enabled, rejected or resolved with false otherwise. - * @since 3.2 - */ - async isOutcomesEditEnabled(siteId?: string): Promise { - const site = await CoreSites.getSite(siteId); - - return site.wsAvailable('mod_assign_submit_grading_form'); - } - - /** - * Check if assignments plugin is enabled in a certain site. - * - * @param siteId Site ID. If not defined, current site. - * @return Whether the plugin is enabled. - */ - isPluginEnabled(): boolean { - return true; - } - /** * Check if a submission is open. This function is based on Moodle's submissions_open. * @@ -1261,25 +1214,6 @@ export class AddonModAssignProvider { return false; }; - // Grading offline is only allowed if WS of grade items is enabled to avoid inconsistency. - const enabled = await this.isGradingOfflineEnabled(siteId); - if (!enabled) { - await this.submitGradingFormOnline( - assignId, - userId, - grade, - attemptNumber, - addAttempt, - workflowState, - applyToAll, - outcomes, - pluginData, - siteId, - ); - - return true; - } - if (!CoreApp.isOnline()) { // App is offline, store the action. return storeOffline(); @@ -1345,58 +1279,35 @@ export class AddonModAssignProvider { const site = await CoreSites.getSite(siteId); userId = userId || site.getUserId(); - if (site.wsAvailable('mod_assign_submit_grading_form')) { - // WS available @since 3.2. + const jsonData = { + grade, + attemptnumber: attemptNumber, + addattempt: addAttempt ? 1 : 0, + workflowstate: workflowState, + applytoall: applyToAll ? 1 : 0, + }; - const jsonData = { - grade, - attemptnumber: attemptNumber, - addattempt: addAttempt ? 1 : 0, - workflowstate: workflowState, - applytoall: applyToAll ? 1 : 0, - }; - - for (const index in outcomes) { - jsonData['outcome_' + index + '[' + userId + ']'] = outcomes[index]; - } - - for (const index in pluginData) { - jsonData[index] = pluginData[index]; - } - - const serialized = CoreInterceptor.serialize(jsonData, true); - const params: AddonModAssignSubmitGradingFormWSParams = { - assignmentid: assignId, - userid: userId, - jsonformdata: JSON.stringify(serialized), - }; - - const warnings = await site.write('mod_assign_submit_grading_form', params); - - if (warnings.length) { - // The WebService returned warnings, reject. - throw new CoreWSError(warnings[0]); - } - - return; + for (const index in outcomes) { + jsonData['outcome_' + index + '[' + userId + ']'] = outcomes[index]; } - // WS not available, fallback to save_grade. - const params: AddonModAssignSaveGradeWSParams = { + for (const index in pluginData) { + jsonData[index] = pluginData[index]; + } + + const serialized = CoreInterceptor.serialize(jsonData, true); + const params: AddonModAssignSubmitGradingFormWSParams = { assignmentid: assignId, userid: userId, - grade: grade, - attemptnumber: attemptNumber, - addattempt: addAttempt, - workflowstate: workflowState, - applytoall: applyToAll, - plugindata: pluginData, - }; - const preSets: CoreSiteWSPreSets = { - responseExpected: false, + jsonformdata: JSON.stringify(serialized), }; - await site.write('mod_assign_save_grade', params, preSets); + const warnings = await site.write('mod_assign_submit_grading_form', params); + + if (warnings.length) { + // The WebService returned warnings, reject. + throw new CoreWSError(warnings[0]); + } } } @@ -1431,7 +1342,7 @@ export type AddonModAssignAssign = { timemodified: number; // Last time assignment was modified. completionsubmit: number; // If enabled, set activity as complete following submission. cutoffdate: number; // Date after which submission is not accepted without an extension. - gradingduedate?: number; // @since 3.3. The expected date for marking the submissions. + gradingduedate?: number; // The expected date for marking the submissions. teamsubmission: number; // If enabled, students submit as a team. requireallteammemberssubmit: number; // If enabled, all team members must submit. teamsubmissiongroupingid: number; // The grouping id for the team submission groups. @@ -1443,13 +1354,13 @@ export type AddonModAssignAssign = { markingworkflow: number; // Enable marking workflow. markingallocation: number; // Enable marking allocation. requiresubmissionstatement: number; // Student must accept submission statement. - preventsubmissionnotingroup?: number; // @since 3.2. Prevent submission not in group. - submissionstatement?: string; // @since 3.2. Submission statement formatted. - submissionstatementformat?: number; // @since 3.2. Submissionstatement format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN). + preventsubmissionnotingroup?: number; // Prevent submission not in group. + submissionstatement?: string; // Submission statement formatted. + submissionstatementformat?: number; // Submissionstatement format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN). configs: AddonModAssignConfig[]; // Configuration settings. intro?: string; // Assignment intro, not allways returned because it deppends on the activity configuration. introformat?: number; // Intro format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN). - introfiles?: CoreWSExternalFile[]; // @since 3.2. + introfiles?: CoreWSExternalFile[]; introattachments?: CoreWSExternalFile[]; }; @@ -1494,7 +1405,7 @@ export type AddonModAssignSubmission = { assignment?: number; // Assignment id. latest?: number; // Latest attempt. plugins?: AddonModAssignPlugin[]; // Plugins. - gradingstatus?: string; // @since 3.2. Grading status. + gradingstatus?: string; // Grading status. }; /** @@ -1539,7 +1450,7 @@ export type AddonModAssignSubmissionAttempt = { locked: boolean; // Whether new submissions are locked. graded: boolean; // Whether the submission is graded. canedit: boolean; // Whether the user can edit the current submission. - caneditowner?: boolean; // @since 3.2. Whether the owner of the submission can edit it. + caneditowner?: boolean; // Whether the owner of the submission can edit it. cansubmit: boolean; // Whether the user can submit. extensionduedate: number; // Extension due date. blindmarking: boolean; // Whether blind marking is enabled. @@ -1610,7 +1521,7 @@ export type AddonModAssignParticipant = { interests?: string; // User interests (separated by commas). firstaccess?: number; // First access to the site (0 if never). lastaccess?: number; // Last access to the site (0 if never). - suspended?: boolean; // @since 3.2. Suspend user account, either false to enable user login or true to disable it. + suspended?: boolean; // Suspend user account, either false to enable user login or true to disable it. description?: string; // User profile description. descriptionformat?: number; // Int format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN). city?: string; // Home city of the user. @@ -1647,7 +1558,7 @@ export type AddonModAssignParticipant = { }[]; submitted: boolean; // Have they submitted their assignment. requiregrading: boolean; // Is their submission waiting for grading. - grantedextension?: boolean; // @since 3.3. Have they been granted an extension. + grantedextension?: boolean; // Have they been granted an extension. groupid?: number; // For group assignments this is the group id. groupname?: string; // For group assignments this is the group name. }; @@ -1815,45 +1726,6 @@ type AddonModAssignSubmitGradingFormWSParams = { jsonformdata: string; // The data from the grading form, encoded as a json array. }; -/** - * Params of mod_assign_save_grade WS. - */ -type AddonModAssignSaveGradeWSParams = { - assignmentid: number; // The assignment id to operate on. - userid: number; // The student id to operate on. - grade: number; // The new grade for this user. Ignored if advanced grading used. - attemptnumber: number; // The attempt number (-1 means latest attempt). - addattempt: boolean; // Allow another attempt if the attempt reopen method is manual. - workflowstate: string; // The next marking workflow state. - applytoall: boolean; // If true, this grade will be applied to all members of the group (for group assignments). - plugindata?: AddonModAssignSavePluginData; // Plugin data. - advancedgradingdata?: { - guide?: { - criteria: { - criterionid: number; // Criterion id. - fillings?: { // Filling. - criterionid: number; // Criterion id. - levelid?: number; // Level id. - remark?: string; // Remark. - remarkformat?: number; // Remark format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN). - score: number; // Maximum score. - }[]; - }[]; - }; // Items. - rubric?: { - criteria: { - criterionid: number; // Criterion id. - fillings?: { // Filling. - criterionid: number; // Criterion id. - levelid?: number; // Level id. - remark?: string; // Remark. - remarkformat?: number; // Remark format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN). - }[]; - }[]; - }; // Items. - }; // Advanced grading data. -}; - /** * Assignment grade outcomes. */ diff --git a/src/addons/mod/assign/services/handlers/module.ts b/src/addons/mod/assign/services/handlers/module.ts index 8ef54dc73..781ef2900 100644 --- a/src/addons/mod/assign/services/handlers/module.ts +++ b/src/addons/mod/assign/services/handlers/module.ts @@ -20,7 +20,6 @@ import { makeSingleton } from '@singletons'; import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course'; import { CoreCourseModule } from '@features/course/services/course-helper'; import { CoreNavigationOptions, CoreNavigator } from '@services/navigator'; -import { AddonModAssign } from '../assign'; /** * Handler to support assign modules. @@ -54,7 +53,7 @@ export class AddonModAssignModuleHandlerService implements CoreCourseModuleHandl * @return Whether or not the handler is enabled on a site level. */ async isEnabled(): Promise { - return AddonModAssign.isPluginEnabled(); + return true; } /** diff --git a/src/addons/mod/assign/services/handlers/prefetch.ts b/src/addons/mod/assign/services/handlers/prefetch.ts index 8d84587d0..1f7d6e533 100644 --- a/src/addons/mod/assign/services/handlers/prefetch.ts +++ b/src/addons/mod/assign/services/handlers/prefetch.ts @@ -202,15 +202,6 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref return CoreCourse.invalidateModule(module.id); } - /** - * Whether or not the handler is enabled on a site level. - * - * @return A boolean, or a promise resolved with a boolean, indicating if the handler is enabled. - */ - async isEnabled(): Promise { - return AddonModAssign.isPluginEnabled(); - } - /** * @inheritdoc */ @@ -391,10 +382,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref // Participiants already fetched, we don't need to ignore cache now. const participants = await AddonModAssignHelper.getParticipants(assign, group.id, { siteId }); - // Fail silently (Moodle < 3.2). - await CoreUtils.ignoreErrors( - CoreUser.prefetchUserAvatars(participants, 'profileimageurl', siteId), - ); + await CoreUser.prefetchUserAvatars(participants, 'profileimageurl', siteId); return; })); diff --git a/src/addons/mod/assign/submission/comments/services/handler.ts b/src/addons/mod/assign/submission/comments/services/handler.ts index 54ea486f3..a14f9c7a3 100644 --- a/src/addons/mod/assign/submission/comments/services/handler.ts +++ b/src/addons/mod/assign/submission/comments/services/handler.ts @@ -16,7 +16,6 @@ import { AddonModAssignAssign, AddonModAssignSubmission, AddonModAssignPlugin } import { AddonModAssignSubmissionHandler } from '@addons/mod/assign/services/submission-delegate'; import { Injectable, Type } from '@angular/core'; import { CoreComments } from '@features/comments/services/comments'; -import { CoreUtils } from '@services/utils/utils'; import { makeSingleton } from '@singletons'; import { AddonModAssignSubmissionCommentsComponent } from '../component/comments'; @@ -87,18 +86,14 @@ export class AddonModAssignSubmissionCommentsHandlerService implements AddonModA plugin: AddonModAssignPlugin, siteId?: string, ): Promise { - - // Fail silently (Moodle < 3.1.1, 3.2) - await CoreUtils.ignoreErrors( - CoreComments.getComments( - 'module', - assign.cmid, - 'assignsubmission_comments', - submission.id, - 'submission_comments', - 0, - siteId, - ), + await CoreComments.getComments( + 'module', + assign.cmid, + 'assignsubmission_comments', + submission.id, + 'submission_comments', + 0, + siteId, ); } diff --git a/src/addons/mod/assign/submission/onlinetext/services/handler.ts b/src/addons/mod/assign/submission/onlinetext/services/handler.ts index 56f86d63a..90c65eaaa 100644 --- a/src/addons/mod/assign/submission/onlinetext/services/handler.ts +++ b/src/addons/mod/assign/submission/onlinetext/services/handler.ts @@ -24,7 +24,6 @@ import { AddonModAssignSubmissionHandler } from '@addons/mod/assign/services/sub import { Injectable, Type } from '@angular/core'; import { CoreError } from '@classes/errors/error'; import { CoreFileHelper } from '@services/file-helper'; -import { CoreSites } from '@services/sites'; import { CoreTextUtils } from '@services/utils/text'; import { CoreUtils } from '@services/utils/utils'; import { CoreWSFile } from '@services/ws'; @@ -224,11 +223,7 @@ export class AddonModAssignSubmissionOnlineTextHandlerService implements AddonMo * @return Whether or not the handler is enabled for edit on a site level. */ isEnabledForEdit(): boolean { - // There's a bug in Moodle 3.1.0 that doesn't allow submitting HTML, so we'll disable this plugin in that case. - // Bug was fixed in 3.1.1 minor release and in 3.2. - const currentSite = CoreSites.getCurrentSite(); - - return !!currentSite?.isVersionGreaterEqualThan('3.1.1') || !!currentSite?.checkIfAppUsesLocalMobile(); + return true; } /** diff --git a/src/addons/mod/book/services/book.ts b/src/addons/mod/book/services/book.ts index cfdfdf680..7abf1dead 100644 --- a/src/addons/mod/book/services/book.ts +++ b/src/addons/mod/book/services/book.ts @@ -441,7 +441,7 @@ export type AddonModBookBookWSData = { name: string; // Book name. intro: string; // The Book intro. introformat: number; // Intro format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN). - introfiles?: CoreWSExternalFile[]; // @since 3.2. + introfiles?: CoreWSExternalFile[]; numbering: number; // Book numbering configuration. navstyle: number; // Book navigation style configuration. customtitles: number; // Book custom titles type. diff --git a/src/addons/mod/chat/components/index/addon-mod-chat-index.html b/src/addons/mod/chat/components/index/addon-mod-chat-index.html index 2efee98b1..6e9094a0e 100644 --- a/src/addons/mod/chat/components/index/addon-mod-chat-index.html +++ b/src/addons/mod/chat/components/index/addon-mod-chat-index.html @@ -46,7 +46,7 @@ {{ 'addon.mod_chat.enterchat' | translate }} - + {{ 'addon.mod_chat.viewreport' | translate }} diff --git a/src/addons/mod/chat/components/index/index.ts b/src/addons/mod/chat/components/index/index.ts index 65b73d838..fe6a7dd65 100644 --- a/src/addons/mod/chat/components/index/index.ts +++ b/src/addons/mod/chat/components/index/index.ts @@ -34,7 +34,6 @@ export class AddonModChatIndexComponent extends CoreCourseModuleMainActivityComp component = AddonModChatProvider.COMPONENT; moduleName = 'chat'; chat?: AddonModChatChat; - sessionsAvailable = false; chatInfo?: { date: string; fromnow: string; @@ -89,8 +88,6 @@ export class AddonModChatIndexComponent extends CoreCourseModuleMainActivityComp } this.dataRetrieved.emit(this.chat); - - this.sessionsAvailable = await AddonModChat.areSessionsAvailable(); } finally { this.fillContextMenu(refresh); } diff --git a/src/addons/mod/chat/services/chat.ts b/src/addons/mod/chat/services/chat.ts index 12af031ca..9908aff4f 100644 --- a/src/addons/mod/chat/services/chat.ts +++ b/src/addons/mod/chat/services/chat.ts @@ -217,19 +217,6 @@ export class AddonModChatProvider { return site.read('mod_chat_get_chat_users', params, preSets); } - /** - * Return whether WS for passed sessions are available. - * - * @param siteId Site ID. If not defined, current site. - * @return Promise resolved with a boolean. - * @since 3.5 - */ - async areSessionsAvailable(siteId?: string): Promise { - const site = await CoreSites.getSite(siteId); - - return site.wsAvailable('mod_chat_get_sessions') && site.wsAvailable('mod_chat_get_session_messages'); - } - /** * Get chat sessions. * @@ -238,7 +225,6 @@ export class AddonModChatProvider { * @param showAll Whether to include incomplete sessions or not. * @param options Other options. * @return Promise resolved with the list of sessions. - * @since 3.5 */ async getSessions( chatId: number, @@ -275,7 +261,6 @@ export class AddonModChatProvider { * @param groupId Group ID, 0 means that the function will determine the user group. * @param options Other options. * @return Promise resolved with the list of messages. - * @since 3.5 */ async getSessionMessages( chatId: number, @@ -461,7 +446,7 @@ export type AddonModChatChat = { name: string; // Chat name. intro: string; // The Chat intro. introformat: number; // Intro format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN). - introfiles?: CoreWSExternalFile[]; // @since 3.2. + introfiles?: CoreWSExternalFile[]; chatmethod?: string; // Chat method (sockets, ajax, header_js). keepdays?: number; // Keep days. studentlogs?: number; // Student logs visible to everyone. diff --git a/src/addons/mod/chat/services/handlers/module.ts b/src/addons/mod/chat/services/handlers/module.ts index a3e15e097..451bda34d 100644 --- a/src/addons/mod/chat/services/handlers/module.ts +++ b/src/addons/mod/chat/services/handlers/module.ts @@ -20,7 +20,6 @@ import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/ import { CoreNavigationOptions, CoreNavigator } from '@services/navigator'; import { makeSingleton } from '@singletons'; import { AddonModChatIndexComponent } from '../../components/index'; -import { AddonModChat } from '../chat'; /** * Handler to support chat modules. @@ -59,6 +58,7 @@ export class AddonModChatModuleHandlerService implements CoreCourseModuleHandler icon: CoreCourse.getModuleIconSrc(this.modName, 'modicon' in module ? module.modicon : undefined), title: module.name, class: 'addon-mod_chat-handler', + showDownloadButton: true, action(event: Event, module: CoreCourseModule, courseId: number, options?: CoreNavigationOptions): void { options = options || {}; options.params = options.params || {}; @@ -69,20 +69,9 @@ export class AddonModChatModuleHandlerService implements CoreCourseModuleHandler }, }; - this.checkDownloadButton(data); - return data; } - /** - * Check whether download button should be displayed. - * - * @param data Handler data. - */ - protected async checkDownloadButton(data: CoreCourseModuleHandlerData): Promise { - data.showDownloadButton = await AddonModChat.areSessionsAvailable(); - } - /** * @inheritdoc */ diff --git a/src/addons/mod/chat/services/handlers/prefetch.ts b/src/addons/mod/chat/services/handlers/prefetch.ts index 335d3a1b5..3a56a30e0 100644 --- a/src/addons/mod/chat/services/handlers/prefetch.ts +++ b/src/addons/mod/chat/services/handlers/prefetch.ts @@ -32,13 +32,6 @@ export class AddonModChatPrefetchHandlerService extends CoreCourseActivityPrefet modName = 'chat'; component = AddonModChatProvider.COMPONENT; - /** - * @inheritdoc - */ - async isEnabled(): Promise { - return AddonModChat.areSessionsAvailable(); - } - /** * @inheritdoc */ diff --git a/src/addons/mod/choice/services/choice.ts b/src/addons/mod/choice/services/choice.ts index af256c9ee..8074f2459 100644 --- a/src/addons/mod/choice/services/choice.ts +++ b/src/addons/mod/choice/services/choice.ts @@ -484,7 +484,7 @@ export type AddonModChoiceChoice = { name: string; // Choice name. intro: string; // The choice intro. introformat: number; // Intro format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN). - introfiles?: CoreWSExternalFile[]; // @since 3.2. + introfiles?: CoreWSExternalFile[]; publish?: boolean; // If choice is published. showresults?: number; // 0 never, 1 after answer, 2 after close, 3 always. display?: number; // Display mode (vertical, horizontal). diff --git a/src/addons/mod/data/services/data.ts b/src/addons/mod/data/services/data.ts index 5d40d3cd8..4dd6ce8e8 100644 --- a/src/addons/mod/data/services/data.ts +++ b/src/addons/mod/data/services/data.ts @@ -950,19 +950,6 @@ export class AddonModDataProvider { await site.invalidateWsCacheForKey(this.getEntryCacheKey(dataId, entryId)); } - /** - * Return whether or not the plugin is enabled in a certain site. Plugin is enabled if the database WS are available. - * - * @param siteId Site ID. If not defined, current site. - * @return Promise resolved with true if plugin is enabled, rejected or resolved with false otherwise. - * @since 3.3 - */ - async isPluginEnabled(siteId?: string): Promise { - const site = await CoreSites.getSite(siteId); - - return site.wsAvailable('mod_data_get_data_access_information'); - } - /** * Report the database as being viewed. * diff --git a/src/addons/mod/data/services/handlers/approve-link.ts b/src/addons/mod/data/services/handlers/approve-link.ts index 7dfdc3173..5d3072634 100644 --- a/src/addons/mod/data/services/handlers/approve-link.ts +++ b/src/addons/mod/data/services/handlers/approve-link.ts @@ -17,7 +17,6 @@ import { Params } from '@angular/router'; import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { makeSingleton } from '@singletons'; -import { AddonModData } from '../data'; import { AddonModDataHelper } from '../data-helper'; /** @@ -56,7 +55,7 @@ export class AddonModDataApproveLinkHandlerService extends CoreContentLinksHandl return false; } - return AddonModData.isPluginEnabled(siteId); + return true; } } diff --git a/src/addons/mod/data/services/handlers/delete-link.ts b/src/addons/mod/data/services/handlers/delete-link.ts index 6fd66bc4b..e17e662b6 100644 --- a/src/addons/mod/data/services/handlers/delete-link.ts +++ b/src/addons/mod/data/services/handlers/delete-link.ts @@ -17,7 +17,6 @@ import { Params } from '@angular/router'; import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { makeSingleton } from '@singletons'; -import { AddonModData } from '../data'; import { AddonModDataHelper } from '../data-helper'; /** @@ -54,7 +53,7 @@ export class AddonModDataDeleteLinkHandlerService extends CoreContentLinksHandle return false; } - return AddonModData.isPluginEnabled(siteId); + return true; } } diff --git a/src/addons/mod/data/services/handlers/edit-link.ts b/src/addons/mod/data/services/handlers/edit-link.ts index 36acd0cfa..e759b20e2 100644 --- a/src/addons/mod/data/services/handlers/edit-link.ts +++ b/src/addons/mod/data/services/handlers/edit-link.ts @@ -20,7 +20,6 @@ import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; -import { AddonModData } from '../data'; import { AddonModDataModuleHandlerService } from './module'; /** @@ -72,7 +71,7 @@ export class AddonModDataEditLinkHandlerService extends CoreContentLinksHandlerB return false; } - return AddonModData.isPluginEnabled(siteId); + return true; } } diff --git a/src/addons/mod/data/services/handlers/index-link.ts b/src/addons/mod/data/services/handlers/index-link.ts index a831add07..30edb741d 100644 --- a/src/addons/mod/data/services/handlers/index-link.ts +++ b/src/addons/mod/data/services/handlers/index-link.ts @@ -15,7 +15,6 @@ import { Injectable } from '@angular/core'; import { CoreContentLinksModuleIndexHandler } from '@features/contentlinks/classes/module-index-handler'; import { makeSingleton } from '@singletons'; -import { AddonModData } from '../data'; /** * Handler to treat links to data. @@ -29,12 +28,5 @@ export class AddonModDataIndexLinkHandlerService extends CoreContentLinksModuleI super('AddonModData', 'data', 'd'); } - /** - * @inheritdoc - */ - isEnabled(siteId: string): Promise { - return AddonModData.isPluginEnabled(siteId); - } - } export const AddonModDataIndexLinkHandler = makeSingleton(AddonModDataIndexLinkHandlerService); diff --git a/src/addons/mod/data/services/handlers/list-link.ts b/src/addons/mod/data/services/handlers/list-link.ts index 1bbd94082..c649e5bf7 100644 --- a/src/addons/mod/data/services/handlers/list-link.ts +++ b/src/addons/mod/data/services/handlers/list-link.ts @@ -15,7 +15,6 @@ import { Injectable } from '@angular/core'; import { CoreContentLinksModuleListHandler } from '@features/contentlinks/classes/module-list-handler'; import { makeSingleton } from '@singletons'; -import { AddonModData } from '../data'; /** * Handler to treat links to data list page. @@ -29,12 +28,5 @@ export class AddonModDataListLinkHandlerService extends CoreContentLinksModuleLi super('AddonModData', 'data'); } - /** - * @inheritdoc - */ - isEnabled(siteId?: string): Promise { - return AddonModData.isPluginEnabled(siteId); - } - } export const AddonModDataListLinkHandler = makeSingleton(AddonModDataListLinkHandlerService); diff --git a/src/addons/mod/data/services/handlers/module.ts b/src/addons/mod/data/services/handlers/module.ts index c48f8bb97..1ccb3d958 100644 --- a/src/addons/mod/data/services/handlers/module.ts +++ b/src/addons/mod/data/services/handlers/module.ts @@ -20,7 +20,6 @@ import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/ import { CoreNavigationOptions, CoreNavigator } from '@services/navigator'; import { makeSingleton } from '@singletons'; import { AddonModDataIndexComponent } from '../../components/index'; -import { AddonModData } from '../data'; /** * Handler to support data modules. @@ -50,8 +49,8 @@ export class AddonModDataModuleHandlerService implements CoreCourseModuleHandler /** * @inheritdoc */ - isEnabled(): Promise { - return AddonModData.isPluginEnabled(); + async isEnabled(): Promise { + return true; } /** diff --git a/src/addons/mod/data/services/handlers/prefetch.ts b/src/addons/mod/data/services/handlers/prefetch.ts index 01446305c..4a7bf6b38 100644 --- a/src/addons/mod/data/services/handlers/prefetch.ts +++ b/src/addons/mod/data/services/handlers/prefetch.ts @@ -203,13 +203,6 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet return true; } - /** - * @inheritdoc - */ - async isEnabled(): Promise { - return AddonModData.isPluginEnabled(); - } - /** * @inheritdoc */ diff --git a/src/addons/mod/data/services/handlers/show-link.ts b/src/addons/mod/data/services/handlers/show-link.ts index 63beb6200..f1279506a 100644 --- a/src/addons/mod/data/services/handlers/show-link.ts +++ b/src/addons/mod/data/services/handlers/show-link.ts @@ -20,7 +20,6 @@ import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; -import { AddonModData } from '../data'; import { AddonModDataModuleHandlerService } from './module'; /** @@ -87,7 +86,7 @@ export class AddonModDataShowLinkHandlerService extends CoreContentLinksHandlerB return false; } - return AddonModData.isPluginEnabled(siteId); + return true; } } diff --git a/src/addons/mod/data/services/handlers/tag-area.ts b/src/addons/mod/data/services/handlers/tag-area.ts index 31341389e..f6c4033e0 100644 --- a/src/addons/mod/data/services/handlers/tag-area.ts +++ b/src/addons/mod/data/services/handlers/tag-area.ts @@ -17,7 +17,6 @@ import { CoreTagFeedComponent } from '@features/tag/components/feed/feed'; import { CoreTagAreaHandler } from '@features/tag/services/tag-area-delegate'; import { CoreTagFeedElement, CoreTagHelper } from '@features/tag/services/tag-helper'; import { makeSingleton } from '@singletons'; -import { AddonModData } from '../data'; /** * Handler to support tags. @@ -32,7 +31,7 @@ export class AddonModDataTagAreaHandlerService implements CoreTagAreaHandler { * @inheritdoc */ async isEnabled(): Promise { - return AddonModData.isPluginEnabled(); + return true; } /** diff --git a/src/addons/mod/feedback/services/feedback.ts b/src/addons/mod/feedback/services/feedback.ts index 3208cd482..c1a254df3 100644 --- a/src/addons/mod/feedback/services/feedback.ts +++ b/src/addons/mod/feedback/services/feedback.ts @@ -1089,20 +1089,6 @@ export class AddonModFeedbackProvider { return CoreUtils.promiseWorks(site.read('mod_feedback_get_last_completed', params, preSets)); } - /** - * Return whether or not the plugin is enabled in a certain site. Plugin is enabled if the feedback WS are available. - * - * @param siteId Site ID. If not defined, current site. - * @return Promise resolved with true if plugin is enabled, rejected or resolved with false otherwise. - * @since 3.3 - */ - async isPluginEnabled(siteId?: string): Promise { - const site = await CoreSites.getSite(siteId); - - return site.wsAvailable('mod_feedback_get_feedbacks_by_courses') && - site.wsAvailable('mod_feedback_get_feedback_access_information'); - } - /** * Report the feedback as being viewed. * diff --git a/src/addons/mod/feedback/services/handlers/analysis-link.ts b/src/addons/mod/feedback/services/handlers/analysis-link.ts index d3c06a61f..8081f4bee 100644 --- a/src/addons/mod/feedback/services/handlers/analysis-link.ts +++ b/src/addons/mod/feedback/services/handlers/analysis-link.ts @@ -19,7 +19,6 @@ import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; -import { AddonModFeedback } from '../feedback'; import { AddonModFeedbackModuleHandlerService } from './module'; /** @@ -84,7 +83,7 @@ export class AddonModFeedbackAnalysisLinkHandlerService extends CoreContentLinks return false; } - return AddonModFeedback.isPluginEnabled(siteId); + return true; } } diff --git a/src/addons/mod/feedback/services/handlers/complete-link.ts b/src/addons/mod/feedback/services/handlers/complete-link.ts index 94d46c83d..f0bc0ac94 100644 --- a/src/addons/mod/feedback/services/handlers/complete-link.ts +++ b/src/addons/mod/feedback/services/handlers/complete-link.ts @@ -19,7 +19,6 @@ import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; -import { AddonModFeedback } from '../feedback'; import { AddonModFeedbackModuleHandlerService } from './module'; /** @@ -72,7 +71,7 @@ export class AddonModFeedbackCompleteLinkHandlerService extends CoreContentLinks return false; } - return AddonModFeedback.isPluginEnabled(siteId); + return true; } } diff --git a/src/addons/mod/feedback/services/handlers/index-link.ts b/src/addons/mod/feedback/services/handlers/index-link.ts index 319112eb6..b6541b5ab 100644 --- a/src/addons/mod/feedback/services/handlers/index-link.ts +++ b/src/addons/mod/feedback/services/handlers/index-link.ts @@ -15,7 +15,6 @@ import { Injectable } from '@angular/core'; import { CoreContentLinksModuleIndexHandler } from '@features/contentlinks/classes/module-index-handler'; import { makeSingleton } from '@singletons'; -import { AddonModFeedback } from '../feedback'; /** * Handler to treat links to feedback. @@ -29,19 +28,6 @@ export class AddonModFeedbackIndexLinkHandlerService extends CoreContentLinksMod super('AddonModFeedback', 'feedback'); } - /** - * Check if the handler is enabled for a certain site (site + user) and a URL. - * - * @param siteId The site ID. - * @param url The URL to treat. - * @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1} - * @param courseId Course ID related to the URL. Optional but recommended. - * @return Whether the handler is enabled for the URL and site. - */ - isEnabled(): Promise { - return AddonModFeedback.isPluginEnabled(); - } - } export const AddonModFeedbackIndexLinkHandler = makeSingleton(AddonModFeedbackIndexLinkHandlerService); diff --git a/src/addons/mod/feedback/services/handlers/list-link.ts b/src/addons/mod/feedback/services/handlers/list-link.ts index 9f62a378c..761015f55 100644 --- a/src/addons/mod/feedback/services/handlers/list-link.ts +++ b/src/addons/mod/feedback/services/handlers/list-link.ts @@ -15,7 +15,6 @@ import { Injectable } from '@angular/core'; import { CoreContentLinksModuleListHandler } from '@features/contentlinks/classes/module-list-handler'; import { makeSingleton } from '@singletons'; -import { AddonModFeedback } from '../feedback'; /** * Handler to treat links to feedback list page. @@ -29,13 +28,6 @@ export class AddonModFeedbackListLinkHandlerService extends CoreContentLinksModu super('AddonModFeedback', 'feedback'); } - /** - * @inheritdoc - */ - isEnabled(): Promise { - return AddonModFeedback.isPluginEnabled(); - } - } export const AddonModFeedbackListLinkHandler = makeSingleton(AddonModFeedbackListLinkHandlerService); diff --git a/src/addons/mod/feedback/services/handlers/module.ts b/src/addons/mod/feedback/services/handlers/module.ts index fba3e5862..5b7b1342c 100644 --- a/src/addons/mod/feedback/services/handlers/module.ts +++ b/src/addons/mod/feedback/services/handlers/module.ts @@ -19,7 +19,6 @@ import { CoreCourseModule } from '@features/course/services/course-helper'; import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate'; import { CoreNavigationOptions, CoreNavigator } from '@services/navigator'; import { makeSingleton } from '@singletons'; -import { AddonModFeedback } from '../feedback'; import { AddonModFeedbackIndexComponent } from '../../components/index'; /** @@ -48,8 +47,8 @@ export class AddonModFeedbackModuleHandlerService implements CoreCourseModuleHan /** * @inheritdoc */ - isEnabled(): Promise { - return AddonModFeedback.isPluginEnabled(); + async isEnabled(): Promise { + return true; } /** diff --git a/src/addons/mod/feedback/services/handlers/prefetch.ts b/src/addons/mod/feedback/services/handlers/prefetch.ts index 88a346d88..3180321d9 100644 --- a/src/addons/mod/feedback/services/handlers/prefetch.ts +++ b/src/addons/mod/feedback/services/handlers/prefetch.ts @@ -110,13 +110,6 @@ export class AddonModFeedbackPrefetchHandlerService extends CoreCourseActivityPr return accessData.isopen; } - /** - * @inheritdoc - */ - isEnabled(): Promise { - return AddonModFeedback.isPluginEnabled(); - } - /** * @inheritdoc */ diff --git a/src/addons/mod/feedback/services/handlers/print-link.ts b/src/addons/mod/feedback/services/handlers/print-link.ts index b74bab793..1a287d5ad 100644 --- a/src/addons/mod/feedback/services/handlers/print-link.ts +++ b/src/addons/mod/feedback/services/handlers/print-link.ts @@ -19,7 +19,6 @@ import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; -import { AddonModFeedback } from '../feedback'; import { AddonModFeedbackModuleHandlerService } from './module'; /** @@ -72,7 +71,7 @@ export class AddonModFeedbackPrintLinkHandlerService extends CoreContentLinksHan return false; } - return AddonModFeedback.isPluginEnabled(siteId); + return true; } } diff --git a/src/addons/mod/feedback/services/handlers/push-click.ts b/src/addons/mod/feedback/services/handlers/push-click.ts index e5119b79a..e736768db 100644 --- a/src/addons/mod/feedback/services/handlers/push-click.ts +++ b/src/addons/mod/feedback/services/handlers/push-click.ts @@ -19,7 +19,6 @@ import { CorePushNotificationsNotificationBasicData } from '@features/pushnotifi import { CoreUrlUtils } from '@services/utils/url'; import { CoreUtils } from '@services/utils/utils'; import { makeSingleton } from '@singletons'; -import { AddonModFeedback } from '../feedback'; import { AddonModFeedbackHelper } from '../feedback-helper'; /** @@ -39,7 +38,7 @@ export class AddonModFeedbackPushClickHandlerService implements CorePushNotifica if (CoreUtils.isTrueOrOne(notification.notif) && notification.moodlecomponent == 'mod_feedback' && (notification.name == 'submission' || notification.name == 'message')) { - return AddonModFeedback.isPluginEnabled(notification.site); + return true; } return false; diff --git a/src/addons/mod/feedback/services/handlers/show-entries-link.ts b/src/addons/mod/feedback/services/handlers/show-entries-link.ts index 6f91981bc..1d1f857d4 100644 --- a/src/addons/mod/feedback/services/handlers/show-entries-link.ts +++ b/src/addons/mod/feedback/services/handlers/show-entries-link.ts @@ -16,7 +16,6 @@ import { Injectable } from '@angular/core'; import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { makeSingleton } from '@singletons'; -import { AddonModFeedback } from '../feedback'; import { AddonModFeedbackHelper } from '../feedback-helper'; /** @@ -50,7 +49,7 @@ export class AddonModFeedbackShowEntriesLinkHandlerService extends CoreContentLi return false; } - return AddonModFeedback.isPluginEnabled(siteId); + return true; } } diff --git a/src/addons/mod/feedback/services/handlers/show-non-respondents-link.ts b/src/addons/mod/feedback/services/handlers/show-non-respondents-link.ts index c133301ec..cccaadcad 100644 --- a/src/addons/mod/feedback/services/handlers/show-non-respondents-link.ts +++ b/src/addons/mod/feedback/services/handlers/show-non-respondents-link.ts @@ -19,7 +19,6 @@ import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; -import { AddonModFeedback } from '../feedback'; import { AddonModFeedbackModuleHandlerService } from './module'; /** * Content links handler for feedback show non respondents. @@ -67,7 +66,7 @@ export class AddonModFeedbackShowNonRespondentsLinkHandlerService extends CoreCo return false; } - return AddonModFeedback.isPluginEnabled(siteId); + return true; } } diff --git a/src/addons/mod/folder/components/index/index.ts b/src/addons/mod/folder/components/index/index.ts index a74ee7819..3c13d7cb4 100644 --- a/src/addons/mod/folder/components/index/index.ts +++ b/src/addons/mod/folder/components/index/index.ts @@ -18,7 +18,6 @@ import { Params } from '@angular/router'; import { CoreCourseModuleMainResourceComponent } from '@features/course/classes/main-resource-component'; import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; import { CoreCourse } from '@features/course/services/course'; -import { CoreApp } from '@services/app'; import { CoreNavigator } from '@services/navigator'; import { Md5 } from 'ts-md5'; import { AddonModFolder, AddonModFolderFolder, AddonModFolderProvider } from '../../services/folder'; @@ -41,7 +40,6 @@ export class AddonModFolderIndexComponent extends CoreCourseModuleMainResourceCo @Input() subfolder?: AddonModFolderFolderFormattedData; // Subfolder to show. component = AddonModFolderProvider.COMPONENT; - canGetFolder = false; contents?: AddonModFolderFolderFormattedData; constructor(@Optional() courseContentsPage?: CoreCourseContentsPage) { @@ -54,8 +52,6 @@ export class AddonModFolderIndexComponent extends CoreCourseModuleMainResourceCo async ngOnInit(): Promise { super.ngOnInit(); - this.canGetFolder = AddonModFolder.isGetFolderWSAvailable(); - if (this.subfolder) { this.description = this.folderInstance ? this.folderInstance.intro : this.module.description; this.contents = this.subfolder; @@ -98,18 +94,8 @@ export class AddonModFolderIndexComponent extends CoreCourseModuleMainResourceCo */ protected async fetchContent(refresh = false): Promise { try { - if (this.canGetFolder) { - this.folderInstance = await AddonModFolder.getFolder(this.courseId, this.module.id); - await CoreCourse.loadModuleContents(this.module, this.courseId, undefined, false, refresh); - } else { - const module = await CoreCourse.getModule(this.module.id, this.courseId); - - if (!module.contents.length && this.module.contents.length && !CoreApp.isOnline()) { - // The contents might be empty due to a cached data. Use the old ones. - module.contents = this.module.contents; - } - this.module = module; - } + this.folderInstance = await AddonModFolder.getFolder(this.courseId, this.module.id); + await CoreCourse.loadModuleContents(this.module, this.courseId, undefined, false, refresh); this.dataRetrieved.emit(this.folderInstance || this.module); diff --git a/src/addons/mod/folder/services/folder.ts b/src/addons/mod/folder/services/folder.ts index f868c2e27..f62fca427 100644 --- a/src/addons/mod/folder/services/folder.ts +++ b/src/addons/mod/folder/services/folder.ts @@ -122,16 +122,6 @@ export class AddonModFolderProvider { await site.invalidateWsCacheForKey(this.getFolderCacheKey(courseId)); } - /** - * Returns whether or not getFolder WS available or not. - * - * @return If WS is available. - * @since 3.3 - */ - isGetFolderWSAvailable(): boolean { - return CoreSites.wsAvailableInCurrentSite('mod_folder_get_folders_by_courses'); - } - /** * Report a folder as being viewed. * diff --git a/src/addons/mod/folder/services/handlers/prefetch.ts b/src/addons/mod/folder/services/handlers/prefetch.ts index 5c2fd9bd6..5081cd5d5 100644 --- a/src/addons/mod/folder/services/handlers/prefetch.ts +++ b/src/addons/mod/folder/services/handlers/prefetch.ts @@ -35,10 +35,7 @@ export class AddonModFolderPrefetchHandlerService extends CoreCourseResourcePref const promises: Promise[] = []; promises.push(super.downloadOrPrefetch(module, courseId, prefetch)); - - if (AddonModFolder.isGetFolderWSAvailable()) { - promises.push(AddonModFolder.getFolder(courseId, module.id)); - } + promises.push(AddonModFolder.getFolder(courseId, module.id)); await Promise.all(promises); } diff --git a/src/addons/mod/forum/pages/new-discussion/new-discussion.page.ts b/src/addons/mod/forum/pages/new-discussion/new-discussion.page.ts index 71e71d97e..52995909a 100644 --- a/src/addons/mod/forum/pages/new-discussion/new-discussion.page.ts +++ b/src/addons/mod/forum/pages/new-discussion/new-discussion.page.ts @@ -359,12 +359,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea * @return Promise resolved with the list of groups. */ protected addAllParticipantsOption(groups: CoreGroup[], check: boolean): Promise { - if (!AddonModForum.isAllParticipantsFixed()) { - // All participants has a bug, don't add it. - return Promise.resolve(groups); - } - - let promise; + let promise: Promise; if (check) { // We need to check if the user can add a discussion to all participants. diff --git a/src/addons/mod/forum/services/forum.ts b/src/addons/mod/forum/services/forum.ts index dcb625e85..131706f96 100644 --- a/src/addons/mod/forum/services/forum.ts +++ b/src/addons/mod/forum/services/forum.ts @@ -308,15 +308,6 @@ export class AddonModForumProvider { return index >= 0 ? posts.splice(index, 1).pop() : undefined; } - /** - * There was a bug adding new discussions to All Participants (see MDL-57962). Check if it's fixed. - * - * @return True if fixed, false otherwise. - */ - isAllParticipantsFixed(): boolean { - return !!CoreSites.getCurrentSite()?.isVersionGreaterEqualThan(['3.1.5', '3.2.2']); - } - /** * Returns whether or not getDiscussionPost WS available or not. * diff --git a/src/addons/mod/glossary/components/index/index.ts b/src/addons/mod/glossary/components/index/index.ts index fac7c7507..41db3e7d1 100644 --- a/src/addons/mod/glossary/components/index/index.ts +++ b/src/addons/mod/glossary/components/index/index.ts @@ -162,7 +162,7 @@ export class AddonModGlossaryIndexComponent extends CoreCourseModuleMainActivity this.glossary = await AddonModGlossary.getGlossary(this.courseId, this.module.id); this.description = this.glossary.intro || this.description; - this.canAdd = (AddonModGlossary.isPluginEnabledForEditing() && !!this.glossary.canaddentry) || false; + this.canAdd = !!this.glossary.canaddentry || false; this.dataRetrieved.emit(this.glossary); diff --git a/src/addons/mod/glossary/services/glossary.ts b/src/addons/mod/glossary/services/glossary.ts index a9476adbe..033adbe77 100644 --- a/src/addons/mod/glossary/services/glossary.ts +++ b/src/addons/mod/glossary/services/glossary.ts @@ -22,7 +22,6 @@ import { CoreRatingInfo } from '@features/rating/services/rating'; import { CoreTagItem } from '@features/tag/services/tag'; import { CoreApp } from '@services/app'; import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites'; -import { CoreTextUtils } from '@services/utils/text'; import { CoreUtils } from '@services/utils/utils'; import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws'; import { makeSingleton, Translate } from '@singletons'; @@ -964,11 +963,6 @@ export class AddonModGlossaryProvider { }); } - // Workaround for bug MDL-57737. - if (!site.isVersionGreaterEqualThan('3.2.2')) { - params.definition = CoreTextUtils.cleanTags(params.definition); - } - const response = await site.write('mod_glossary_add_entry', params); return response.entryid; @@ -1007,16 +1001,6 @@ export class AddonModGlossaryProvider { } } - /** - * Return whether or not the plugin is enabled for editing in the current site. Plugin is enabled if the glossary WS are - * available. - * - * @return Whether the glossary editing is available or not. - */ - isPluginEnabledForEditing(): boolean { - return !!CoreSites.getCurrentSite()?.wsAvailable('mod_glossary_add_entry'); - } - /** * Report a glossary as being viewed. * diff --git a/src/addons/mod/glossary/services/handlers/prefetch.ts b/src/addons/mod/glossary/services/handlers/prefetch.ts index 16236256d..58420e244 100644 --- a/src/addons/mod/glossary/services/handlers/prefetch.ts +++ b/src/addons/mod/glossary/services/handlers/prefetch.ts @@ -19,7 +19,7 @@ import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/c import { CoreCourses } from '@features/courses/services/courses'; import { CoreUser } from '@features/user/services/user'; import { CoreFilepool } from '@services/filepool'; -import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; +import { CoreSitesReadingStrategy } from '@services/sites'; import { CoreUtils } from '@services/utils/utils'; import { CoreWSFile } from '@services/ws'; import { makeSingleton } from '@singletons'; @@ -73,16 +73,12 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr ): CoreWSFile[] { let files = this.getIntroFilesFromInstance(module, glossary); - const getInlineFiles = CoreSites.getCurrentSite()?.isVersionGreaterEqualThan('3.2'); - // Get entries files. entries.forEach((entry) => { files = files.concat(entry.attachments || []); - if (getInlineFiles && entry.definitioninlinefiles && entry.definitioninlinefiles.length) { + if (entry.definitioninlinefiles && entry.definitioninlinefiles.length) { files = files.concat(entry.definitioninlinefiles); - } else if (entry.definition && !getInlineFiles) { - files = files.concat(CoreFilepool.extractDownloadableFilesFromHtmlAsFakeFileObjects(entry.definition)); } }); diff --git a/src/addons/mod/h5pactivity/services/h5pactivity.ts b/src/addons/mod/h5pactivity/services/h5pactivity.ts index 2c7f3f6d7..f3e3b0c1a 100644 --- a/src/addons/mod/h5pactivity/services/h5pactivity.ts +++ b/src/addons/mod/h5pactivity/services/h5pactivity.ts @@ -744,6 +744,7 @@ export class AddonModH5PActivityProvider { * Delete launcher. * * @return Promise resolved when the launcher file is deleted. + * @since 3.9 */ async isPluginEnabled(siteId?: string): Promise { const site = await CoreSites.getSite(siteId); @@ -788,7 +789,7 @@ export class AddonModH5PActivityProvider { const site = await CoreSites.getSite(options.siteId); if (!site.wsAvailable('mod_h5pactivity_log_report_viewed')) { - // Site doesn't support the WS, stop. + // Site doesn't support the WS, stop. Added in Moodle 3.11. return; } diff --git a/src/addons/mod/label/services/handlers/prefetch.ts b/src/addons/mod/label/services/handlers/prefetch.ts index 2b702318a..c9f35f8fa 100644 --- a/src/addons/mod/label/services/handlers/prefetch.ts +++ b/src/addons/mod/label/services/handlers/prefetch.ts @@ -19,7 +19,7 @@ import { CoreSitesReadingStrategy } from '@services/sites'; import { CoreUtils } from '@services/utils/utils'; import { CoreWSFile } from '@services/ws'; import { makeSingleton } from '@singletons'; -import { AddonModLabel, AddonModLabelLabel, AddonModLabelProvider } from '../label'; +import { AddonModLabel, AddonModLabelProvider } from '../label'; /** * Handler to prefetch labels. @@ -37,13 +37,9 @@ export class AddonModLabelPrefetchHandlerService extends CoreCourseResourcePrefe * @inheritdoc */ async getIntroFiles(module: CoreCourseAnyModuleData, courseId: number, ignoreCache?: boolean): Promise { - let label: AddonModLabelLabel | undefined; - - if (AddonModLabel.isGetLabelAvailableForSite()) { - label = await AddonModLabel.getLabel(courseId, module.id, { - readingStrategy: ignoreCache ? CoreSitesReadingStrategy.ONLY_NETWORK : undefined, - }); - } + const label = await AddonModLabel.getLabel(courseId, module.id, { + readingStrategy: ignoreCache ? CoreSitesReadingStrategy.ONLY_NETWORK : undefined, + }); return this.getIntroFilesFromInstance(module, label); } diff --git a/src/addons/mod/label/services/label.ts b/src/addons/mod/label/services/label.ts index 21f673e6b..2bea84806 100644 --- a/src/addons/mod/label/services/label.ts +++ b/src/addons/mod/label/services/label.ts @@ -136,32 +136,6 @@ export class AddonModLabelProvider { await CoreUtils.allPromises(promises); } - /** - * Check if the site has the WS to get label data. - * - * @param siteId Site ID. If not defined, current site. - * @return Promise resolved with boolean: whether it's available. - * @since 3.3 - */ - async isGetLabelAvailable(siteId?: string): Promise { - const site = await CoreSites.getSite(siteId); - - return site.wsAvailable('mod_label_get_labels_by_courses'); - } - - /** - * Check if the site has the WS to get label data. - * - * @param site Site. If not defined, current site. - * @return Whether it's available. - * @since 3.3 - */ - isGetLabelAvailableForSite(site?: CoreSite): boolean { - site = site || CoreSites.getCurrentSite(); - - return !!site?.wsAvailable('mod_label_get_labels_by_courses'); - } - } export const AddonModLabel = makeSingleton(AddonModLabelProvider); diff --git a/src/addons/mod/lesson/services/handlers/grade-link.ts b/src/addons/mod/lesson/services/handlers/grade-link.ts index d5c847659..3bc46f80b 100644 --- a/src/addons/mod/lesson/services/handlers/grade-link.ts +++ b/src/addons/mod/lesson/services/handlers/grade-link.ts @@ -82,21 +82,6 @@ export class AddonModLessonGradeLinkHandlerService extends CoreContentLinksModul } } - /** - * Check if the handler is enabled for a certain site (site + user) and a URL. - * If not defined, defaults to true. - * - * @param siteId The site ID. - * @param url The URL to treat. - * @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1} - * @param courseId Course ID related to the URL. Optional but recommended. - * @return Whether the handler is enabled for the URL and site. - */ - // eslint-disable-next-line @typescript-eslint/no-unused-vars - async isEnabled(siteId: string, url: string, params: Record, courseId?: number): Promise { - return AddonModLesson.isPluginEnabled(siteId); - } - } export const AddonModLessonGradeLinkHandler = makeSingleton(AddonModLessonGradeLinkHandlerService); diff --git a/src/addons/mod/lesson/services/handlers/index-link.ts b/src/addons/mod/lesson/services/handlers/index-link.ts index 03da03b76..98b647e8e 100644 --- a/src/addons/mod/lesson/services/handlers/index-link.ts +++ b/src/addons/mod/lesson/services/handlers/index-link.ts @@ -66,21 +66,6 @@ export class AddonModLessonIndexLinkHandlerService extends CoreContentLinksModul }]; } - /** - * Check if the handler is enabled for a certain site (site + user) and a URL. - * If not defined, defaults to true. - * - * @param siteId The site ID. - * @param url The URL to treat. - * @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1} - * @param courseId Course ID related to the URL. Optional but recommended. - * @return Whether the handler is enabled for the URL and site. - */ - // eslint-disable-next-line @typescript-eslint/no-unused-vars - isEnabled(siteId: string, url: string, params: Record, courseId?: number): Promise { - return AddonModLesson.isPluginEnabled(siteId); - } - /** * Navigate to a lesson module (index page) with a fixed password. * diff --git a/src/addons/mod/lesson/services/handlers/list-link.ts b/src/addons/mod/lesson/services/handlers/list-link.ts index 16e69fb25..a2b36e3ac 100644 --- a/src/addons/mod/lesson/services/handlers/list-link.ts +++ b/src/addons/mod/lesson/services/handlers/list-link.ts @@ -16,7 +16,6 @@ import { Injectable } from '@angular/core'; import { CoreContentLinksModuleListHandler } from '@features/contentlinks/classes/module-list-handler'; import { makeSingleton } from '@singletons'; -import { AddonModLesson } from '../lesson'; /** * Handler to treat links to lesson list page. @@ -30,16 +29,6 @@ export class AddonModLessonListLinkHandlerService extends CoreContentLinksModule super('AddonModLesson', 'lesson'); } - /** - * Check if the handler is enabled on a site level. - * - * @return Promise resolved with boolean: whether or not the handler is enabled on a site level. - */ - // eslint-disable-next-line @typescript-eslint/no-unused-vars - isEnabled(siteId: string, url: string, params: Record, courseId?: number): Promise { - return AddonModLesson.isPluginEnabled(siteId); - } - } export const AddonModLessonListLinkHandler = makeSingleton(AddonModLessonListLinkHandlerService); diff --git a/src/addons/mod/lesson/services/handlers/module.ts b/src/addons/mod/lesson/services/handlers/module.ts index c094f2170..68cf0e871 100644 --- a/src/addons/mod/lesson/services/handlers/module.ts +++ b/src/addons/mod/lesson/services/handlers/module.ts @@ -18,7 +18,6 @@ import { CoreConstants } from '@/core/constants'; import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate'; import { CoreCourse, CoreCourseAnyModuleData, CoreCourseWSModule } from '@features/course/services/course'; import { CoreCourseModule } from '@features/course/services/course-helper'; -import { AddonModLesson } from '../lesson'; import { AddonModLessonIndexComponent } from '../../components/index'; import { CoreCourseAnyCourseData } from '@features/courses/services/courses'; import { CoreNavigationOptions, CoreNavigator } from '@services/navigator'; @@ -52,8 +51,8 @@ export class AddonModLessonModuleHandlerService implements CoreCourseModuleHandl * * @return Promise resolved with boolean: whether or not the handler is enabled on a site level. */ - isEnabled(): Promise { - return AddonModLesson.isPluginEnabled(); + async isEnabled(): Promise { + return true; } /** diff --git a/src/addons/mod/lesson/services/handlers/prefetch.ts b/src/addons/mod/lesson/services/handlers/prefetch.ts index 8369dee99..2b550bf94 100644 --- a/src/addons/mod/lesson/services/handlers/prefetch.ts +++ b/src/addons/mod/lesson/services/handlers/prefetch.ts @@ -221,15 +221,6 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref (accessInfo.preventaccessreasons.length == 1 && AddonModLesson.isPasswordProtected(accessInfo)); } - /** - * Whether or not the handler is enabled on a site level. - * - * @return Promise resolved with a boolean indicating if the handler is enabled. - */ - isEnabled(): Promise { - return AddonModLesson.isPluginEnabled(); - } - /** * @inheritdoc */ diff --git a/src/addons/mod/lesson/services/handlers/report-link.ts b/src/addons/mod/lesson/services/handlers/report-link.ts index ecc00a4a1..7a068134a 100644 --- a/src/addons/mod/lesson/services/handlers/report-link.ts +++ b/src/addons/mod/lesson/services/handlers/report-link.ts @@ -20,7 +20,6 @@ import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; -import { AddonModLesson } from '../lesson'; import { AddonModLessonModuleHandlerService } from './module'; /** @@ -81,7 +80,7 @@ export class AddonModLessonReportLinkHandlerService extends CoreContentLinksHand return false; } - return AddonModLesson.isPluginEnabled(siteId); + return true; } /** diff --git a/src/addons/mod/lesson/services/lesson.ts b/src/addons/mod/lesson/services/lesson.ts index be4d8c826..a89470d6d 100644 --- a/src/addons/mod/lesson/services/lesson.ts +++ b/src/addons/mod/lesson/services/lesson.ts @@ -2710,19 +2710,6 @@ export class AddonModLessonProvider { return false; } - /** - * Return whether or not the plugin is enabled in a certain site. Plugin is enabled if the lesson WS are available. - * - * @param siteId Site ID. If not defined, current site. - * @return Promise resolved with true if plugin is enabled, rejected or resolved with false otherwise. - */ - async isPluginEnabled(siteId?: string): Promise { - const site = await CoreSites.getSite(siteId); - - // All WS were introduced at the same time so checking one is enough. - return site.wsAvailable('mod_lesson_get_lesson_access_information'); - } - /** * Check if a page is a question page or a content page. * diff --git a/src/addons/mod/lti/services/lti.ts b/src/addons/mod/lti/services/lti.ts index 35678bb66..72c658feb 100644 --- a/src/addons/mod/lti/services/lti.ts +++ b/src/addons/mod/lti/services/lti.ts @@ -331,7 +331,7 @@ export type AddonModLtiLti = { name: string; // LTI name. intro?: string; // The LTI intro. introformat?: number; // Intro format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN). - introfiles?: CoreWSExternalFile[]; // @since 3.2. + introfiles?: CoreWSExternalFile[]; timecreated?: number; // Time of creation. timemodified?: number; // Time of last modification. typeid?: number; // Type id. diff --git a/src/addons/mod/page/components/index/index.ts b/src/addons/mod/page/components/index/index.ts index 4dad5b9be..f3034ce73 100644 --- a/src/addons/mod/page/components/index/index.ts +++ b/src/addons/mod/page/components/index/index.ts @@ -15,7 +15,7 @@ import { Component, OnInit, Optional } from '@angular/core'; import { CoreCourseModuleMainResourceComponent } from '@features/course/classes/main-resource-component'; import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; -import { CoreCourse, CoreCourseWSModule } from '@features/course/services/course'; +import { CoreCourse } from '@features/course/services/course'; import { CoreTextUtils } from '@services/utils/text'; import { CoreUtils } from '@services/utils/utils'; import { AddonModPageProvider, AddonModPagePage, AddonModPage } from '../../services/page'; @@ -32,12 +32,11 @@ import { AddonModPageHelper } from '../../services/page-helper'; export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComponent implements OnInit { component = AddonModPageProvider.COMPONENT; - canGetPage = false; contents?: string; displayDescription = true; displayTimemodified = true; timemodified?: number; - page?: CoreCourseWSModule | AddonModPagePage; + page?: AddonModPagePage; warning?: string; protected fetchContentDefaultError = 'addon.mod_page.errorwhileloadingthepage'; @@ -52,8 +51,6 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp async ngOnInit(): Promise { super.ngOnInit(); - this.canGetPage = AddonModPage.isGetPageWSAvailable(); - await this.loadContent(); try { @@ -103,21 +100,13 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp */ protected async loadPageData(): Promise { // Get latest title, description and some extra data. Data should've been updated in download. - const page = this.canGetPage ? - await AddonModPage.getPageData(this.courseId, this.module.id) : - await CoreCourse.getModule(this.module.id, this.courseId); + this.page = await AddonModPage.getPageData(this.courseId, this.module.id); - this.description = 'intro' in page ? page.intro : page.description; - this.dataRetrieved.emit(page); - - if (!this.canGetPage) { - return; - } - - this.page = page; + this.description = this.page.intro; + this.dataRetrieved.emit(this.page); // Check if description and timemodified should be displayed. - if ('displayoptions' in this.page) { + if (this.page.displayoptions) { const options: Record = CoreTextUtils.unserialize(this.page.displayoptions) || {}; diff --git a/src/addons/mod/page/services/handlers/prefetch.ts b/src/addons/mod/page/services/handlers/prefetch.ts index 187d77fd6..fdbb6f721 100644 --- a/src/addons/mod/page/services/handlers/prefetch.ts +++ b/src/addons/mod/page/services/handlers/prefetch.ts @@ -42,10 +42,7 @@ export class AddonModPagePrefetchHandlerService extends CoreCourseResourcePrefet const promises: Promise[] = []; promises.push(super.downloadOrPrefetch(module, courseId, prefetch)); - - if (AddonModPage.isGetPageWSAvailable()) { - promises.push(AddonModPage.getPageData(courseId, module.id)); - } + promises.push(AddonModPage.getPageData(courseId, module.id)); await Promise.all(promises); } diff --git a/src/addons/mod/page/services/page.ts b/src/addons/mod/page/services/page.ts index f936f0d64..1e29c8b7f 100644 --- a/src/addons/mod/page/services/page.ts +++ b/src/addons/mod/page/services/page.ts @@ -124,16 +124,6 @@ export class AddonModPageProvider { await site.invalidateWsCacheForKey(this.getPageCacheKey(courseId)); } - /** - * Returns whether or not getPage WS available or not. - * - * @return If WS is available. - * @since 3.3 - */ - isGetPageWSAvailable(): boolean { - return CoreSites.wsAvailableInCurrentSite('mod_page_get_pages_by_courses'); - } - /** * Return whether or not the plugin is enabled. * diff --git a/src/addons/mod/quiz/components/index/index.ts b/src/addons/mod/quiz/components/index/index.ts index 623de1c11..d8e45071e 100644 --- a/src/addons/mod/quiz/components/index/index.ts +++ b/src/addons/mod/quiz/components/index/index.ts @@ -18,7 +18,6 @@ import { Component, OnDestroy, OnInit, Optional } from '@angular/core'; import { CoreCourseModuleMainActivityComponent } from '@features/course/classes/main-activity-component'; import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; import { CoreCourse } from '@features/course/services/course'; -import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; import { CoreQuestionBehaviourDelegate } from '@features/question/services/behaviour-delegate'; import { IonContent } from '@ionic/angular'; import { CoreNavigator } from '@services/navigator'; @@ -154,7 +153,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp // If the site doesn't support check updates, always prefetch it because we cannot tell if there's something new. const isDownloaded = this.currentStatus == CoreConstants.DOWNLOADED; - if (isDownloaded && CoreCourseModulePrefetchDelegate.canCheckUpdates()) { + if (isDownloaded) { // Already downloaded, open it. return this.openQuiz(); } @@ -168,7 +167,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp // Success downloading, open quiz. this.openQuiz(); } catch (error) { - if (this.hasOffline || (isDownloaded && !CoreCourseModulePrefetchDelegate.canCheckUpdates())) { + if (this.hasOffline) { // Error downloading but there is something offline, allow continuing it. // If the site doesn't support check updates, continue too because we cannot tell if there's something new. this.openQuiz(); @@ -647,9 +646,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp if (data) { this.gradebookData = { - grade: 'graderaw' in data && data.graderaw !== undefined && data.graderaw !== null ? - data.graderaw : - (data.grade !== undefined && data.grade !== null ? Number(data.grade) : undefined), + grade: data.graderaw ?? (data.grade !== undefined && data.grade !== null ? Number(data.grade) : undefined), feedback: data.feedback, }; } diff --git a/src/addons/mod/quiz/services/handlers/prefetch.ts b/src/addons/mod/quiz/services/handlers/prefetch.ts index 1ee999c75..47b61b959 100644 --- a/src/addons/mod/quiz/services/handlers/prefetch.ts +++ b/src/addons/mod/quiz/services/handlers/prefetch.ts @@ -111,7 +111,6 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet attempts: AddonModQuizAttemptWSData[], siteId?: string, ): Promise { - const getInlineFiles = CoreSites.getCurrentSite()?.isVersionGreaterEqualThan('3.2'); let files: CoreWSFile[] = []; await Promise.all(attempts.map(async (attempt) => { @@ -131,12 +130,8 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet siteId, }); - if (getInlineFiles && feedback.feedbackinlinefiles?.length) { + if (feedback.feedbackinlinefiles?.length) { files = files.concat(feedback.feedbackinlinefiles); - } else if (feedback.feedbacktext && !getInlineFiles) { - files = files.concat( - CoreFilepool.extractDownloadableFilesFromHtmlAsFakeFileObjects(feedback.feedbacktext), - ); } })); @@ -526,7 +521,7 @@ export class AddonModQuizPrefetchHandlerService extends CoreCourseActivityPrefet try { const gradebookData = await AddonModQuiz.getGradeFromGradebook(quiz.course, quiz.coursemodule, true, siteId); - if (gradebookData && 'graderaw' in gradebookData && gradebookData.graderaw !== undefined) { + if (gradebookData && gradebookData.graderaw !== undefined) { await AddonModQuiz.getFeedbackForGrade(quiz.id, gradebookData.graderaw, modOptions); } } catch { diff --git a/src/addons/mod/quiz/services/quiz.ts b/src/addons/mod/quiz/services/quiz.ts index 30216d969..f64bda703 100644 --- a/src/addons/mod/quiz/services/quiz.ts +++ b/src/addons/mod/quiz/services/quiz.ts @@ -19,7 +19,7 @@ import { CoreWSError } from '@classes/errors/wserror'; import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; import { CoreCourseCommonModWSOptions } from '@features/course/services/course'; import { CoreCourseLogHelper } from '@features/course/services/log-helper'; -import { CoreGradesFormattedItem, CoreGradesFormattedRow, CoreGradesHelper } from '@features/grades/services/grades-helper'; +import { CoreGradesFormattedItem, CoreGradesHelper } from '@features/grades/services/grades-helper'; import { CorePushNotifications } from '@features/pushnotifications/services/pushnotifications'; import { CoreQuestion, @@ -647,7 +647,7 @@ export class AddonModQuizProvider { ignoreCache?: boolean, siteId?: string, userId?: number, - ): Promise { + ): Promise { const items = await CoreGradesHelper.getGradeModuleItems( courseId, diff --git a/src/addons/mod/resource/components/index/index.ts b/src/addons/mod/resource/components/index/index.ts index 29f8e101e..90d47fa39 100644 --- a/src/addons/mod/resource/components/index/index.ts +++ b/src/addons/mod/resource/components/index/index.ts @@ -16,7 +16,7 @@ import { Component, OnDestroy, OnInit, Optional } from '@angular/core'; import { CoreError } from '@classes/errors/error'; import { CoreCourseModuleMainResourceComponent } from '@features/course/classes/main-resource-component'; import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; -import { CoreCourse, CoreCourseWSModule } from '@features/course/services/course'; +import { CoreCourse } from '@features/course/services/course'; import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; import { CoreApp } from '@services/app'; import { CoreFileHelper } from '@services/file-helper'; @@ -30,7 +30,6 @@ import { AddonModResource, AddonModResourceCustomData, AddonModResourceProvider, - AddonModResourceResource, } from '../../services/resource'; import { AddonModResourceHelper } from '../../services/resource-helper'; @@ -45,7 +44,6 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource component = AddonModResourceProvider.COMPONENT; - canGetResource = false; mode = ''; src = ''; contentText = ''; @@ -69,7 +67,6 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource async ngOnInit(): Promise { super.ngOnInit(); - this.canGetResource = AddonModResource.isGetResourceWSAvailable(); this.isIOS = CoreApp.isIOS(); this.isOnline = CoreApp.isOnline(); @@ -110,26 +107,17 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource throw new CoreError(Translate.instant('core.filenotfound')); } - let resource: AddonModResourceResource | CoreCourseWSModule | undefined; - let options: AddonModResourceCustomData = {}; let hasCalledDownloadResource = false; // Get the resource instance to get the latest name/description and to know if it's embedded. - if (this.canGetResource) { - resource = await AddonModResource.getResourceData(this.courseId, this.module.id); - this.description = resource.intro || ''; - options = resource.displayoptions ? CoreTextUtils.unserialize(resource.displayoptions) : {}; - } else { - resource = await CoreCourse.getModule(this.module.id, this.courseId); - this.description = resource.description || ''; - options = resource.customdata ? CoreTextUtils.unserialize(CoreTextUtils.parseJSON(resource.customdata)) : {}; - } + const resource = await AddonModResource.getResourceData(this.courseId, this.module.id); + this.description = resource.intro || ''; + const options: AddonModResourceCustomData = + resource.displayoptions ? CoreTextUtils.unserialize(resource.displayoptions) : {}; try { - if (resource) { - this.displayDescription = typeof options.printintro == 'undefined' || !!options.printintro; - this.dataRetrieved.emit(resource); - } + this.displayDescription = typeof options.printintro == 'undefined' || !!options.printintro; + this.dataRetrieved.emit(resource); if (AddonModResourceHelper.isDisplayedInIframe(this.module)) { hasCalledDownloadResource = true; diff --git a/src/addons/mod/resource/services/handlers/module.ts b/src/addons/mod/resource/services/handlers/module.ts index 672482df8..317bd0c1f 100644 --- a/src/addons/mod/resource/services/handlers/module.ts +++ b/src/addons/mod/resource/services/handlers/module.ts @@ -156,7 +156,7 @@ export class AddonModResourceModuleHandlerService implements CoreCourseModuleHan if ('customdata' in module && typeof module.customdata != 'undefined') { options = CoreTextUtils.unserialize(CoreTextUtils.parseJSON(module.customdata)); - } else if (AddonModResource.isGetResourceWSAvailable()) { + } else { // Get the resource data. promises.push(AddonModResource.getResourceData(courseId, module.id).then((info) => { infoFiles = info.contentfiles; diff --git a/src/addons/mod/resource/services/handlers/prefetch.ts b/src/addons/mod/resource/services/handlers/prefetch.ts index f93df9fac..696922b78 100644 --- a/src/addons/mod/resource/services/handlers/prefetch.ts +++ b/src/addons/mod/resource/services/handlers/prefetch.ts @@ -67,10 +67,7 @@ export class AddonModResourcePrefetchHandlerService extends CoreCourseResourcePr const promises: Promise[] = []; promises.push(super.downloadOrPrefetch(module, courseId, prefetch, dirPath)); - - if (AddonModResource.isGetResourceWSAvailable()) { - promises.push(AddonModResource.getResourceData(courseId, module.id)); - } + promises.push(AddonModResource.getResourceData(courseId, module.id)); await Promise.all(promises); } diff --git a/src/addons/mod/resource/services/resource.ts b/src/addons/mod/resource/services/resource.ts index 23f21dc62..e9a672728 100644 --- a/src/addons/mod/resource/services/resource.ts +++ b/src/addons/mod/resource/services/resource.ts @@ -130,16 +130,6 @@ export class AddonModResourceProvider { await site.invalidateWsCacheForKey(this.getResourceCacheKey(courseId)); } - /** - * Returns whether or not getResource WS available or not. - * - * @return If WS is abalaible. - * @since 3.3 - */ - isGetResourceWSAvailable(): boolean { - return CoreSites.wsAvailableInCurrentSite('mod_resource_get_resources_by_courses'); - } - /** * Return whether or not the plugin is enabled. * diff --git a/src/addons/mod/scorm/services/scorm.ts b/src/addons/mod/scorm/services/scorm.ts index 340eb6ed8..a5cd5ecb9 100644 --- a/src/addons/mod/scorm/services/scorm.ts +++ b/src/addons/mod/scorm/services/scorm.ts @@ -1612,11 +1612,6 @@ export class AddonModScormProvider { }; const wsFunction = 'mod_scorm_insert_scorm_tracks'; - // Check if the method is available, use a prefixed version if possible. - if (!currentSite.wsAvailable(wsFunction, false)) { - return false; - } - try { const response = CoreWS.syncCall(wsFunction, params, preSets); diff --git a/src/addons/mod/survey/services/survey.ts b/src/addons/mod/survey/services/survey.ts index 523a7fa8d..0278684aa 100644 --- a/src/addons/mod/survey/services/survey.ts +++ b/src/addons/mod/survey/services/survey.ts @@ -322,7 +322,7 @@ export type AddonModSurveySurvey = { name: string; // Survey name. intro?: string; // The Survey intro. introformat?: number; // Intro format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN). - introfiles?: CoreWSExternalFile[]; // @since 3.2. + introfiles?: CoreWSExternalFile[]; template?: number; // Survey type. days?: number; // Days. questions?: string; // Question ids. diff --git a/src/addons/mod/url/components/index/index.ts b/src/addons/mod/url/components/index/index.ts index 0409c7e4c..dddcee782 100644 --- a/src/addons/mod/url/components/index/index.ts +++ b/src/addons/mod/url/components/index/index.ts @@ -36,7 +36,6 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo component = AddonModUrlProvider.COMPONENT; - canGetUrl = false; url?: string; name?: string; shouldEmbed = false; @@ -58,8 +57,6 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo async ngOnInit(): Promise { super.ngOnInit(); - this.canGetUrl = AddonModUrl.isGetUrlWSAvailable(); - await this.loadContent(); if ((this.shouldIframe || @@ -86,9 +83,6 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo */ protected async fetchContent(refresh = false): Promise { try { - if (!this.canGetUrl) { - throw null; - } // Fetch the module data. const url = await AddonModUrl.getUrl(this.courseId, this.module.id); @@ -110,7 +104,7 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo await this.calculateDisplayOptions(url); } catch { - // Fallback in case is not prefetched or not available. + // Fallback in case is not prefetched. const mod = await CoreCourse.getModule(this.module.id, this.courseId, undefined, false, false, undefined, 'url'); diff --git a/src/addons/mod/url/services/handlers/module.ts b/src/addons/mod/url/services/handlers/module.ts index d30b3189c..08ed9d915 100644 --- a/src/addons/mod/url/services/handlers/module.ts +++ b/src/addons/mod/url/services/handlers/module.ts @@ -175,7 +175,7 @@ export class AddonModUrlModuleHandlerService implements CoreCourseModuleHandler if (canHandle) { // URL handled by the app, open it directly. return true; - } else if (AddonModUrl.isGetUrlWSAvailable()) { + } else { // Not handled by the app, check the display type. const url = await CoreUtils.ignoreErrors(AddonModUrl.getUrl(courseId, module.id)); const displayType = AddonModUrl.getFinalDisplayType(url); @@ -183,8 +183,6 @@ export class AddonModUrlModuleHandlerService implements CoreCourseModuleHandler return displayType == CoreConstants.RESOURCELIB_DISPLAY_OPEN || displayType == CoreConstants.RESOURCELIB_DISPLAY_POPUP; } - - return false; } catch { return false; } diff --git a/src/addons/mod/url/services/url.ts b/src/addons/mod/url/services/url.ts index 2cac565ba..0ccff66ed 100644 --- a/src/addons/mod/url/services/url.ts +++ b/src/addons/mod/url/services/url.ts @@ -206,16 +206,6 @@ export class AddonModUrlProvider { await site.invalidateWsCacheForKey(this.getUrlCacheKey(courseId)); } - /** - * Returns whether or not getUrl WS available or not. - * - * @return If WS is abalaible. - * @since 3.3 - */ - isGetUrlWSAvailable(): boolean { - return CoreSites.wsAvailableInCurrentSite('mod_url_get_urls_by_courses'); - } - /** * Report the url as being viewed. * diff --git a/src/addons/mod/wiki/services/wiki.ts b/src/addons/mod/wiki/services/wiki.ts index f150b3834..580e9f20d 100644 --- a/src/addons/mod/wiki/services/wiki.ts +++ b/src/addons/mod/wiki/services/wiki.ts @@ -178,9 +178,7 @@ export class AddonModWikiProvider { if (section) { params.section = section; } - - // This parameter requires Moodle 3.2. It saves network usage. - if (lockOnly && site.isVersionGreaterEqualThan('3.2')) { + if (lockOnly) { params.lockonly = true; } diff --git a/src/addons/mod/workshop/services/handlers/index-link.ts b/src/addons/mod/workshop/services/handlers/index-link.ts index 01fe2e311..3ad62aba9 100644 --- a/src/addons/mod/workshop/services/handlers/index-link.ts +++ b/src/addons/mod/workshop/services/handlers/index-link.ts @@ -15,7 +15,7 @@ import { Injectable } from '@angular/core'; import { CoreContentLinksModuleIndexHandler } from '@features/contentlinks/classes/module-index-handler'; import { makeSingleton } from '@singletons'; -import { AddonModWorkshopProvider, AddonModWorkshop } from '../workshop'; +import { AddonModWorkshopProvider } from '../workshop'; /** * Handler to treat links to workshop. */ @@ -28,12 +28,5 @@ export class AddonModWorkshopIndexLinkHandlerService extends CoreContentLinksMod super(AddonModWorkshopProvider.COMPONENT, 'workshop', 'w'); } - /** - * @inheritdoc - */ - isEnabled(siteId: string): Promise { - return AddonModWorkshop.isPluginEnabled(siteId); - } - } export const AddonModWorkshopIndexLinkHandler = makeSingleton(AddonModWorkshopIndexLinkHandlerService); diff --git a/src/addons/mod/workshop/services/handlers/list-link.ts b/src/addons/mod/workshop/services/handlers/list-link.ts index 7e2852f57..ca7ebe105 100644 --- a/src/addons/mod/workshop/services/handlers/list-link.ts +++ b/src/addons/mod/workshop/services/handlers/list-link.ts @@ -15,7 +15,6 @@ import { Injectable } from '@angular/core'; import { CoreContentLinksModuleListHandler } from '@features/contentlinks/classes/module-list-handler'; import { makeSingleton } from '@singletons'; -import { AddonModWorkshop } from '../workshop'; /** * Handler to treat links to workshop list page. @@ -29,14 +28,5 @@ export class AddonModWorkshopListLinkHandlerService extends CoreContentLinksModu super('AddonModWorkshop', 'workshop'); } - /** - * Check if the handler is enabled on a site level. - * - * @return Whether or not the handler is enabled on a site level. - */ - isEnabled(): Promise { - return AddonModWorkshop.isPluginEnabled(); - } - } export const AddonModWorkshopListLinkHandler = makeSingleton(AddonModWorkshopListLinkHandlerService); diff --git a/src/addons/mod/workshop/services/handlers/module.ts b/src/addons/mod/workshop/services/handlers/module.ts index 22e54bf0a..86463eee3 100644 --- a/src/addons/mod/workshop/services/handlers/module.ts +++ b/src/addons/mod/workshop/services/handlers/module.ts @@ -20,7 +20,6 @@ import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/ import { CoreNavigationOptions, CoreNavigator } from '@services/navigator'; import { makeSingleton } from '@singletons'; import { AddonModWorkshopIndexComponent } from '../../components/index'; -import { AddonModWorkshop } from '../workshop'; /** * Handler to support workshop modules. @@ -47,8 +46,8 @@ export class AddonModWorkshopModuleHandlerService implements CoreCourseModuleHan /** * @inheritdoc */ - isEnabled(): Promise { - return AddonModWorkshop.isPluginEnabled(); + async isEnabled(): Promise { + return true; } /** diff --git a/src/addons/mod/workshop/services/handlers/prefetch.ts b/src/addons/mod/workshop/services/handlers/prefetch.ts index c0903280a..ad986d253 100644 --- a/src/addons/mod/workshop/services/handlers/prefetch.ts +++ b/src/addons/mod/workshop/services/handlers/prefetch.ts @@ -201,13 +201,6 @@ export class AddonModWorkshopPrefetchHandlerService extends CoreCourseActivityPr return accessData.canswitchphase || workshop.phase > AddonModWorkshopPhase.PHASE_SETUP; } - /** - * @inheritdoc - */ - async isEnabled(): Promise { - return AddonModWorkshop.isPluginEnabled(); - } - /** * @inheritdoc */ diff --git a/src/addons/mod/workshop/services/workshop.ts b/src/addons/mod/workshop/services/workshop.ts index 27d802240..53bc85119 100644 --- a/src/addons/mod/workshop/services/workshop.ts +++ b/src/addons/mod/workshop/services/workshop.ts @@ -224,19 +224,6 @@ export class AddonModWorkshopProvider { return this.getWorkshopDataPrefixCacheKey(workshopId) + ':assessmentsform:' + assessmentId + ':' + mode; } - /** - * Return whether or not the plugin is enabled in a certain site. Plugin is enabled if the workshop WS are available. - * - * @param siteId Site ID. If not defined, current site. - * @return Promise resolved with true if plugin is enabled, rejected or resolved with false otherwise. - */ - async isPluginEnabled(siteId?: string): Promise { - const site = await CoreSites.getSite(siteId); - - return site.wsAvailable('mod_workshop_get_workshops_by_courses') && - site.wsAvailable('mod_workshop_get_workshop_access_information'); - } - /** * Get a workshop with key=value. If more than one is found, only the first will be returned. * @@ -275,7 +262,7 @@ export class AddonModWorkshopProvider { throw new CoreError(Translate.instant('core.course.modulenotfound')); } - // Set submission types for Moodle 3.5 and older. + // Set submission types for Moodle 3.5. if (typeof workshop.submissiontypetext == 'undefined') { if (typeof workshop.nattachments != 'undefined' && workshop.nattachments > 0) { workshop.submissiontypetext = AddonModWorkshopSubmissionType.SUBMISSION_TYPE_AVAILABLE; diff --git a/src/addons/notifications/pages/list/list.ts b/src/addons/notifications/pages/list/list.ts index fc37ccd61..589e0c8c7 100644 --- a/src/addons/notifications/pages/list/list.ts +++ b/src/addons/notifications/pages/list/list.ts @@ -89,7 +89,9 @@ export class AddonNotificationsListPage implements OnInit, OnDestroy { this.loadMoreError = false; try { - const result = await AddonNotificationsHelper.getNotifications(refresh ? [] : this.notifications); + const result = await AddonNotificationsHelper.getNotifications(refresh ? [] : this.notifications, { + onlyPopupNotifications: true, + }); const notifications = result.notifications.map((notification) => this.formatText(notification)); @@ -150,13 +152,7 @@ export class AddonNotificationsListPage implements OnInit, OnDestroy { CoreEvents.trigger(AddonNotificationsProvider.READ_CHANGED_EVENT, {}, CoreSites.getCurrentSiteId()); } - // Check if mark all notifications as read is enabled and there are some to read. - if (!AddonNotifications.isMarkAllNotificationsAsReadEnabled()) { - this.canMarkAllNotificationsAsRead = false; - - return; - } - + // Check if mark all as read should be displayed (there are unread notifications). try { this.loadingMarkAllNotificationsAsRead = true; diff --git a/src/addons/notifications/pages/settings/settings.html b/src/addons/notifications/pages/settings/settings.html index efa57cdfd..536c149c6 100644 --- a/src/addons/notifications/pages/settings/settings.html +++ b/src/addons/notifications/pages/settings/settings.html @@ -16,105 +16,96 @@ - + - - - {{ 'addon.notifications.playsound' | translate }} - - + + + {{ 'addon.notifications.notifications' | translate }} + + + + {{ 'addon.notifications.playsound' | translate }} + + + + - - - - {{ 'addon.notifications.notifications' | translate }} - - - - {{ 'addon.notifications.playsound' | translate }} - + + + + {{ processor.displayname }} + + + + + + + + {{ component.displayname }} + + {{ 'core.settings.loggedin' | translate }} + + + {{ 'core.settings.loggedoff' | translate }} + + + + + + + + + {{ notification.displayname }} + + + + + + + + {{'core.settings.locked' | translate }} + + + {{ 'core.settings.disabled' | translate }} + + + + + + + {{ notification.displayname }} + + + + {{ 'core.settings.' + state | translate }} + + + + + {{'core.settings.locked' | translate }} + + {{ 'core.settings.disabled' | translate }} - - - - - - {{ processor.displayname }} - - - - - - - - {{ component.displayname }} - - {{ 'core.settings.loggedin' | translate }} - - - {{ 'core.settings.loggedoff' | translate }} - - - - - - - - - {{ notification.displayname }} - - - - - - - - {{'core.settings.locked' | translate }} - - - {{ 'core.settings.disabled' | translate }} - - - - - - - {{ notification.displayname }} - - - - {{ 'core.settings.' + state | translate }} - - - - - - {{'core.settings.locked' | translate }} - - {{ 'core.settings.disabled' | translate }} - - - - + + diff --git a/src/addons/notifications/pages/settings/settings.ts b/src/addons/notifications/pages/settings/settings.ts index 0748db3b5..f87ced644 100644 --- a/src/addons/notifications/pages/settings/settings.ts +++ b/src/addons/notifications/pages/settings/settings.ts @@ -54,14 +54,12 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy { currentProcessor?: AddonNotificationsPreferencesProcessor; preferencesLoaded = false; notificationSound = false; - notifPrefsEnabled: boolean; canChangeSound: boolean; processorHandlers: AddonMessageOutputHandlerData[] = []; protected updateTimeout?: number; constructor() { - this.notifPrefsEnabled = AddonNotifications.isNotificationPreferencesEnabled(); this.canChangeSound = CoreLocalNotifications.canDisableSound(); } @@ -73,11 +71,7 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy { this.notificationSound = await CoreConfig.get(CoreConstants.SETTINGS_NOTIFICATION_SOUND, true); } - if (this.notifPrefsEnabled) { - this.fetchPreferences(); - } else { - this.preferencesLoaded = true; - } + this.fetchPreferences(); } /** diff --git a/src/addons/notifications/services/handlers/cron.ts b/src/addons/notifications/services/handlers/cron.ts index 828a78fbc..fc8ca5329 100644 --- a/src/addons/notifications/services/handlers/cron.ts +++ b/src/addons/notifications/services/handlers/cron.ts @@ -19,7 +19,7 @@ import { CoreCronHandler } from '@services/cron'; import { CoreSites } from '@services/sites'; import { makeSingleton } from '@singletons'; import { CoreEvents } from '@singletons/events'; -import { AddonNotifications, AddonNotificationsProvider } from '../notifications'; +import { AddonNotificationsProvider } from '../notifications'; /** * Notifications cron handler. @@ -44,8 +44,7 @@ export class AddonNotificationsCronHandlerService implements CoreCronHandler { * @return Whether it's a synchronization process or not. */ isSync(): boolean { - // This is done to use only wifi if using the fallback function. - return !AddonNotifications.isPreciseNotificationCountEnabled(); + return false; } /** diff --git a/src/addons/notifications/services/handlers/settings.ts b/src/addons/notifications/services/handlers/settings.ts index a67c415f4..fad86d300 100644 --- a/src/addons/notifications/services/handlers/settings.ts +++ b/src/addons/notifications/services/handlers/settings.ts @@ -14,10 +14,8 @@ import { Injectable } from '@angular/core'; -import { CoreLocalNotifications } from '@services/local-notifications'; import { makeSingleton } from '@singletons'; import { CoreSettingsHandler, CoreSettingsHandlerData } from '@features/settings/services/settings-delegate'; -import { AddonNotifications } from '../notifications'; /** * Notifications settings handler. @@ -36,8 +34,7 @@ export class AddonNotificationsSettingsHandlerService implements CoreSettingsHan * @return Whether or not the handler is enabled on a site level. */ async isEnabled(): Promise { - // Preferences or notification sound setting available. - return CoreLocalNotifications.isAvailable() || AddonNotifications.isNotificationPreferencesEnabled(); + return true; } /** diff --git a/src/addons/notifications/services/notifications-helper.ts b/src/addons/notifications/services/notifications-helper.ts index ebea4573a..77adc8eec 100644 --- a/src/addons/notifications/services/notifications-helper.ts +++ b/src/addons/notifications/services/notifications-helper.ts @@ -67,7 +67,7 @@ export class AddonNotificationsHelperProvider { */ async getNotifications( notifications: AddonNotificationsAnyNotification[], - options?: AddonNotificationsGetNotificationsOptions, + options?: AddonNotificationsHelperGetNotificationsOptions, ): Promise<{notifications: AddonNotificationsAnyNotification[]; canLoadMore: boolean}> { notifications = notifications || []; @@ -75,13 +75,11 @@ export class AddonNotificationsHelperProvider { options.limit = options.limit || AddonNotificationsProvider.LIST_LIMIT; options.siteId = options.siteId || CoreSites.getCurrentSiteId(); - const available = await AddonNotifications.isPopupAvailable(options.siteId); - - if (available) { + if (options.onlyPopupNotifications) { return AddonNotifications.getPopupNotifications(notifications.length, options); } - // Fallback to get_messages. We need 2 calls, one for read and the other one for unread. + // Use get_messages. We need 2 calls, one for read and the other one for unread. const unreadFrom = notifications.reduce((total, current) => total + (current.read ? 0 : 1), 0); const unread = await AddonNotifications.getUnreadNotifications(unreadFrom, options); @@ -209,3 +207,10 @@ export type AddonNotificationsPreferencesNotificationFormatted = AddonNotificati export type AddonNotificationsPreferencesProcessorFormatted = AddonNotificationsPreferencesProcessor & { supported?: boolean; // Calculated in the app. Whether the processor is supported in the app. }; + +/** + * Options to pass to getNotifications. + */ +export type AddonNotificationsHelperGetNotificationsOptions = AddonNotificationsGetNotificationsOptions & { + onlyPopupNotifications?: boolean; // Whether to get only popup notifications. +}; diff --git a/src/addons/notifications/services/notifications.ts b/src/addons/notifications/services/notifications.ts index aa4cc92bb..38bd4b982 100644 --- a/src/addons/notifications/services/notifications.ts +++ b/src/addons/notifications/services/notifications.ts @@ -201,7 +201,6 @@ export class AddonNotificationsProvider { * @param offset Position of the first notification to get. * @param options Other options. * @return Promise resolved with notifications and if can load more. - * @since 3.2 */ async getPopupNotifications( offset: number, @@ -277,57 +276,29 @@ export class AddonNotificationsProvider { async getUnreadNotificationsCount(userId?: number, siteId?: string): Promise { const site = await CoreSites.getSite(siteId); - // @since 3.2 - if (site.wsAvailable('message_popup_get_unread_popup_notification_count')) { - userId = userId || site.getUserId(); - const params: AddonNotificationsPopupGetUnreadPopupNotificationCountWSParams = { - useridto: userId, - }; - const preSets: CoreSiteWSPreSets = { - getFromCache: false, - emergencyCache: false, - saveToCache: false, - typeExpected: 'number', - }; + userId = userId || site.getUserId(); + const params: AddonNotificationsPopupGetUnreadPopupNotificationCountWSParams = { + useridto: userId, + }; + const preSets: CoreSiteWSPreSets = { + getFromCache: false, + emergencyCache: false, + saveToCache: false, + typeExpected: 'number', + }; - try { - return await site.read('message_popup_get_unread_popup_notification_count', params, preSets); - } catch { - // Return no messages if the call fails. - return 0; - } - } - - // Fallback call try { - const unread = await this.getUnreadNotifications(0, { limit: AddonNotificationsProvider.LIST_LIMIT, siteId }); - - // The app used to add a + sign if needed, but 3.1 will be dropped soon so it's easier to always return a number. - return unread.length; + return await site.read('message_popup_get_unread_popup_notification_count', params, preSets); } catch { // Return no messages if the call fails. return 0; } } - /** - * Returns whether or not popup WS is available for a certain site. - * - * @param siteId Site ID. If not defined, current site. - * @return Promise resolved with true if available, resolved with false or rejected otherwise. - * @since 3.2 - */ - async isPopupAvailable(siteId?: string): Promise { - const site = await CoreSites.getSite(siteId); - - return site.wsAvailable('message_popup_get_popup_notifications'); - } - /** * Mark all message notification as read. * * @return Resolved when done. - * @since 3.2 */ async markAllNotificationsAsRead(siteId?: string): Promise { const site = await CoreSites.getSite(siteId); @@ -345,7 +316,6 @@ export class AddonNotificationsProvider { * @param notificationId ID of notification to mark as read * @param siteId Site ID. If not defined, current site. * @return Promise resolved when done. - * @since 3.5 */ async markNotificationRead( notificationId: number, @@ -354,17 +324,12 @@ export class AddonNotificationsProvider { const site = await CoreSites.getSite(siteId); - if (site.wsAvailable('core_message_mark_notification_read')) { - const params: CoreMessageMarkNotificationReadWSParams = { - notificationid: notificationId, - timeread: CoreTimeUtils.timestamp(), - }; + const params: CoreMessageMarkNotificationReadWSParams = { + notificationid: notificationId, + timeread: CoreTimeUtils.timestamp(), + }; - return site.write('core_message_mark_notification_read', params); - } else { - // Fallback for versions prior to 3.5. - return AddonMessages.markMessageRead(notificationId, site.id); - } + return site.write('core_message_mark_notification_read', params); } /** @@ -391,36 +356,6 @@ export class AddonNotificationsProvider { await site.invalidateWsCacheForKey(this.getNotificationsCacheKey()); } - /** - * Returns whether or not we can mark all notifications as read. - * - * @return True if enabled, false otherwise. - * @since 3.2 - */ - isMarkAllNotificationsAsReadEnabled(): boolean { - return CoreSites.wsAvailableInCurrentSite('core_message_mark_all_notifications_as_read'); - } - - /** - * Returns whether or not we can count unread notifications precisely. - * - * @return True if enabled, false otherwise. - * @since 3.2 - */ - isPreciseNotificationCountEnabled(): boolean { - return CoreSites.wsAvailableInCurrentSite('message_popup_get_unread_popup_notification_count'); - } - - /** - * Returns whether or not the notification preferences are enabled for the current site. - * - * @return True if enabled, false otherwise. - * @since 3.2 - */ - isNotificationPreferencesEnabled(): boolean { - return CoreSites.wsAvailableInCurrentSite('core_message_get_user_notification_preferences'); - } - } export const AddonNotifications = makeSingleton(AddonNotificationsProvider); diff --git a/src/addons/privatefiles/pages/index/index.ts b/src/addons/privatefiles/pages/index/index.ts index b20ad8ad7..b7a6b0da4 100644 --- a/src/addons/privatefiles/pages/index/index.ts +++ b/src/addons/privatefiles/pages/index/index.ts @@ -146,14 +146,6 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy { * Upload a new file. */ async uploadFile(): Promise { - const canUpload = await AddonPrivateFiles.versionCanUploadFiles(); - - if (!canUpload) { - CoreDomUtils.showAlertTranslated('core.notice', 'addon.privatefiles.erroruploadnotworking'); - - return; - } - if (!CoreApp.isOnline()) { CoreDomUtils.showErrorModal('core.fileuploader.errormustbeonlinetoupload', true); @@ -198,8 +190,7 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy { this.files = await AddonPrivateFiles.getPrivateFiles(); - if (this.showUpload && AddonPrivateFiles.canGetPrivateFilesInfo() && this.userQuota && - this.userQuota > 0) { + if (this.showUpload && this.userQuota && this.userQuota > 0) { // Get the info to calculate the available size. this.filesInfo = await AddonPrivateFiles.getPrivateFilesInfo(); diff --git a/src/addons/privatefiles/services/privatefiles.ts b/src/addons/privatefiles/services/privatefiles.ts index 0af06f08f..49c29eafc 100644 --- a/src/addons/privatefiles/services/privatefiles.ts +++ b/src/addons/privatefiles/services/privatefiles.ts @@ -32,15 +32,6 @@ export class AddonPrivateFilesProvider { static readonly PRIVATE_FILES_COMPONENT = 'mmaFilesMy'; static readonly SITE_FILES_COMPONENT = 'mmaFilesSite'; - /** - * Check if core_user_get_private_files_info WS call is available. - * - * @return Whether the WS is available, false otherwise. - */ - canGetPrivateFilesInfo(): boolean { - return CoreSites.wsAvailableInCurrentSite('core_user_get_private_files_info'); - } - /** * Check if user can view his private files. * @@ -396,19 +387,6 @@ export class AddonPrivateFilesProvider { return site.write('core_user_add_user_private_files', params, preSets); } - /** - * Check the Moodle version in order to check if upload files is working. - * - * @param siteId Site ID. If not defined, use current site. - * @return Promise resolved with true if WS is working, false otherwise. - */ - async versionCanUploadFiles(siteId?: string): Promise { - const site = await CoreSites.getSite(siteId); - - // Upload private files doesn't work for Moodle 3.1.0 due to a bug. - return site.isVersionGreaterEqualThan('3.1.1'); - } - } export const AddonPrivateFiles = makeSingleton(AddonPrivateFilesProvider); diff --git a/src/addons/qtype/ddimageortext/component/ddimageortext.ts b/src/addons/qtype/ddimageortext/component/ddimageortext.ts index 113a500d4..88d011139 100644 --- a/src/addons/qtype/ddimageortext/component/ddimageortext.ts +++ b/src/addons/qtype/ddimageortext/component/ddimageortext.ts @@ -70,7 +70,7 @@ export class AddonQtypeDdImageOrTextComponent extends CoreQuestionBaseComponent this.ddQuestion.readOnly = false; if (this.ddQuestion.initObjects) { - // Moodle version <= 3.5. + // Moodle version = 3.5. if (typeof this.ddQuestion.initObjects.drops != 'undefined') { this.drops = this.ddQuestion.initObjects.drops; } diff --git a/src/addons/qtype/ddmarker/component/ddmarker.ts b/src/addons/qtype/ddmarker/component/ddmarker.ts index 8d4942e8f..cc8611b95 100644 --- a/src/addons/qtype/ddmarker/component/ddmarker.ts +++ b/src/addons/qtype/ddmarker/component/ddmarker.ts @@ -82,7 +82,7 @@ export class AddonQtypeDdMarkerComponent extends CoreQuestionBaseComponent imple this.ddQuestion.readOnly = false; if (this.ddQuestion.initObjects) { - // Moodle version <= 3.5. + // Moodle version = 3.5. if (typeof this.ddQuestion.initObjects.dropzones != 'undefined') { this.dropZones = this.ddQuestion.initObjects.dropzones; } diff --git a/src/core/classes/site.ts b/src/core/classes/site.ts index 8d10c359d..c5a3260f2 100644 --- a/src/core/classes/site.ts +++ b/src/core/classes/site.ts @@ -1764,7 +1764,7 @@ export class CoreSite { * @return Promise resolved with the converted URL. */ async getAutoLoginUrl(url: string, showModal: boolean = true): Promise { - if (!this.privateToken || !this.wsAvailable('tool_mobile_get_autologin_key') || (this.lastAutoLogin && + if (!this.privateToken || (this.lastAutoLogin && CoreTimeUtils.timestamp() - this.lastAutoLogin < CoreConstants.SECONDS_MINUTE * 6)) { // No private token, WS not available or last auto-login was less than 6 minutes ago. Don't change the URL. return url; diff --git a/src/core/directives/external-content.ts b/src/core/directives/external-content.ts index 188a27ee1..4dd8f719f 100644 --- a/src/core/directives/external-content.ts +++ b/src/core/directives/external-content.ts @@ -33,7 +33,7 @@ import { CoreError } from '@classes/errors/error'; * * If a file is downloaded, its URL will be replaced by the local file URL. * - * From v3.5.2 this directive will also download inline styles, so it can be used in any element as long as it has inline styles. + * This directive also downloads inline styles, so it can be used in any element as long as it has inline styles. */ @Directive({ selector: '[core-external-content]', diff --git a/src/core/directives/format-text.ts b/src/core/directives/format-text.ts index cfcdfa2c6..719c1845c 100644 --- a/src/core/directives/format-text.ts +++ b/src/core/directives/format-text.ts @@ -509,8 +509,6 @@ export class CoreFormatTextDirective implements OnChanges { * @return Promise resolved when done. */ protected async treatHTMLElements(div: HTMLElement, site?: CoreSite): Promise { - const canTreatVimeo = site?.isVersionGreaterEqualThan(['3.3.4', '3.4']) || false; - const images = Array.from(div.querySelectorAll('img')); const anchors = Array.from(div.querySelectorAll('a')); const audios = Array.from(div.querySelectorAll('audio')); @@ -561,7 +559,7 @@ export class CoreFormatTextDirective implements OnChanges { }); iframes.forEach((iframe) => { - promises.push(this.treatIframe(iframe, site, canTreatVimeo)); + promises.push(this.treatIframe(iframe, site)); }); svgImages.forEach((image) => { @@ -704,13 +702,8 @@ export class CoreFormatTextDirective implements OnChanges { * * @param iframe Iframe to treat. * @param site Site instance. - * @param canTreatVimeo Whether Vimeo videos can be treated in the site. */ - protected async treatIframe( - iframe: HTMLIFrameElement, - site: CoreSite | undefined, - canTreatVimeo: boolean, - ): Promise { + protected async treatIframe(iframe: HTMLIFrameElement, site: CoreSite | undefined): Promise { const src = iframe.src; const currentSite = CoreSites.getCurrentSite(); @@ -736,7 +729,7 @@ export class CoreFormatTextDirective implements OnChanges { await CoreIframeUtils.fixIframeCookies(src); - if (site && src && canTreatVimeo) { + if (site && src) { // Check if it's a Vimeo video. If it is, use the wsplayer script instead to make restricted videos work. const matches = iframe.src.match(/https?:\/\/player\.vimeo\.com\/video\/([0-9]+)/); if (matches && matches[1]) { diff --git a/src/core/features/comments/services/comments.ts b/src/core/features/comments/services/comments.ts index 1c252e21c..094fab2ff 100644 --- a/src/core/features/comments/services/comments.ts +++ b/src/core/features/comments/services/comments.ts @@ -536,7 +536,7 @@ export type CoreCommentsArea = { canpost: boolean; // Canpost. canview: boolean; // Canview. count: number; // Count. - collapsediconkey: string; // @since 3.3. Collapsediconkey. + collapsediconkey: string; // Collapsediconkey. displaytotalcount: boolean; // Displaytotalcount. displaycancel: boolean; // Displaycancel. fullwidth: boolean; // Fullwidth. 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 191f9fb11..705b9aeb7 100644 --- a/src/core/features/course/components/format/core-course-format.html +++ b/src/core/features/course/components/format/core-course-format.html @@ -177,7 +177,7 @@
+ [loading]="section.isDownloading || section.isCalculating" [canTrustDownload]="true" size="small"> 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 fc93272c2..bbfebb68c 100644 --- a/src/core/features/course/components/module/core-course-module.html +++ b/src/core/features/course/components/module/core-course-module.html @@ -60,7 +60,7 @@
diff --git a/src/core/features/course/components/module/module.ts b/src/core/features/course/components/module/module.ts index 9ae336d9e..5431e5114 100644 --- a/src/core/features/course/components/module/module.ts +++ b/src/core/features/course/components/module/module.ts @@ -69,7 +69,6 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy { @Output() statusChanged = new EventEmitter(); // Notify when the download status changes. downloadStatus?: string; - canCheckUpdates?: boolean; spinner?: boolean; // Whether to display a loading spinner. downloadEnabled?: boolean; // Whether the download of sections and modules is enabled. modNameTranslated = ''; @@ -108,7 +107,6 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy { if (this.module.handlerData.showDownloadButton) { // Listen for changes on this module status, even if download isn't enabled. this.prefetchHandler = CoreCourseModulePrefetchDelegate.getPrefetchHandlerFor(this.module); - this.canCheckUpdates = CoreCourseModulePrefetchDelegate.canCheckUpdates(); this.statusObserver = CoreEvents.on(CoreEvents.PACKAGE_STATUS_CHANGED, (data) => { if (!this.module || data.componentId != this.module.id || !this.prefetchHandler || diff --git a/src/core/features/course/pages/contents/contents.ts b/src/core/features/course/pages/contents/contents.ts index 3bb1ac9fc..2cccc6ecb 100644 --- a/src/core/features/course/pages/contents/contents.ts +++ b/src/core/features/course/pages/contents/contents.ts @@ -322,7 +322,7 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy { protected async loadCourseFormatOptions(): Promise { // Load the course format options when course completion is enabled to show completion progress on sections. - if (!this.course.enablecompletion || !CoreCourses.isGetCoursesByFieldAvailable()) { + if (!this.course.enablecompletion) { return; } diff --git a/src/core/features/course/pages/preview/preview.page.ts b/src/core/features/course/pages/preview/preview.page.ts index 122557ace..b7a6aa5e2 100644 --- a/src/core/features/course/pages/preview/preview.page.ts +++ b/src/core/features/course/pages/preview/preview.page.ts @@ -223,12 +223,9 @@ export class CoreCoursePreviewPage implements OnInit, OnDestroy { if (!CoreSites.getCurrentSite()?.isVersionGreaterEqualThan('3.7')) { try { - const available = await CoreCourses.isGetCoursesByFieldAvailableInSite(); - if (available) { - const course = await CoreCourses.getCourseByField('id', this.course!.id); + const course = await CoreCourses.getCourseByField('id', this.course!.id); - this.course!.customfields = course.customfields; - } + this.course!.customfields = course.customfields; } catch { // Ignore errors. } diff --git a/src/core/features/course/services/course-helper.ts b/src/core/features/course/services/course-helper.ts index be69290b1..14b7f8241 100644 --- a/src/core/features/course/services/course-helper.ts +++ b/src/core/features/course/services/course-helper.ts @@ -36,6 +36,8 @@ import { CoreCourseAnyCourseData, CoreCourseBasicData, CoreCourses, + CoreCourseSearchedData, + CoreEnrolledCourseData, } from '@features/courses/services/courses'; import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '@features/courses/services/courses-helper'; import { CoreArray } from '@singletons/array'; @@ -280,7 +282,7 @@ export class CoreCourseHelperProvider { } sectionWithStatus.downloadStatus = result.status; - sectionWithStatus.canCheckUpdates = CoreCourseModulePrefetchDelegate.canCheckUpdates(); + sectionWithStatus.canCheckUpdates = true; // Set this section data. if (result.status !== CoreConstants.DOWNLOADING) { @@ -342,7 +344,7 @@ export class CoreCourseHelperProvider { if (allSectionsSection) { // Set "All sections" data. allSectionsSection.downloadStatus = allSectionsStatus; - allSectionsSection.canCheckUpdates = CoreCourseModulePrefetchDelegate.canCheckUpdates(); + allSectionsSection.canCheckUpdates = true; allSectionsSection.isDownloading = allSectionsStatus === CoreConstants.DOWNLOADING; } @@ -1126,27 +1128,19 @@ export class CoreCourseHelperProvider { async getCourse( courseId: number, siteId?: string, - ): Promise<{ enrolled: boolean; course: CoreCourseAnyCourseData }> { + ): Promise<{ enrolled: boolean; course: CoreEnrolledCourseData | CoreCourseSearchedData }> { siteId = siteId || CoreSites.getCurrentSiteId(); - let course: CoreCourseAnyCourseData; - // Try with enrolled courses first. try { - course = await CoreCourses.getUserCourse(courseId, false, siteId); + const course = await CoreCourses.getUserCourse(courseId, false, siteId); return ({ enrolled: true, course: course }); } catch { // Not enrolled or an error happened. Try to use another WebService. } - const available = await CoreCourses.isGetCoursesByFieldAvailableInSite(siteId); - - if (available) { - course = await CoreCourses.getCourseByField('id', courseId, siteId); - } else { - course = await CoreCourses.getCourse(courseId, siteId); - } + const course = await CoreCourses.getCourseByField('id', courseId, siteId); return ({ enrolled: false, course: course }); } @@ -1186,7 +1180,7 @@ export class CoreCourseHelperProvider { * @param name Block name to search. * @param siteId Site ID. If not defined, current site. * @return Promise resolved with true if the block exists or false otherwise. - * @since 3.3 + * @since 3.7 */ async hasABlockNamed(courseId: number, name: string, siteId?: string): Promise { try { @@ -1483,9 +1477,6 @@ export class CoreCourseHelperProvider { moduleInfo.statusIcon = CoreConstants.ICON_OUTDATED; break; case CoreConstants.DOWNLOADED: - if (!CoreCourseModulePrefetchDelegate.canCheckUpdates()) { - moduleInfo.statusIcon = CoreConstants.ICON_OUTDATED; - } break; default: moduleInfo.statusIcon = ''; @@ -1739,9 +1730,7 @@ export class CoreCourseHelperProvider { }); // Prefetch other data needed to render the course. - if (CoreCourses.isGetCoursesByFieldAvailable()) { - promises.push(CoreCourses.getCoursesByField('id', course.id)); - } + promises.push(CoreCourses.getCoursesByField('id', course.id)); const sectionWithModules = sections.find((section) => section.modules && section.modules.length > 0); if (!sectionWithModules || typeof sectionWithModules.modules[0].completion == 'undefined') { @@ -1850,7 +1839,7 @@ export class CoreCourseHelperProvider { // Set "All sections" data. section.downloadStatus = allSectionsStatus; - section.canCheckUpdates = CoreCourseModulePrefetchDelegate.canCheckUpdates(); + section.canCheckUpdates = true; section.isDownloading = allSectionsStatus === CoreConstants.DOWNLOADING; } finally { section.isDownloading = false; @@ -2092,7 +2081,7 @@ export type CoreCourseSection = Omit & { */ export type CoreCourseSectionWithStatus = CoreCourseSection & { downloadStatus?: string; // Section status. - canCheckUpdates?: boolean; // Whether can check updates. + canCheckUpdates?: boolean; // Whether can check updates. @deprecated since app 4.0 isDownloading?: boolean; // Whether section is being downloaded. total?: number; // Total of modules being downloaded. count?: number; // Number of downloaded modules. diff --git a/src/core/features/course/services/course-options-delegate.ts b/src/core/features/course/services/course-options-delegate.ts index dc54a21bb..87765a546 100644 --- a/src/core/features/course/services/course-options-delegate.ts +++ b/src/core/features/course/services/course-options-delegate.ts @@ -585,8 +585,7 @@ export class CoreCourseOptionsDelegateService extends CoreDelegate { - if (CoreCourses.canGetAdminAndNavOptions() && - (typeof course.navOptions == 'undefined' || typeof course.admOptions == 'undefined' || refresh)) { + if (typeof course.navOptions == 'undefined' || typeof course.admOptions == 'undefined' || refresh) { const options = await CoreCourses.getCoursesAdminAndNavOptions([course.id]); course.navOptions = options.navOptions[course.id]; diff --git a/src/core/features/course/services/course.ts b/src/core/features/course/services/course.ts index 8aa879d2c..e115afb9d 100644 --- a/src/core/features/course/services/course.ts +++ b/src/core/features/course/services/course.ts @@ -126,7 +126,7 @@ export class CoreCourseProvider { canGetCourseBlocks(site?: CoreSite): boolean { site = site || CoreSites.getCurrentSite(); - return !!site && site.isVersionGreaterEqualThan('3.7') && site.wsAvailable('core_block_get_course_blocks'); + return !!site && site.isVersionGreaterEqualThan('3.7'); } /** @@ -134,12 +134,12 @@ export class CoreCourseProvider { * * @param site Site. If not defined, current site. * @return Whether the site supports requesting stealth modules. - * @since 3.4.6, 3.5.3, 3.6 + * @since 3.5.3, 3.6 */ canRequestStealthModules(site?: CoreSite): boolean { site = site || CoreSites.getCurrentSite(); - return !!site && site.isVersionGreaterEqualThan(['3.4.6', '3.5.3']); + return !!site && site.isVersionGreaterEqualThan('3.5.3'); } /** @@ -538,20 +538,11 @@ export class CoreCourseProvider { /** * Gets a module basic grade info by module ID. * - * If the user does not have permision to manage the activity false is returned. - * * @param moduleId Module ID. * @param siteId Site ID. If not defined, current site. * @return Promise resolved with the module's grade info. */ async getModuleBasicGradeInfo(moduleId: number, siteId?: string): Promise { - const site = await CoreSites.getSite(siteId); - - if (!site || !site.isVersionGreaterEqualThan('3.2')) { - // On 3.1 won't get grading info and will return undefined. See check bellow. - return; - } - const info = await this.getModuleBasicInfo(moduleId, siteId); const grade: CoreCourseModuleGradeInfo = { @@ -568,7 +559,6 @@ export class CoreCourseProvider { typeof grade.advancedgrading != 'undefined' || typeof grade.outcomes != 'undefined' ) { - // On 3.1 won't get grading info and will return undefined. return grade; } @@ -1253,12 +1243,12 @@ export type CoreCourseSummary = { fullname: string; // Fullname. shortname: string; // Shortname. idnumber: string; // Idnumber. - summary: string; // @since 3.3. Summary. - summaryformat: number; // @since 3.3. Summary format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN). - startdate: number; // @since 3.3. Startdate. - enddate: number; // @since 3.3. Enddate. + summary: string; // Summary. + summaryformat: number; // Summary format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN). + startdate: number; // Startdate. + enddate: number; // Enddate. visible: boolean; // @since 3.8. Visible. - fullnamedisplay: string; // @since 3.3. Fullnamedisplay. + fullnamedisplay: string; // Fullnamedisplay. viewurl: string; // Viewurl. courseimage: string; // @since 3.6. Courseimage. progress?: number; // @since 3.6. Progress. @@ -1522,7 +1512,7 @@ export type CoreCourseModuleContentFile = { }; /** - * Course module basic info type. 3.2 onwards. + * Course module basic info type. */ export type CoreCourseModuleGradeInfo = { grade?: number; // Grade (max value or scale id). diff --git a/src/core/features/course/services/handlers/default-format.ts b/src/core/features/course/services/handlers/default-format.ts index e2a8e1e46..c84073a96 100644 --- a/src/core/features/course/services/handlers/default-format.ts +++ b/src/core/features/course/services/handlers/default-format.ts @@ -127,9 +127,6 @@ export class CoreCourseFormatDefaultHandler implements CoreCourseFormatHandler { if ('marker' in course) { // We already have it. marker = course.marker; - } else if (!CoreCourses.isGetCoursesByFieldAvailable()) { - // Cannot get the current section, return all of them. - return sections[0]; } else { // Try to retrieve the marker. const courseData = await CoreUtils.ignoreErrors(CoreCourses.getCourseByField('id', course.id)); diff --git a/src/core/features/course/services/module-prefetch-delegate.ts b/src/core/features/course/services/module-prefetch-delegate.ts index cd2ede92b..ff494e60a 100644 --- a/src/core/features/course/services/module-prefetch-delegate.ts +++ b/src/core/features/course/services/module-prefetch-delegate.ts @@ -80,9 +80,10 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { - if (!this.canCheckUpdates()) { - throw new CoreError('Cannot check course updates.'); - } - // Check if there's already a getCourseUpdates in progress. const id = Md5.hashAsciiStr(courseId + '#' + JSON.stringify(modules)); const siteId = CoreSites.getCurrentSiteId(); @@ -334,10 +328,6 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { - if (!this.canCheckUpdates()) { - throw new CoreError('Cannot check course updates.'); - } - // Get course sections and all their modules. const sections = await CoreCourse.getSections(courseId, false, true, { omitExpires: true }); @@ -558,7 +548,6 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { const handler = this.getPrefetchHandlerFor(module); - const canCheck = this.canCheckUpdates(); if (!handler) { // No handler found, module not downloadable. @@ -572,7 +561,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate(packageId, 'status', true); return { - status: this.determineModuleStatus(module, status || CoreConstants.NOT_DOWNLOADED, canCheck), + status: this.determineModuleStatus(module, status || CoreConstants.NOT_DOWNLOADED), updateStatus: true, }; } @@ -1441,10 +1429,10 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler { * * @param module Module. * @param status The current status. - * @param canCheck Whether the site allows checking for updates. + * @param canCheck Whether the site allows checking for updates. This parameter was deprecated since app 4.0. * @return Status to display. */ - determineStatus?(module: CoreCourseAnyModuleData, status: string, canCheck: boolean): string; + determineStatus?(module: CoreCourseAnyModuleData, status: string, canCheck: true): string; /** * Get the downloaded size of a module. If not defined, we'll use getFiles to calculate it (it can be slow). diff --git a/src/core/features/courses/pages/my-courses/my-courses.ts b/src/core/features/courses/pages/my-courses/my-courses.ts index c7697acb8..576d7e8df 100644 --- a/src/core/features/courses/pages/my-courses/my-courses.ts +++ b/src/core/features/courses/pages/my-courses/my-courses.ts @@ -105,13 +105,11 @@ export class CoreCoursesMyCoursesPage implements OnInit, OnDestroy { await CoreCoursesHelper.loadCoursesExtraInfo(courses); - if (CoreCourses.canGetAdminAndNavOptions()) { - const options = await CoreCourses.getCoursesAdminAndNavOptions(courseIds); - courses.forEach((course) => { - course.navOptions = options.navOptions[course.id]; - course.admOptions = options.admOptions[course.id]; - }); - } + const options = await CoreCourses.getCoursesAdminAndNavOptions(courseIds); + courses.forEach((course) => { + course.navOptions = options.navOptions[course.id]; + course.admOptions = options.admOptions[course.id]; + }); this.courses = courses; this.filteredCourses = this.courses; diff --git a/src/core/features/courses/services/courses-helper.ts b/src/core/features/courses/services/courses-helper.ts index 158cf018d..f5e1aaec5 100644 --- a/src/core/features/courses/services/courses-helper.ts +++ b/src/core/features/courses/services/courses-helper.ts @@ -109,8 +109,7 @@ export class CoreCoursesHelperProvider { return; })); - if (CoreCourses.isGetCoursesByFieldAvailable() && (loadCategoryNames || - (typeof courses[0].overviewfiles == 'undefined' && typeof courses[0].displayname == 'undefined'))) { + if (loadCategoryNames || (courses[0].overviewfiles === undefined && courses[0].displayname === undefined)) { const courseIds = courses.map((course) => course.id).join(','); courseInfoAvailable = true; @@ -196,17 +195,15 @@ export class CoreCoursesHelperProvider { const promises: Promise[] = []; const courseIds = courses.map((course) => course.id); - if (CoreCourses.canGetAdminAndNavOptions()) { - // Load course options of the course. - promises.push(CoreCourses.getCoursesAdminAndNavOptions(courseIds).then((options) => { - courses.forEach((course) => { - course.navOptions = options.navOptions[course.id]; - course.admOptions = options.admOptions[course.id]; - }); + // Load course options of the course. + promises.push(CoreCourses.getCoursesAdminAndNavOptions(courseIds).then((options) => { + courses.forEach((course) => { + course.navOptions = options.navOptions[course.id]; + course.admOptions = options.admOptions[course.id]; + }); - return; - })); - } + return; + })); promises.push(this.loadCoursesExtraInfo(courses, loadCategoryNames)); diff --git a/src/core/features/courses/services/courses.ts b/src/core/features/courses/services/courses.ts index 1af2c4d65..f16b0e41a 100644 --- a/src/core/features/courses/services/courses.ts +++ b/src/core/features/courses/services/courses.ts @@ -72,10 +72,10 @@ export class CoreCoursesProvider { * Whether current site supports getting course options. * * @return Whether current site supports getting course options. + * @deprecated since app 4.0 */ canGetAdminAndNavOptions(): boolean { - return CoreSites.wsAvailableInCurrentSite('core_course_get_user_navigation_options') && - CoreSites.wsAvailableInCurrentSite('core_course_get_user_administration_options'); + return true; } /** @@ -461,7 +461,6 @@ export class CoreCoursesProvider { * @param value The value to match. * @param siteId Site ID. If not defined, use current site. * @return Promise resolved with the first course. - * @since 3.2 */ async getCourseByField(field?: string, value?: string | number, siteId?: string): Promise { const courses = await this.getCoursesByField(field, value, siteId); @@ -485,7 +484,6 @@ export class CoreCoursesProvider { * @param value The value to match. * @param siteId Site ID. If not defined, use current site. * @return Promise resolved with the courses. - * @since 3.2 */ async getCoursesByField( field: string = '', @@ -593,27 +591,21 @@ export class CoreCoursesProvider { /** * Check if get courses by field WS is available in a certain site. * - * @param site Site to check. * @return Whether get courses by field is available. - * @since 3.2 + * @deprecated since app 4.0 */ - isGetCoursesByFieldAvailable(site?: CoreSite): boolean { - site = site || CoreSites.getCurrentSite(); - - return !!site && site.wsAvailable('core_course_get_courses_by_field'); + isGetCoursesByFieldAvailable(): boolean { + return true; } /** * Check if get courses by field WS is available in a certain site, by site ID. * - * @param siteId Site ID. If not defined, current site. * @return Promise resolved with boolean: whether get courses by field is available. - * @since 3.2 + * @deprecated since app 4.0 */ - async isGetCoursesByFieldAvailableInSite(siteId?: string): Promise { - const site = await CoreSites.getSite(siteId); - - return this.isGetCoursesByFieldAvailable(site); + async isGetCoursesByFieldAvailableInSite(): Promise { + return true; } /** @@ -1069,8 +1061,7 @@ export class CoreCoursesProvider { * Check if WS to retrieve guest enrolment data is available. * * @return Whether guest WS is available. - * @since 3.1 - * @deprecated Will always return true since it's available since 3.1. + * @deprecated since app 3.9.5 */ isGuestWSAvailable(): boolean { return true; diff --git a/src/core/features/courses/services/handlers/courses-index-link.ts b/src/core/features/courses/services/handlers/courses-index-link.ts index 1f273fa87..500287239 100644 --- a/src/core/features/courses/services/handlers/courses-index-link.ts +++ b/src/core/features/courses/services/handlers/courses-index-link.ts @@ -18,7 +18,6 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreNavigator } from '@services/navigator'; import { makeSingleton } from '@singletons'; -import { CoreCourses } from '../courses'; import { CoreCoursesMyCoursesHomeHandlerService } from './my-courses-home'; /** @@ -44,15 +43,10 @@ export class CoreCoursesIndexLinkHandlerService extends CoreContentLinksHandlerB action: (siteId): void => { let pageName = CoreCoursesMyCoursesHomeHandlerService.PAGE_NAME; - if (CoreCourses.isGetCoursesByFieldAvailable()) { - if (params.categoryid) { - pageName += '/categories/' + params.categoryid; - } else { - pageName += '/all'; - } + if (params.categoryid) { + pageName += '/categories/' + params.categoryid; } else { - // By default, go to My Courses. - pageName += '/my'; + pageName += '/all'; } CoreNavigator.navigateToSitePath(pageName, { siteId }); diff --git a/src/core/features/filter/services/filter.ts b/src/core/features/filter/services/filter.ts index b5139a92f..4b7dd89ca 100644 --- a/src/core/features/filter/services/filter.ts +++ b/src/core/features/filter/services/filter.ts @@ -63,27 +63,21 @@ export class CoreFilterProvider { /** * Returns whether or not WS get available in context is available. * - * @param siteId Site ID. If not defined, current site. * @return Promise resolved with true if ws is available, false otherwise. - * @since 3.4 + * @deprecated since app 4.0 */ - async canGetAvailableInContext(siteId?: string): Promise { - const site = await CoreSites.getSite(siteId); - - return this.canGetAvailableInContextInSite(site); + async canGetAvailableInContext(): Promise { + return true; } /** * Returns whether or not WS get available in context is available in a certain site. * - * @param site Site. If not defined, current site. * @return Promise resolved with true if ws is available, false otherwise. - * @since 3.4 + * @deprecated since app 4.0 */ - canGetAvailableInContextInSite(site?: CoreSite): boolean { - site = site || CoreSites.getCurrentSite(); - - return !!(site?.wsAvailable('core_filters_get_available_in_context')); + canGetAvailableInContextInSite(): boolean { + return true; } /** @@ -93,10 +87,9 @@ export class CoreFilterProvider { * @return Promise resolved with boolean: whethe can get filters. */ async canGetFilters(siteId?: string): Promise { - const wsAvailable = await this.canGetAvailableInContext(siteId); const disabled = await this.checkFiltersDisabled(siteId); - return wsAvailable && !disabled; + return !disabled; } /** @@ -106,7 +99,7 @@ export class CoreFilterProvider { * @return Promise resolved with boolean: whethe can get filters. */ canGetFiltersInSite(site?: CoreSite): boolean { - return this.canGetAvailableInContextInSite(site) && this.checkFiltersDisabledInSite(site); + return this.checkFiltersDisabledInSite(site); } /** diff --git a/src/core/features/grades/services/grades-helper.ts b/src/core/features/grades/services/grades-helper.ts index 809566334..3d003415b 100644 --- a/src/core/features/grades/services/grades-helper.ts +++ b/src/core/features/grades/services/grades-helper.ts @@ -231,11 +231,7 @@ export class CoreGradesHelperProvider { // If any course wasn't found, make a network request. if (coursesWereMissing) { - const coursesPromise = CoreCourses.isGetCoursesByFieldAvailable() - ? CoreCourses.getCoursesByField('ids', grades.map((grade) => grade.courseid).join(',')) - : CoreCourses.getUserCourses(undefined, undefined, CoreSitesReadingStrategy.PREFER_NETWORK); - - const courses = await coursesPromise; + const courses = await CoreCourses.getCoursesByField('ids', grades.map((grade) => grade.courseid).join(',')); const coursesMap = CoreUtils.arrayToObject(courses as Record[], 'id') as Record | @@ -337,18 +333,9 @@ export class CoreGradesHelperProvider { groupId?: number, siteId?: string, ignoreCache: boolean = false, - ): Promise { + ): Promise { const grades = await CoreGrades.getGradeItems(courseId, userId, groupId, siteId, ignoreCache); - if (!grades) { - throw new CoreError('Couldn\'t get grade module items'); - } - - if ('tabledata' in grades) { - // 3.1 Table format. - return this.getModuleGradesTableRows(grades, moduleId); - } - return grades.filter((item) => item.cmid == moduleId).map((item) => this.formatGradeItem(item)); } @@ -419,6 +406,7 @@ export class CoreGradesHelperProvider { * @param table JSON object representing a table with data. * @param moduleId Grade Object identifier. * @return Formatted HTML table. + * @deprecated since app 4.0 */ getModuleGradesTableRows(table: CoreGradesTable, moduleId: number): CoreGradesFormattedRow[] { if (!table.tabledata) { @@ -470,14 +458,7 @@ export class CoreGradesHelperProvider { throw new CoreError('Invalid moduleId'); } - // Try to open the module grade directly. Check if it's possible. - const grades = await CoreGrades.isGradeItemsAvailable(siteId); - - if (!grades) { - throw new CoreError('No grades found.'); - } - - // Can get grades. Do it. + // Try to open the module grade directly. const items = await CoreGrades.getGradeItems(courseId, userId, undefined, siteId); // Find the item of the module. @@ -543,11 +524,7 @@ export class CoreGradesHelperProvider { const site = await CoreSites.getSite(siteId); userId = userId || site.getUserId(); - const enabled = await CoreGrades.isGradeItemsAvailable(siteId); - - return enabled - ? CoreGrades.invalidateCourseGradesItemsData(courseId, userId, groupId, siteId) - : CoreGrades.invalidateCourseGradesData(courseId, userId, siteId); + return CoreGrades.invalidateCourseGradesItemsData(courseId, userId, groupId, siteId); } /** diff --git a/src/core/features/grades/services/grades.ts b/src/core/features/grades/services/grades.ts index ad28b605e..00280957d 100644 --- a/src/core/features/grades/services/grades.ts +++ b/src/core/features/grades/services/grades.ts @@ -87,7 +87,6 @@ export class CoreGradesProvider { /** * Get the grade items for a certain module. Keep in mind that may have more than one item to include outcomes and scales. - * Fallback function only used if 'gradereport_user_get_grade_items' WS is not available Moodle < 3.2. * * @param courseId ID of the course to get the grades from. * @param userId ID of the user to get the grades from. If not defined use site's current user. @@ -102,26 +101,14 @@ export class CoreGradesProvider { groupId?: number, siteId?: string, ignoreCache: boolean = false, - ): Promise { + ): Promise { siteId = siteId || CoreSites.getCurrentSiteId(); const site = await CoreSites.getSite(siteId); userId = userId || site.getUserId(); - const enabled = await this.isGradeItemsAvailable(siteId); - - if (enabled) { - try { - const items = await this.getCourseGradesItems(courseId, userId, groupId, siteId, ignoreCache); - - return items; - } catch { - // Ignore while solving MDL-57255 (fixed on 3.2.1) - } - } - - return this.getCourseGradesTable(courseId, userId, siteId, ignoreCache); + return await this.getCourseGradesItems(courseId, userId, groupId, siteId, ignoreCache); } /** @@ -307,16 +294,11 @@ export class CoreGradesProvider { * * @param siteId Site ID. If not defined, current site. * @return Resolve with true if plugin is enabled, false otherwise. - * @since Moodle 3.2 */ async isCourseGradesEnabled(siteId?: string): Promise { const site = await CoreSites.getSite(siteId); - if (!site.wsAvailable('gradereport_overview_get_course_grades')) { - return false; - } - - // Now check that the configurable mygradesurl is pointing to the gradereport_overview plugin. + // Check that the configurable mygradesurl is pointing to the gradereport_overview plugin. const url = site.getStoredConfig('mygradesurl') || ''; return url.indexOf('/grade/report/overview/') !== -1; @@ -344,12 +326,10 @@ export class CoreGradesProvider { * * @param siteId Site ID. If not defined, current site. * @return True if ws is available, false otherwise. - * @since Moodle 3.2 + * @deprecated since app 4.0 */ - async isGradeItemsAvailable(siteId?: string): Promise { - const site = await CoreSites.getSite(siteId); - - return site.wsAvailable('gradereport_user_get_grade_items'); + async isGradeItemsAvailable(): Promise { + return true; } /** diff --git a/src/core/features/login/pages/site-policy/site-policy.ts b/src/core/features/login/pages/site-policy/site-policy.ts index f4804322b..d58ee4c4e 100644 --- a/src/core/features/login/pages/site-policy/site-policy.ts +++ b/src/core/features/login/pages/site-policy/site-policy.ts @@ -55,8 +55,8 @@ export class CoreLoginSitePolicyPage implements OnInit { const currentSiteId = this.currentSite.id; this.siteId = this.siteId || currentSiteId; - if (this.siteId != currentSiteId || !this.currentSite.wsAvailable('core_user_agree_site_policy')) { - // Not current site or WS not available, stop. + if (this.siteId != currentSiteId) { + // Not current site, stop. this.cancel(); return; diff --git a/src/core/features/login/services/login-helper.ts b/src/core/features/login/services/login-helper.ts index afa90857d..91d95ff1f 100644 --- a/src/core/features/login/services/login-helper.ts +++ b/src/core/features/login/services/login-helper.ts @@ -1127,11 +1127,6 @@ export class CoreLoginHelperProvider { return; } - if (!CoreSites.wsAvailableInCurrentSite('core_user_agree_site_policy')) { - // WS not available, stop. - return; - } - // If current page is already site policy, stop. if (CoreNavigator.isCurrent('/login/sitepolicy')) { return; diff --git a/src/core/features/rating/components/rate/rate.ts b/src/core/features/rating/components/rate/rate.ts index 07f7ee309..55f489c7f 100644 --- a/src/core/features/rating/components/rate/rate.ts +++ b/src/core/features/rating/components/rate/rate.ts @@ -75,7 +75,7 @@ export class CoreRatingRateComponent implements OnChanges, OnDestroy { this.item = (this.ratingInfo.ratings || []).find((rating) => rating.itemid == this.itemId); this.scale = (this.ratingInfo.scales || []).find((scale) => scale.id == this.scaleId); - if (!this.item || !this.scale || !CoreRating.isAddRatingWSAvailable()) { + if (!this.item || !this.scale) { this.item = undefined; return; diff --git a/src/core/features/rating/services/rating.ts b/src/core/features/rating/services/rating.ts index 25642d32a..482ebcb5a 100644 --- a/src/core/features/rating/services/rating.ts +++ b/src/core/features/rating/services/rating.ts @@ -47,11 +47,11 @@ export class CoreRatingProvider { /** * Returns whether the web serivce to add ratings is available. * - * @return If WS is abalaible. - * @since 3.2 + * @return If WS is available. + * @deprecated since app 4.0 */ isAddRatingWSAvailable(): boolean { - return CoreSites.wsAvailableInCurrentSite('core_rating_add_rating'); + return true; } /** @@ -70,7 +70,6 @@ export class CoreRatingProvider { * @param aggregateMethod Aggregate method. * @param siteId Site ID. If not defined, current site. * @return Promise resolved with the aggregated rating or void if stored offline. - * @since 3.2 */ async addRating( component: string, @@ -162,7 +161,6 @@ export class CoreRatingProvider { * @param aggregateMethod Aggregate method. * @param siteId Site ID. If not defined, current site. * @return Promise resolved with the aggregated rating. - * @since 3.2 */ async addRatingOnline( component: string, diff --git a/src/core/features/sitehome/services/sitehome.ts b/src/core/features/sitehome/services/sitehome.ts index 4d45d10d8..8cb52346d 100644 --- a/src/core/features/sitehome/services/sitehome.ts +++ b/src/core/features/sitehome/services/sitehome.ts @@ -171,8 +171,8 @@ export class CoreSiteHomeProvider { case FrontPageItemNames['LIST_OF_CATEGORIES']: case FrontPageItemNames['COMBO_LIST']: case FrontPageItemNames['LIST_OF_COURSE']: - add = CoreCourses.isGetCoursesByFieldAvailable(); - if (add && itemNumber == FrontPageItemNames['COMBO_LIST']) { + add = true; + if (itemNumber == FrontPageItemNames['COMBO_LIST']) { itemNumber = FrontPageItemNames['LIST_OF_CATEGORIES']; } break; diff --git a/src/core/features/siteplugins/services/siteplugins.ts b/src/core/features/siteplugins/services/siteplugins.ts index e0aa2e9d5..984c8cfe5 100644 --- a/src/core/features/siteplugins/services/siteplugins.ts +++ b/src/core/features/siteplugins/services/siteplugins.ts @@ -292,11 +292,6 @@ export class CoreSitePluginsProvider { async getPlugins(siteId?: string): Promise { const site = await CoreSites.getSite(siteId); - if (!CoreSitePlugins.isGetContentAvailable(site)) { - // Cannot load site plugins, so there's no point to fetch them. - return []; - } - // Get the list of plugins. Try not to use cache. const data = await site.read( 'tool_mobile_get_plugins_supporting_mobile', @@ -371,12 +366,10 @@ export class CoreSitePluginsProvider { /** * Check if the get content WS is available. * - * @param site The site to check. If not defined, current site. + * @deprecated since app 4.0 */ - isGetContentAvailable(site?: CoreSite): boolean { - site = site || CoreSites.getCurrentSite(); - - return !!site?.wsAvailable('tool_mobile_get_content'); + isGetContentAvailable(): boolean { + return true; } /** diff --git a/src/core/features/tag/services/tag.ts b/src/core/features/tag/services/tag.ts index 4d1d6bd77..a4e3f6128 100644 --- a/src/core/features/tag/services/tag.ts +++ b/src/core/features/tag/services/tag.ts @@ -47,6 +47,7 @@ export class CoreTagProvider { * * @param site Site. If not defined, use current site. * @return True if available. + * @since 3.7 */ areTagsAvailableInSite(site?: CoreSite): boolean { site = site || CoreSites.getCurrentSite(); diff --git a/src/core/features/user/pages/profile/profile.page.ts b/src/core/features/user/pages/profile/profile.page.ts index f40c7a053..081bfbf72 100644 --- a/src/core/features/user/pages/profile/profile.page.ts +++ b/src/core/features/user/pages/profile/profile.page.ts @@ -96,7 +96,6 @@ export class CoreUserProfilePage implements OnInit, OnDestroy { (!this.courseId || this.courseId == this.site.getSiteHomeId()) && this.userId == this.site.getUserId() && this.site.canUploadFiles() && - CoreUser.canUpdatePictureInSite(this.site) && !CoreUser.isUpdatePictureDisabledInSite(this.site); try { diff --git a/src/core/features/user/services/user-delegate.ts b/src/core/features/user/services/user-delegate.ts index 38c11a9c3..5901fa17d 100644 --- a/src/core/features/user/services/user-delegate.ts +++ b/src/core/features/user/services/user-delegate.ts @@ -270,22 +270,17 @@ export class CoreUserDelegateService extends CoreDelegate { - let navOptions: CoreCourseUserAdminOrNavOptionIndexed | undefined; - let admOptions: CoreCourseUserAdminOrNavOptionIndexed | undefined; + // Get course options. + const courses = await CoreCourses.getUserCourses(true); + const courseIds = courses.map((course) => course.id); - if (CoreCourses.canGetAdminAndNavOptions()) { - // Get course options. - const courses = await CoreCourses.getUserCourses(true); - const courseIds = courses.map((course) => course.id); + const options = await CoreCourses.getCoursesAdminAndNavOptions(courseIds); - const options = await CoreCourses.getCoursesAdminAndNavOptions(courseIds); + // For backwards compatibility we don't modify the courseId. + const courseIdForOptions = courseId || CoreSites.getCurrentSiteHomeId(); - // For backwards compatibility we don't modify the courseId. - const courseIdForOptions = courseId || CoreSites.getCurrentSiteHomeId(); - - navOptions = options.navOptions[courseIdForOptions]; - admOptions = options.admOptions[courseIdForOptions]; - } + const navOptions = options.navOptions[courseIdForOptions]; + const admOptions = options.admOptions[courseIdForOptions]; const userData = this.userHandlers[user.id]; userData.handlers = []; diff --git a/src/core/features/user/services/user.ts b/src/core/features/user/services/user.ts index 6dfc08bfa..23cf37c5b 100644 --- a/src/core/features/user/services/user.ts +++ b/src/core/features/user/services/user.ts @@ -110,27 +110,21 @@ export class CoreUserProvider { /** * Check if WS to update profile picture is available in site. * - * @param siteId Site ID. If not defined, current site. * @return Promise resolved with boolean: whether it's available. - * @since 3.2 + * @deprecated since app 4.0 */ - async canUpdatePicture(siteId?: string): Promise { - const site = await CoreSites.getSite(siteId); - - return this.canUpdatePictureInSite(site); + async canUpdatePicture(): Promise { + return true; } /** * Check if WS to search participants is available in site. * - * @param site Site. If not defined, current site. * @return Whether it's available. - * @since 3.2 + * @deprecated since app 4.0 */ - canUpdatePictureInSite(site?: CoreSite): boolean { - site = site || CoreSites.getCurrentSite(); - - return !!site?.wsAvailable('core_user_update_picture'); + canUpdatePictureInSite(): boolean { + return true; } /** diff --git a/src/core/services/sites.ts b/src/core/services/sites.ts index 25dc84381..ee1b5c434 100644 --- a/src/core/services/sites.ts +++ b/src/core/services/sites.ts @@ -1481,11 +1481,6 @@ export class CoreSitesProvider { * @return Promise resolved with config if available. */ protected async getSiteConfig(site: CoreSite): Promise { - if (!site.wsAvailable('tool_mobile_get_config')) { - // WS not available, cannot get config. - return; - } - return await site.getConfig(undefined, true); }