2
0
Fork 0

Merge pull request #4121 from crazyserver/MOBILE-4616

Mobile 4616 Solve lots of circular dependencies
main
Dani Palou 2024-07-15 13:36:27 +02:00 committed by GitHub
commit 41879a3526
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
292 changed files with 2153 additions and 1480 deletions

View File

@ -17,7 +17,7 @@ import { CoreBlockHandlerData } from '@features/block/services/block-delegate';
import { CoreBlockOnlyTitleComponent } from '@features/block/components/only-title-block/only-title-block'; import { CoreBlockOnlyTitleComponent } from '@features/block/components/only-title-block/only-title-block';
import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler'; import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/competency.module'; import { ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/constants';
/** /**
* Block handler. * Block handler.

View File

@ -14,7 +14,7 @@
import { Params } from '@angular/router'; import { Params } from '@angular/router';
import { CoreRoutedItemsManagerSource } from '@classes/items-management/routed-items-manager-source'; import { CoreRoutedItemsManagerSource } from '@classes/items-management/routed-items-manager-source';
import { ADDON_COMPETENCY_COMPETENCIES_PAGE } from '../competency.module'; import { ADDON_COMPETENCY_COMPETENCIES_PAGE } from '../constants';
import { AddonCompetency, AddonCompetencyPlan, AddonCompetencyProvider } from '../services/competency'; import { AddonCompetency, AddonCompetencyPlan, AddonCompetencyProvider } from '../services/competency';
import { AddonCompetencyHelper } from '../services/competency-helper'; import { AddonCompetencyHelper } from '../services/competency-helper';
import { CoreIonicColorNames } from '@singletons/colors'; import { CoreIonicColorNames } from '@singletons/colors';

View File

@ -17,7 +17,7 @@ import { RouterModule, Routes } from '@angular/router';
import { AddonCompetencyCompetencyPage } from './pages/competency/competency.page'; import { AddonCompetencyCompetencyPage } from './pages/competency/competency.page';
import { AddonCompetencyCompetencySummaryPage } from './pages/competencysummary/competencysummary.page'; import { AddonCompetencyCompetencySummaryPage } from './pages/competencysummary/competencysummary.page';
import { ADDON_COMPETENCY_SUMMARY_PAGE } from './competency.module'; import { ADDON_COMPETENCY_SUMMARY_PAGE } from './constants';
import { AddonCompetencyCompetencyPageModule } from './pages/competency/competency.module'; import { AddonCompetencyCompetencyPageModule } from './pages/competency/competency.module';
import { AddonCompetencyCompetencySummaryPageModule } from './pages/competencysummary/competencysummary.module'; import { AddonCompetencyCompetencySummaryPageModule } from './pages/competencysummary/competencysummary.module';
import { AddonCompetencyCourseCompetenciesPage } from './pages/coursecompetencies/coursecompetencies.page'; import { AddonCompetencyCourseCompetenciesPage } from './pages/coursecompetencies/coursecompetencies.page';

View File

@ -22,7 +22,7 @@ import { AddonCompetencyPlanPage } from './pages/plan/plan';
import { AddonCompetencyPlanListPage } from './pages/planlist/planlist'; import { AddonCompetencyPlanListPage } from './pages/planlist/planlist';
import { AddonCompetencyCompetencyPage } from './pages/competency/competency.page'; import { AddonCompetencyCompetencyPage } from './pages/competency/competency.page';
import { AddonCompetencyCompetencySummaryPage } from './pages/competencysummary/competencysummary.page'; import { AddonCompetencyCompetencySummaryPage } from './pages/competencysummary/competencysummary.page';
import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_SUMMARY_PAGE } from './competency.module'; import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_SUMMARY_PAGE } from './constants';
import { AddonCompetencyCompetencyPageModule } from './pages/competency/competency.module'; import { AddonCompetencyCompetencyPageModule } from './pages/competency/competency.module';
import { AddonCompetencyCompetencySummaryPageModule } from './pages/competencysummary/competencysummary.module'; import { AddonCompetencyCompetencySummaryPageModule } from './pages/competencysummary/competencysummary.module';
import { AddonCompetencyCompetenciesPage } from './pages/competencies/competencies.page'; import { AddonCompetencyCompetenciesPage } from './pages/competencies/competencies.page';

View File

@ -27,8 +27,9 @@ import { AddonCompetencyUserHandler } from './services/handlers/user';
import { Routes } from '@angular/router'; import { Routes } from '@angular/router';
import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module'; import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module';
import { CoreCourseIndexRoutingModule } from '@features/course/course-routing.module'; import { CoreCourseIndexRoutingModule } from '@features/course/course-routing.module';
import { COURSE_PAGE_NAME } from '@features/course/course.module'; import { PARTICIPANTS_PAGE_NAME } from '@features/user/constants';
import { PARTICIPANTS_PAGE_NAME } from '@features/user/user.module'; import { COURSE_PAGE_NAME } from '@features/course/constants';
import { ADDON_COMPETENCY_LEARNING_PLANS_PAGE, ADDON_COMPETENCY_COMPETENCIES_PAGE } from './constants';
/** /**
* Get competency services. * Get competency services.
@ -45,10 +46,6 @@ export async function getCompetencyServices(): Promise<Type<unknown>[]> {
]; ];
} }
export const ADDON_COMPETENCY_LEARNING_PLANS_PAGE = 'learning-plans';
export const ADDON_COMPETENCY_COMPETENCIES_PAGE = 'competencies';
export const ADDON_COMPETENCY_SUMMARY_PAGE = 'summary';
const mainMenuChildrenRoutes: Routes = [ const mainMenuChildrenRoutes: Routes = [
{ {
path: ADDON_COMPETENCY_LEARNING_PLANS_PAGE, path: ADDON_COMPETENCY_LEARNING_PLANS_PAGE,

View File

@ -0,0 +1,17 @@
// (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.
export const ADDON_COMPETENCY_LEARNING_PLANS_PAGE = 'learning-plans';
export const ADDON_COMPETENCY_COMPETENCIES_PAGE = 'competencies';
export const ADDON_COMPETENCY_SUMMARY_PAGE = 'summary';

View File

@ -32,7 +32,7 @@ import {
import { CoreNavigator } from '@services/navigator'; import { CoreNavigator } from '@services/navigator';
import { ContextLevel } from '@/core/constants'; import { ContextLevel } from '@/core/constants';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { ADDON_COMPETENCY_SUMMARY_PAGE } from '@addons/competency/competency.module'; import { ADDON_COMPETENCY_SUMMARY_PAGE } from '@addons/competency/constants';
import { CoreSwipeNavigationItemsManager } from '@classes/items-management/swipe-navigation-items-manager'; import { CoreSwipeNavigationItemsManager } from '@classes/items-management/swipe-navigation-items-manager';
import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker'; import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker';
import { AddonCompetencyPlanCompetenciesSource } from '@addons/competency/classes/competency-plan-competencies-source'; import { AddonCompetencyPlanCompetenciesSource } from '@addons/competency/classes/competency-plan-competencies-source';

View File

@ -18,7 +18,7 @@ import { AddonCompetencySummary, AddonCompetency } from '@addons/competency/serv
import { CoreNavigator } from '@services/navigator'; import { CoreNavigator } from '@services/navigator';
import { CoreDomUtils } from '@services/utils/dom'; import { CoreDomUtils } from '@services/utils/dom';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { ADDON_COMPETENCY_SUMMARY_PAGE } from '@addons/competency/competency.module'; import { ADDON_COMPETENCY_SUMMARY_PAGE } from '@addons/competency/constants';
import { CoreTime } from '@singletons/time'; import { CoreTime } from '@singletons/time';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';

View File

@ -21,7 +21,7 @@ import { CoreUserProfile } from '@features/user/services/user';
import { CoreNavigator } from '@services/navigator'; import { CoreNavigator } from '@services/navigator';
import { CoreDomUtils } from '@services/utils/dom'; import { CoreDomUtils } from '@services/utils/dom';
import { ContextLevel } from '@/core/constants'; import { ContextLevel } from '@/core/constants';
import { ADDON_COMPETENCY_SUMMARY_PAGE } from '@addons/competency/competency.module'; import { ADDON_COMPETENCY_SUMMARY_PAGE } from '@addons/competency/constants';
import { CoreListItemsManager } from '@classes/items-management/list-items-manager'; import { CoreListItemsManager } from '@classes/items-management/list-items-manager';
import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker'; import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker';
import { AddonCompetencyCourseCompetenciesSource } from '@addons/competency/classes/competency-course-competencies-source'; import { AddonCompetencyCourseCompetenciesSource } from '@addons/competency/classes/competency-course-competencies-source';

View File

@ -12,11 +12,11 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/competency.module'; import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/constants';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
import { COURSE_PAGE_NAME } from '@features/course/course.module'; import { COURSE_PAGE_NAME } from '@features/course/constants';
import { CoreNavigator } from '@services/navigator'; import { CoreNavigator } from '@services/navigator';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonCompetency } from '../competency'; import { AddonCompetency } from '../competency';

View File

@ -24,7 +24,7 @@ import { AddonCompetency } from '../competency';
import { CoreCourseAnyCourseData, CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses'; import { CoreCourseAnyCourseData, CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses';
import { CoreFilterHelper } from '@features/filter/services/filter-helper'; import { CoreFilterHelper } from '@features/filter/services/filter-helper';
import { ContextLevel } from '@/core/constants'; import { ContextLevel } from '@/core/constants';
import { ADDON_COMPETENCY_COMPETENCIES_PAGE } from '@addons/competency/competency.module'; import { ADDON_COMPETENCY_COMPETENCIES_PAGE } from '@addons/competency/constants';
/** /**
* Course nav handler. * Course nav handler.

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/competency.module'; import { ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/constants';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/competency.module'; import { ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/constants';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';

View File

@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/competency.module'; import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/constants';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { COURSE_PAGE_NAME } from '@features/course/course.module'; import { COURSE_PAGE_NAME } from '@features/course/constants';
import { CorePushNotificationsClickHandler } from '@features/pushnotifications/services/push-delegate'; import { CorePushNotificationsClickHandler } from '@features/pushnotifications/services/push-delegate';
import { CorePushNotificationsNotificationBasicData } from '@features/pushnotifications/services/pushnotifications'; import { CorePushNotificationsNotificationBasicData } from '@features/pushnotifications/services/pushnotifications';
import { CoreNavigator } from '@services/navigator'; import { CoreNavigator } from '@services/navigator';

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_SUMMARY_PAGE } from '@addons/competency/competency.module'; import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_SUMMARY_PAGE } from '@addons/competency/constants';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';

View File

@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/competency.module'; import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_LEARNING_PLANS_PAGE } from '@addons/competency/constants';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { COURSE_PAGE_NAME } from '@features/course/course.module'; import { COURSE_PAGE_NAME } from '@features/course/constants';
import { CoreUserProfile } from '@features/user/services/user'; import { CoreUserProfile } from '@features/user/services/user';
import { import {
CoreUserProfileHandler, CoreUserProfileHandler,
@ -22,7 +22,7 @@ import {
CoreUserProfileHandlerData, CoreUserProfileHandlerData,
CoreUserDelegateContext, CoreUserDelegateContext,
} from '@features/user/services/user-delegate'; } from '@features/user/services/user-delegate';
import { PARTICIPANTS_PAGE_NAME } from '@features/user/user.module'; import { PARTICIPANTS_PAGE_NAME } from '@features/user/constants';
import { CoreNavigator } from '@services/navigator'; import { CoreNavigator } from '@services/navigator';
import { CoreSites } from '@services/sites'; import { CoreSites } from '@services/sites';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';

View File

@ -22,13 +22,13 @@ import {
AddonMessages, AddonMessages,
} from '../../services/messages'; } from '../../services/messages';
import { CoreDomUtils } from '@services/utils/dom'; import { CoreDomUtils } from '@services/utils/dom';
import { CoreApp } from '@services/app';
import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Translate } from '@singletons'; import { Translate } from '@singletons';
import { CoreScreen } from '@services/screen'; import { CoreScreen } from '@services/screen';
import { CoreNavigator } from '@services/navigator'; import { CoreNavigator } from '@services/navigator';
import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { CoreSplitViewComponent } from '@components/split-view/split-view';
import { CoreKeyboard } from '@singletons/keyboard';
/** /**
* Page that displays the list of contacts. * Page that displays the list of contacts.
@ -205,15 +205,17 @@ export class AddonMessagesContacts35Page implements OnInit, OnDestroy {
* @param query Text to search for. * @param query Text to search for.
* @returns Resolved when done. * @returns Resolved when done.
*/ */
search(query: string): Promise<void> { async search(query: string): Promise<void> {
CoreApp.closeKeyboard(); CoreKeyboard.close();
this.loaded = false; this.loaded = false;
this.loadingMessage = this.searchingMessages; this.loadingMessage = this.searchingMessages;
return this.performSearch(query).finally(() => { try {
await this.performSearch(query);
} finally {
this.loaded = true; this.loaded = true;
}); }
} }
/** /**

View File

@ -34,7 +34,6 @@ import { CoreDomUtils } from '@services/utils/dom';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreTextUtils } from '@services/utils/text'; import { CoreTextUtils } from '@services/utils/text';
import { CoreLogger } from '@singletons/logger'; import { CoreLogger } from '@singletons/logger';
import { CoreApp } from '@services/app';
import { CoreInfiniteLoadingComponent } from '@components/infinite-loading/infinite-loading'; import { CoreInfiniteLoadingComponent } from '@components/infinite-loading/infinite-loading';
import { Md5 } from 'ts-md5/dist/md5'; import { Md5 } from 'ts-md5/dist/md5';
import moment from 'moment-timezone'; import moment from 'moment-timezone';
@ -45,6 +44,7 @@ import { CoreIonLoadingElement } from '@classes/ion-loading';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { CoreConstants } from '@/core/constants'; import { CoreConstants } from '@/core/constants';
import { CoreDom } from '@singletons/dom'; import { CoreDom } from '@singletons/dom';
import { CoreKeyboard } from '@singletons/keyboard';
/** /**
* Page that displays a message discussion page. * Page that displays a message discussion page.
@ -1177,7 +1177,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
// Only close the keyboard if an error happens. // Only close the keyboard if an error happens.
// We want the user to be able to send multiple messages without the keyboard being closed. // We want the user to be able to send multiple messages without the keyboard being closed.
CoreApp.closeKeyboard(); CoreKeyboard.close();
CoreDomUtils.showErrorModalDefault(error, 'addon.messages.messagenotsent', true); CoreDomUtils.showErrorModalDefault(error, 'addon.messages.messagenotsent', true);
this.removeMessage(message.hash!); this.removeMessage(message.hash!);

View File

@ -23,7 +23,6 @@ import {
} from '../../services/messages'; } from '../../services/messages';
import { CoreDomUtils } from '@services/utils/dom'; import { CoreDomUtils } from '@services/utils/dom';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreApp } from '@services/app';
import { ActivatedRoute, Params } from '@angular/router'; import { ActivatedRoute, Params } from '@angular/router';
import { CorePushNotificationsNotificationBasicData } from '@features/pushnotifications/services/pushnotifications'; import { CorePushNotificationsNotificationBasicData } from '@features/pushnotifications/services/pushnotifications';
import { CorePushNotificationsDelegate } from '@features/pushnotifications/services/push-delegate'; import { CorePushNotificationsDelegate } from '@features/pushnotifications/services/push-delegate';
@ -34,6 +33,7 @@ import { CoreScreen } from '@services/screen';
import { CoreMainMenuDeepLinkManager } from '@features/mainmenu/classes/deep-link-manager'; import { CoreMainMenuDeepLinkManager } from '@features/mainmenu/classes/deep-link-manager';
import { CorePlatform } from '@services/platform'; import { CorePlatform } from '@services/platform';
import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { CoreSplitViewComponent } from '@components/split-view/split-view';
import { CoreKeyboard } from '@singletons/keyboard';
/** /**
* Page that displays the list of discussions. * Page that displays the list of discussions.
@ -234,7 +234,7 @@ export class AddonMessagesDiscussions35Page implements OnInit, OnDestroy {
* @returns Resolved when done. * @returns Resolved when done.
*/ */
async searchMessage(query: string): Promise<void> { async searchMessage(query: string): Promise<void> {
CoreApp.closeKeyboard(); CoreKeyboard.close();
this.loaded = false; this.loaded = false;
this.loadingMessage = this.search.loading; this.loadingMessage = this.search.loading;

View File

@ -22,10 +22,10 @@ import {
AddonMessages, AddonMessages,
} from '../../services/messages'; } from '../../services/messages';
import { CoreDomUtils } from '@services/utils/dom'; import { CoreDomUtils } from '@services/utils/dom';
import { CoreApp } from '@services/app';
import { CoreNavigator } from '@services/navigator'; import { CoreNavigator } from '@services/navigator';
import { CoreScreen } from '@services/screen'; import { CoreScreen } from '@services/screen';
import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { CoreSplitViewComponent } from '@components/split-view/split-view';
import { CoreKeyboard } from '@singletons/keyboard';
/** /**
* Page for searching users. * Page for searching users.
@ -124,7 +124,7 @@ export class AddonMessagesSearchPage implements OnDestroy {
* @returns Resolved when done. * @returns Resolved when done.
*/ */
async search(query: string, loadMore?: 'contacts' | 'noncontacts' | 'messages', infiniteComplete?: () => void): Promise<void> { async search(query: string, loadMore?: 'contacts' | 'noncontacts' | 'messages', infiniteComplete?: () => void): Promise<void> {
CoreApp.closeKeyboard(); CoreKeyboard.close();
this.query = query; this.query = query;
this.disableSearch = true; this.disableSearch = true;

View File

@ -82,4 +82,4 @@ const routes: Routes = [
AddonModAssignEditPage, AddonModAssignEditPage,
], ],
}) })
export class AddonModAssignLazyModule {} export default class AddonModAssignLazyModule {}

View File

@ -23,15 +23,15 @@ import { CorePushNotificationsDelegate } from '@features/pushnotifications/servi
import { CoreCronDelegate } from '@services/cron'; import { CoreCronDelegate } from '@services/cron';
import { CORE_SITE_SCHEMAS } from '@services/sites'; import { CORE_SITE_SCHEMAS } from '@services/sites';
import { AddonModAssignFeedbackModule } from './feedback/feedback.module'; import { AddonModAssignFeedbackModule } from './feedback/feedback.module';
import { AddonModAssignProvider } from './services/assign';
import { OFFLINE_SITE_SCHEMA } from './services/database/assign'; import { OFFLINE_SITE_SCHEMA } from './services/database/assign';
import { AddonModAssignIndexLinkHandler } from './services/handlers/index-link'; import { AddonModAssignIndexLinkHandler } from './services/handlers/index-link';
import { AddonModAssignListLinkHandler } from './services/handlers/list-link'; import { AddonModAssignListLinkHandler } from './services/handlers/list-link';
import { AddonModAssignModuleHandler, AddonModAssignModuleHandlerService } from './services/handlers/module'; import { AddonModAssignModuleHandler } from './services/handlers/module';
import { AddonModAssignPrefetchHandler } from './services/handlers/prefetch'; import { AddonModAssignPrefetchHandler } from './services/handlers/prefetch';
import { AddonModAssignPushClickHandler } from './services/handlers/push-click'; import { AddonModAssignPushClickHandler } from './services/handlers/push-click';
import { AddonModAssignSyncCronHandler } from './services/handlers/sync-cron'; import { AddonModAssignSyncCronHandler } from './services/handlers/sync-cron';
import { AddonModAssignSubmissionModule } from './submission/submission.module'; import { AddonModAssignSubmissionModule } from './submission/submission.module';
import { ADDON_MOD_ASSIGN_COMPONENT, ADDON_MOD_ASSIGN_PAGE_NAME } from './constants';
/** /**
* Get mod assign services. * Get mod assign services.
@ -69,8 +69,8 @@ export async function getModAssignComponentModules(): Promise<unknown[]> {
const routes: Routes = [ const routes: Routes = [
{ {
path: AddonModAssignModuleHandlerService.PAGE_NAME, path: ADDON_MOD_ASSIGN_PAGE_NAME,
loadChildren: () => import('./assign-lazy.module').then(m => m.AddonModAssignLazyModule), loadChildren: () => import('./assign-lazy.module'),
}, },
]; ];
@ -97,7 +97,7 @@ const routes: Routes = [
CoreCronDelegate.register(AddonModAssignSyncCronHandler.instance); CoreCronDelegate.register(AddonModAssignSyncCronHandler.instance);
CorePushNotificationsDelegate.registerClickHandler(AddonModAssignPushClickHandler.instance); CorePushNotificationsDelegate.registerClickHandler(AddonModAssignPushClickHandler.instance);
CoreCourseHelper.registerModuleReminderClick(AddonModAssignProvider.COMPONENT); CoreCourseHelper.registerModuleReminderClick(ADDON_MOD_ASSIGN_COMPONENT);
}, },
}, },
], ],

View File

@ -29,7 +29,8 @@ import {
} from '../services/assign'; } from '../services/assign';
import { AddonModAssignHelper, AddonModAssignSubmissionFormatted } from '../services/assign-helper'; import { AddonModAssignHelper, AddonModAssignSubmissionFormatted } from '../services/assign-helper';
import { AddonModAssignOffline } from '../services/assign-offline'; import { AddonModAssignOffline } from '../services/assign-offline';
import { AddonModAssignSync, AddonModAssignSyncProvider } from '../services/assign-sync'; import { AddonModAssignSync } from '../services/assign-sync';
import { ADDON_MOD_ASSIGN_MANUAL_SYNCED } from '../constants';
/** /**
* Provides a collection of assignment submissions. * Provides a collection of assignment submissions.
@ -116,7 +117,7 @@ export class AddonModAssignSubmissionsSource extends CoreRoutedItemsManagerSourc
if (result && result.updated) { if (result && result.updated) {
CoreEvents.trigger( CoreEvents.trigger(
AddonModAssignSyncProvider.MANUAL_SYNCED, ADDON_MOD_ASSIGN_MANUAL_SYNCED,
{ {
assignId: this.assign.id, assignId: this.assign.id,
warnings: result.warnings, warnings: result.warnings,

View File

@ -20,11 +20,11 @@ import {
AddonModAssignAssign, AddonModAssignAssign,
AddonModAssignSubmission, AddonModAssignSubmission,
AddonModAssignPlugin, AddonModAssignPlugin,
AddonModAssignProvider,
AddonModAssign, AddonModAssign,
} from '../../services/assign'; } from '../../services/assign';
import { AddonModAssignHelper, AddonModAssignPluginConfig } from '../../services/assign-helper'; import { AddonModAssignHelper, AddonModAssignPluginConfig } from '../../services/assign-helper';
import { AddonModAssignFeedbackDelegate } from '../../services/feedback-delegate'; import { AddonModAssignFeedbackDelegate } from '../../services/feedback-delegate';
import { ADDON_MOD_ASSIGN_COMPONENT } from '../../constants';
/** /**
* Component that displays an assignment feedback plugin. * Component that displays an assignment feedback plugin.
@ -48,7 +48,7 @@ export class AddonModAssignFeedbackPluginComponent implements OnInit {
data?: AddonModAssignFeedbackPluginData; // Data to pass to the component. data?: AddonModAssignFeedbackPluginData; // Data to pass to the component.
// Data to render the plugin if it isn't supported. // Data to render the plugin if it isn't supported.
component = AddonModAssignProvider.COMPONENT; component = ADDON_MOD_ASSIGN_COMPONENT;
text = ''; text = '';
files: CoreWSFile[] = []; files: CoreWSFile[] = [];
notSupported = false; notSupported = false;

View File

@ -32,18 +32,26 @@ import { AddonModAssignListFilterName } from '../../classes/submissions-source';
import { import {
AddonModAssign, AddonModAssign,
AddonModAssignAssign, AddonModAssignAssign,
AddonModAssignProvider,
AddonModAssignSubmissionGradingSummary, AddonModAssignSubmissionGradingSummary,
} from '../../services/assign'; } from '../../services/assign';
import { AddonModAssignOffline } from '../../services/assign-offline'; import { AddonModAssignOffline } from '../../services/assign-offline';
import { import {
AddonModAssignAutoSyncData, AddonModAssignAutoSyncData,
AddonModAssignSync, AddonModAssignSync,
AddonModAssignSyncProvider,
AddonModAssignSyncResult, AddonModAssignSyncResult,
} from '../../services/assign-sync'; } from '../../services/assign-sync';
import { AddonModAssignModuleHandlerService } from '../../services/handlers/module';
import { AddonModAssignSubmissionComponent } from '../submission/submission'; import { AddonModAssignSubmissionComponent } from '../submission/submission';
import {
ADDON_MOD_ASSIGN_AUTO_SYNCED,
ADDON_MOD_ASSIGN_COMPONENT,
ADDON_MOD_ASSIGN_GRADED_EVENT,
ADDON_MOD_ASSIGN_PAGE_NAME,
ADDON_MOD_ASSIGN_STARTED_EVENT,
ADDON_MOD_ASSIGN_SUBMISSION_SAVED_EVENT,
ADDON_MOD_ASSIGN_SUBMITTED_FOR_GRADING_EVENT,
ADDON_MOD_ASSIGN_WARN_GROUPS_OPTIONAL,
ADDON_MOD_ASSIGN_WARN_GROUPS_REQUIRED,
} from '../../constants';
/** /**
* Component that displays an assignment. * Component that displays an assignment.
@ -56,7 +64,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo
@ViewChild(AddonModAssignSubmissionComponent) submissionComponent?: AddonModAssignSubmissionComponent; @ViewChild(AddonModAssignSubmissionComponent) submissionComponent?: AddonModAssignSubmissionComponent;
component = AddonModAssignProvider.COMPONENT; component = ADDON_MOD_ASSIGN_COMPONENT;
pluginName = 'assign'; pluginName = 'assign';
assign?: AddonModAssignAssign; // The assign object. assign?: AddonModAssignAssign; // The assign object.
@ -82,7 +90,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo
protected currentUserId!: number; // Current user ID. protected currentUserId!: number; // Current user ID.
protected currentSite!: CoreSite; // Current site. protected currentSite!: CoreSite; // Current site.
protected syncEventName = AddonModAssignSyncProvider.AUTO_SYNCED; protected syncEventName = ADDON_MOD_ASSIGN_AUTO_SYNCED;
// Observers. // Observers.
protected savedObserver?: CoreEventObserver; protected savedObserver?: CoreEventObserver;
@ -108,7 +116,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo
// Listen to events. // Listen to events.
this.savedObserver = CoreEvents.on( this.savedObserver = CoreEvents.on(
AddonModAssignProvider.SUBMISSION_SAVED_EVENT, ADDON_MOD_ASSIGN_SUBMISSION_SAVED_EVENT,
(data) => { (data) => {
if (this.assign && data.assignmentId == this.assign.id && data.userId == this.currentUserId) { if (this.assign && data.assignmentId == this.assign.id && data.userId == this.currentUserId) {
// Assignment submission saved, refresh data. // Assignment submission saved, refresh data.
@ -119,7 +127,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo
); );
this.submittedObserver = CoreEvents.on( this.submittedObserver = CoreEvents.on(
AddonModAssignProvider.SUBMITTED_FOR_GRADING_EVENT, ADDON_MOD_ASSIGN_SUBMITTED_FOR_GRADING_EVENT,
(data) => { (data) => {
if (this.assign && data.assignmentId == this.assign.id && data.userId == this.currentUserId) { if (this.assign && data.assignmentId == this.assign.id && data.userId == this.currentUserId) {
// Assignment submitted, check completion. // Assignment submitted, check completion.
@ -132,14 +140,14 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo
this.siteId, this.siteId,
); );
this.gradedObserver = CoreEvents.on(AddonModAssignProvider.GRADED_EVENT, (data) => { this.gradedObserver = CoreEvents.on(ADDON_MOD_ASSIGN_GRADED_EVENT, (data) => {
if (this.assign && data.assignmentId == this.assign.id && data.userId == this.currentUserId) { if (this.assign && data.assignmentId == this.assign.id && data.userId == this.currentUserId) {
// Assignment graded, refresh data. // Assignment graded, refresh data.
this.showLoadingAndRefresh(true, false); this.showLoadingAndRefresh(true, false);
} }
}, this.siteId); }, this.siteId);
this.startedObserver = CoreEvents.on(AddonModAssignProvider.STARTED_EVENT, (data) => { this.startedObserver = CoreEvents.on(ADDON_MOD_ASSIGN_STARTED_EVENT, (data) => {
if (this.assign && data.assignmentId == this.assign.id) { if (this.assign && data.assignmentId == this.assign.id) {
// Assignment submission started, refresh data. // Assignment submission started, refresh data.
this.showLoadingAndRefresh(false, false); this.showLoadingAndRefresh(false, false);
@ -276,10 +284,10 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo
this.summary.warnofungroupedusers = 'ungroupedusers'; this.summary.warnofungroupedusers = 'ungroupedusers';
} else { } else {
switch (this.summary.warnofungroupedusers) { switch (this.summary.warnofungroupedusers) {
case AddonModAssignProvider.WARN_GROUPS_REQUIRED: case ADDON_MOD_ASSIGN_WARN_GROUPS_REQUIRED:
this.summary.warnofungroupedusers = 'ungroupedusers'; this.summary.warnofungroupedusers = 'ungroupedusers';
break; break;
case AddonModAssignProvider.WARN_GROUPS_OPTIONAL: case ADDON_MOD_ASSIGN_WARN_GROUPS_OPTIONAL:
this.summary.warnofungroupedusers = 'ungroupedusersoptional'; this.summary.warnofungroupedusers = 'ungroupedusersoptional';
break; break;
default: default:
@ -311,7 +319,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo
} }
CoreNavigator.navigateToSitePath( CoreNavigator.navigateToSitePath(
AddonModAssignModuleHandlerService.PAGE_NAME + `/${this.courseId}/${this.module.id}/submission`, ADDON_MOD_ASSIGN_PAGE_NAME + `/${this.courseId}/${this.module.id}/submission`,
{ {
params, params,
}, },

View File

@ -18,13 +18,13 @@ import {
AddonModAssignAssign, AddonModAssignAssign,
AddonModAssignSubmission, AddonModAssignSubmission,
AddonModAssignPlugin, AddonModAssignPlugin,
AddonModAssignProvider,
AddonModAssign, AddonModAssign,
} from '../../services/assign'; } from '../../services/assign';
import { AddonModAssignHelper, AddonModAssignPluginConfig } from '../../services/assign-helper'; import { AddonModAssignHelper, AddonModAssignPluginConfig } from '../../services/assign-helper';
import { AddonModAssignSubmissionDelegate } from '../../services/submission-delegate'; import { AddonModAssignSubmissionDelegate } from '../../services/submission-delegate';
import { CoreFileEntry } from '@services/file-helper'; import { CoreFileEntry } from '@services/file-helper';
import type { AddonModAssignSubmissionPluginBaseComponent } from '@addons/mod/assign/classes/base-submission-plugin-component'; import type { AddonModAssignSubmissionPluginBaseComponent } from '@addons/mod/assign/classes/base-submission-plugin-component';
import { ADDON_MOD_ASSIGN_COMPONENT } from '../../constants';
/** /**
* Component that displays an assignment submission plugin. * Component that displays an assignment submission plugin.
@ -47,7 +47,7 @@ export class AddonModAssignSubmissionPluginComponent implements OnInit {
data?: AddonModAssignSubmissionPluginData; // Data to pass to the component. data?: AddonModAssignSubmissionPluginData; // Data to pass to the component.
// Data to render the plugin if it isn't supported. // Data to render the plugin if it isn't supported.
component = AddonModAssignProvider.COMPONENT; component = ADDON_MOD_ASSIGN_COMPONENT;
text = ''; text = '';
files: CoreFileEntry[] = []; files: CoreFileEntry[] = [];
notSupported = false; notSupported = false;

View File

@ -16,7 +16,6 @@ import { Component, Input, OnInit, OnDestroy, ViewChild, Optional, ViewChildren,
import { CoreEvents, CoreEventObserver } from '@singletons/events'; import { CoreEvents, CoreEventObserver } from '@singletons/events';
import { CoreSites } from '@services/sites'; import { CoreSites } from '@services/sites';
import { import {
AddonModAssignProvider,
AddonModAssignAssign, AddonModAssignAssign,
AddonModAssignSubmissionFeedback, AddonModAssignSubmissionFeedback,
AddonModAssignSubmissionAttempt, AddonModAssignSubmissionAttempt,
@ -33,7 +32,6 @@ import {
AddonModAssignAutoSyncData, AddonModAssignAutoSyncData,
AddonModAssignManualSyncData, AddonModAssignManualSyncData,
AddonModAssignSync, AddonModAssignSync,
AddonModAssignSyncProvider,
} from '../../services/assign-sync'; } from '../../services/assign-sync';
import { CoreTabsComponent } from '@components/tabs/tabs'; import { CoreTabsComponent } from '@components/tabs/tabs';
import { CoreTabComponent } from '@components/tabs/tab'; import { CoreTabComponent } from '@components/tabs/tab';
@ -56,11 +54,19 @@ import { CoreError } from '@classes/errors/error';
import { CoreGroups } from '@services/groups'; import { CoreGroups } from '@services/groups';
import { CoreSync } from '@services/sync'; import { CoreSync } from '@services/sync';
import { AddonModAssignSubmissionPluginComponent } from '../submission-plugin/submission-plugin'; import { AddonModAssignSubmissionPluginComponent } from '../submission-plugin/submission-plugin';
import { AddonModAssignModuleHandlerService } from '../../services/handlers/module';
import { CanLeave } from '@guards/can-leave'; import { CanLeave } from '@guards/can-leave';
import { CoreTime } from '@singletons/time'; import { CoreTime } from '@singletons/time';
import { isSafeNumber, SafeNumber } from '@/core/utils/types'; import { isSafeNumber, SafeNumber } from '@/core/utils/types';
import { CoreIonicColorNames } from '@singletons/colors'; import { CoreIonicColorNames } from '@singletons/colors';
import {
ADDON_MOD_ASSIGN_AUTO_SYNCED,
ADDON_MOD_ASSIGN_COMPONENT,
ADDON_MOD_ASSIGN_GRADED_EVENT,
ADDON_MOD_ASSIGN_MANUAL_SYNCED,
ADDON_MOD_ASSIGN_PAGE_NAME,
ADDON_MOD_ASSIGN_SUBMITTED_FOR_GRADING_EVENT,
ADDON_MOD_ASSIGN_UNLIMITED_ATTEMPTS,
} from '../../constants';
/** /**
* Component that displays an assignment submission. * Component that displays an assignment submission.
@ -137,7 +143,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
statusNew = AddonModAssignSubmissionStatusValues.NEW; statusNew = AddonModAssignSubmissionStatusValues.NEW;
statusReopened = AddonModAssignSubmissionStatusValues.REOPENED; statusReopened = AddonModAssignSubmissionStatusValues.REOPENED;
attemptReopenMethodNone = AddonModAssignAttemptReopenMethodValues.NONE; attemptReopenMethodNone = AddonModAssignAttemptReopenMethodValues.NONE;
unlimitedAttempts = AddonModAssignProvider.UNLIMITED_ATTEMPTS; unlimitedAttempts = ADDON_MOD_ASSIGN_UNLIMITED_ATTEMPTS;
protected siteId: string; // Current site ID. protected siteId: string; // Current site ID.
protected currentUserId: number; // Current user ID. protected currentUserId: number; // Current user ID.
@ -161,7 +167,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
this.maxAttemptsText = Translate.instant('addon.mod_assign.unlimitedattempts'); this.maxAttemptsText = Translate.instant('addon.mod_assign.unlimitedattempts');
// Refresh data if this assign is synchronized and it's grading. // Refresh data if this assign is synchronized and it's grading.
const events = [AddonModAssignSyncProvider.AUTO_SYNCED, AddonModAssignSyncProvider.MANUAL_SYNCED]; const events = [ADDON_MOD_ASSIGN_AUTO_SYNCED, ADDON_MOD_ASSIGN_MANUAL_SYNCED];
this.syncObserver = CoreEvents.onMultiple<AddonModAssignAutoSyncData | AddonModAssignManualSyncData>( this.syncObserver = CoreEvents.onMultiple<AddonModAssignAutoSyncData | AddonModAssignManualSyncData>(
events, events,
async (data) => { async (data) => {
@ -341,7 +347,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
if (!this.assign.submissiondrafts && this.userSubmission) { if (!this.assign.submissiondrafts && this.userSubmission) {
// No drafts allowed, so it was submitted. Trigger event. // No drafts allowed, so it was submitted. Trigger event.
CoreEvents.trigger(AddonModAssignProvider.SUBMITTED_FOR_GRADING_EVENT, { CoreEvents.trigger(ADDON_MOD_ASSIGN_SUBMITTED_FOR_GRADING_EVENT, {
assignmentId: this.assign.id, assignmentId: this.assign.id,
submissionId: this.userSubmission.id, submissionId: this.userSubmission.id,
userId: this.currentUserId, userId: this.currentUserId,
@ -389,7 +395,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
} }
CoreNavigator.navigateToSitePath( CoreNavigator.navigateToSitePath(
AddonModAssignModuleHandlerService.PAGE_NAME + '/' + this.courseId + '/' + this.moduleId + '/edit', ADDON_MOD_ASSIGN_PAGE_NAME + '/' + this.courseId + '/' + this.moduleId + '/edit',
{ {
params: { params: {
blindId: this.blindId, blindId: this.blindId,
@ -528,7 +534,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
const result = await AddonModAssignSync.syncAssign(this.assign.id); const result = await AddonModAssignSync.syncAssign(this.assign.id);
if (result && result.updated) { if (result && result.updated) {
CoreEvents.trigger(AddonModAssignSyncProvider.MANUAL_SYNCED, { CoreEvents.trigger(ADDON_MOD_ASSIGN_MANUAL_SYNCED, {
assignId: this.assign.id, assignId: this.assign.id,
warnings: result.warnings, warnings: result.warnings,
gradesBlocked: result.gradesBlocked, gradesBlocked: result.gradesBlocked,
@ -703,7 +709,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
await this.treatGradeInfo(assign); await this.treatGradeInfo(assign);
const isManual = assign.attemptreopenmethod == AddonModAssignAttemptReopenMethodValues.MANUAL; const isManual = assign.attemptreopenmethod == AddonModAssignAttemptReopenMethodValues.MANUAL;
const isUnlimited = assign.maxattempts == AddonModAssignProvider.UNLIMITED_ATTEMPTS; const isUnlimited = assign.maxattempts == ADDON_MOD_ASSIGN_UNLIMITED_ATTEMPTS;
const isLessThanMaxAttempts = !!this.userSubmission && (this.userSubmission.attemptnumber < (assign.maxattempts - 1)); const isLessThanMaxAttempts = !!this.userSubmission && (this.userSubmission.attemptnumber < (assign.maxattempts - 1));
this.allowAddAttempt = isManual && (!this.userSubmission || isUnlimited || isLessThanMaxAttempts); this.allowAddAttempt = isManual && (!this.userSubmission || isUnlimited || isLessThanMaxAttempts);
@ -864,7 +870,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
Translate.instant('core.grades.grade'), Translate.instant('core.grades.grade'),
this.feedback.gradefordisplay, this.feedback.gradefordisplay,
{ {
component: AddonModAssignProvider.COMPONENT, component: ADDON_MOD_ASSIGN_COMPONENT,
componentId: this.moduleId, componentId: this.moduleId,
}, },
); );
@ -903,7 +909,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
); );
// Submitted, trigger event. // Submitted, trigger event.
CoreEvents.trigger(AddonModAssignProvider.SUBMITTED_FOR_GRADING_EVENT, { CoreEvents.trigger(ADDON_MOD_ASSIGN_SUBMITTED_FOR_GRADING_EVENT, {
assignmentId: this.assign.id, assignmentId: this.assign.id,
submissionId: this.userSubmission.id, submissionId: this.userSubmission.id,
userId: this.currentUserId, userId: this.currentUserId,
@ -977,7 +983,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
// Invalidate and refresh data. // Invalidate and refresh data.
this.invalidateAndRefresh(true); this.invalidateAndRefresh(true);
CoreEvents.trigger(AddonModAssignProvider.GRADED_EVENT, { CoreEvents.trigger(ADDON_MOD_ASSIGN_GRADED_EVENT, {
assignmentId: this.assign.id, assignmentId: this.assign.id,
submissionId: this.submitId, submissionId: this.submitId,
userId: this.currentUserId, userId: this.currentUserId,
@ -1228,9 +1234,9 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can
const syncId = AddonModAssignSync.getGradeSyncId(this.assign.id, this.submitId); const syncId = AddonModAssignSync.getGradeSyncId(this.assign.id, this.submitId);
if (block) { if (block) {
CoreSync.blockOperation(AddonModAssignProvider.COMPONENT, syncId); CoreSync.blockOperation(ADDON_MOD_ASSIGN_COMPONENT, syncId);
} else { } else {
CoreSync.unblockOperation(AddonModAssignProvider.COMPONENT, syncId); CoreSync.unblockOperation(ADDON_MOD_ASSIGN_COMPONENT, syncId);
} }
} }

View File

@ -13,3 +13,20 @@
// limitations under the License. // limitations under the License.
export const ADDON_MOD_ASSIGN_FEATURE_NAME = 'CoreCourseModuleDelegate_AddonModAssign'; export const ADDON_MOD_ASSIGN_FEATURE_NAME = 'CoreCourseModuleDelegate_AddonModAssign';
export const ADDON_MOD_ASSIGN_COMPONENT = 'mmaModAssign';
export const ADDON_MOD_ASSIGN_PAGE_NAME = 'mod_assign';
export const ADDON_MOD_ASSIGN_UNLIMITED_ATTEMPTS = -1;
// Group submissions warnings.
export const ADDON_MOD_ASSIGN_WARN_GROUPS_REQUIRED = 'warnrequired';
export const ADDON_MOD_ASSIGN_WARN_GROUPS_OPTIONAL = 'warnoptional';
// Events.
export const ADDON_MOD_ASSIGN_SUBMISSION_SAVED_EVENT = 'addon_mod_assign_submission_saved';
export const ADDON_MOD_ASSIGN_SUBMITTED_FOR_GRADING_EVENT = 'addon_mod_assign_submitted_for_grading';
export const ADDON_MOD_ASSIGN_GRADED_EVENT = 'addon_mod_assign_graded';
export const ADDON_MOD_ASSIGN_STARTED_EVENT = 'addon_mod_assign_started';
export const ADDON_MOD_ASSIGN_AUTO_SYNCED = 'addon_mod_assign_autom_synced';
export const ADDON_MOD_ASSIGN_MANUAL_SYNCED = 'addon_mod_assign_manual_synced';

View File

@ -14,7 +14,7 @@
import { Component, OnInit, ElementRef } from '@angular/core'; import { Component, OnInit, ElementRef } from '@angular/core';
import { FormBuilder, FormControl } from '@angular/forms'; import { FormBuilder, FormControl } from '@angular/forms';
import { AddonModAssign, AddonModAssignProvider } from '@addons/mod/assign/services/assign'; import { AddonModAssign } from '@addons/mod/assign/services/assign';
import { CoreTextUtils } from '@services/utils/text'; import { CoreTextUtils } from '@services/utils/text';
import { import {
AddonModAssignFeedbackCommentsDraftData, AddonModAssignFeedbackCommentsDraftData,
@ -26,6 +26,7 @@ import { AddonModAssignOffline } from '@addons/mod/assign/services/assign-offlin
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { AddonModAssignFeedbackPluginBaseComponent } from '@addons/mod/assign/classes/base-feedback-plugin-component'; import { AddonModAssignFeedbackPluginBaseComponent } from '@addons/mod/assign/classes/base-feedback-plugin-component';
import { ContextLevel } from '@/core/constants'; import { ContextLevel } from '@/core/constants';
import { ADDON_MOD_ASSIGN_COMPONENT } from '@addons/mod/assign/constants';
/** /**
* Component to render a comments feedback plugin. * Component to render a comments feedback plugin.
*/ */
@ -36,7 +37,7 @@ import { ContextLevel } from '@/core/constants';
export class AddonModAssignFeedbackCommentsComponent extends AddonModAssignFeedbackPluginBaseComponent implements OnInit { export class AddonModAssignFeedbackCommentsComponent extends AddonModAssignFeedbackPluginBaseComponent implements OnInit {
control?: FormControl<string>; control?: FormControl<string>;
component = AddonModAssignProvider.COMPONENT; component = ADDON_MOD_ASSIGN_COMPONENT;
text = ''; text = '';
isSent = false; isSent = false;
loaded = false; loaded = false;

View File

@ -13,7 +13,8 @@
// limitations under the License. // limitations under the License.
import { AddonModAssignFeedbackPluginBaseComponent } from '@addons/mod/assign/classes/base-feedback-plugin-component'; import { AddonModAssignFeedbackPluginBaseComponent } from '@addons/mod/assign/classes/base-feedback-plugin-component';
import { AddonModAssignProvider, AddonModAssign } from '@addons/mod/assign/services/assign'; import { ADDON_MOD_ASSIGN_COMPONENT } from '@addons/mod/assign/constants';
import { AddonModAssign } from '@addons/mod/assign/services/assign';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { CoreWSFile } from '@services/ws'; import { CoreWSFile } from '@services/ws';
@ -26,7 +27,7 @@ import { CoreWSFile } from '@services/ws';
}) })
export class AddonModAssignFeedbackEditPdfComponent extends AddonModAssignFeedbackPluginBaseComponent implements OnInit { export class AddonModAssignFeedbackEditPdfComponent extends AddonModAssignFeedbackPluginBaseComponent implements OnInit {
component = AddonModAssignProvider.COMPONENT; component = ADDON_MOD_ASSIGN_COMPONENT;
files: CoreWSFile[] = []; files: CoreWSFile[] = [];
/** /**

View File

@ -13,7 +13,8 @@
// limitations under the License. // limitations under the License.
import { AddonModAssignFeedbackPluginBaseComponent } from '@addons/mod/assign/classes/base-feedback-plugin-component'; import { AddonModAssignFeedbackPluginBaseComponent } from '@addons/mod/assign/classes/base-feedback-plugin-component';
import { AddonModAssign, AddonModAssignProvider } from '@addons/mod/assign/services/assign'; import { ADDON_MOD_ASSIGN_COMPONENT } from '@addons/mod/assign/constants';
import { AddonModAssign } from '@addons/mod/assign/services/assign';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { CoreWSFile } from '@services/ws'; import { CoreWSFile } from '@services/ws';
@ -26,7 +27,7 @@ import { CoreWSFile } from '@services/ws';
}) })
export class AddonModAssignFeedbackFileComponent extends AddonModAssignFeedbackPluginBaseComponent implements OnInit { export class AddonModAssignFeedbackFileComponent extends AddonModAssignFeedbackPluginBaseComponent implements OnInit {
component = AddonModAssignProvider.COMPONENT; component = ADDON_MOD_ASSIGN_COMPONENT;
files: CoreWSFile[] = []; files: CoreWSFile[] = [];
/** /**

View File

@ -27,7 +27,6 @@ import { CoreEvents } from '@singletons/events';
import { import {
AddonModAssignAssign, AddonModAssignAssign,
AddonModAssignSubmission, AddonModAssignSubmission,
AddonModAssignProvider,
AddonModAssign, AddonModAssign,
AddonModAssignSubmissionStatusOptions, AddonModAssignSubmissionStatusOptions,
AddonModAssignGetSubmissionStatusWSResponse, AddonModAssignGetSubmissionStatusWSResponse,
@ -40,6 +39,12 @@ import { AddonModAssignSync } from '../../services/assign-sync';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws'; import { CoreWSExternalFile } from '@services/ws';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import {
ADDON_MOD_ASSIGN_COMPONENT,
ADDON_MOD_ASSIGN_STARTED_EVENT,
ADDON_MOD_ASSIGN_SUBMISSION_SAVED_EVENT,
ADDON_MOD_ASSIGN_SUBMITTED_FOR_GRADING_EVENT,
} from '../../constants';
/** /**
* Page that allows adding or editing an assigment submission. * Page that allows adding or editing an assigment submission.
@ -65,7 +70,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave {
timeLimitEndTime = 0; // If time limit is enabled, the end time for the timer. timeLimitEndTime = 0; // If time limit is enabled, the end time for the timer.
activityInstructions?: string; // Activity instructions. activityInstructions?: string; // Activity instructions.
introAttachments?: CoreWSExternalFile[]; // Intro attachments. introAttachments?: CoreWSExternalFile[]; // Intro attachments.
component = AddonModAssignProvider.COMPONENT; component = ADDON_MOD_ASSIGN_COMPONENT;
protected userId: number; // User doing the submission. protected userId: number; // User doing the submission.
protected isBlind = false; // Whether blind is used. protected isBlind = false; // Whether blind is used.
@ -144,7 +149,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave {
if (!this.isDestroyed) { if (!this.isDestroyed) {
// Block the assignment. // Block the assignment.
CoreSync.blockOperation(AddonModAssignProvider.COMPONENT, this.assign.id); CoreSync.blockOperation(ADDON_MOD_ASSIGN_COMPONENT, this.assign.id);
} }
// Wait for sync to be over (if any). // Wait for sync to be over (if any).
@ -276,7 +281,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave {
await AddonModAssign.startSubmission(this.assign.id); await AddonModAssign.startSubmission(this.assign.id);
CoreEvents.trigger(AddonModAssignProvider.STARTED_EVENT, { CoreEvents.trigger(ADDON_MOD_ASSIGN_STARTED_EVENT, {
assignmentId: this.assign.id, assignmentId: this.assign.id,
}, CoreSites.getCurrentSiteId()); }, CoreSites.getCurrentSiteId());
@ -453,7 +458,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave {
CoreForms.triggerFormSubmittedEvent(this.formElement, sent, CoreSites.getCurrentSiteId()); CoreForms.triggerFormSubmittedEvent(this.formElement, sent, CoreSites.getCurrentSiteId());
CoreEvents.trigger( CoreEvents.trigger(
AddonModAssignProvider.SUBMISSION_SAVED_EVENT, ADDON_MOD_ASSIGN_SUBMISSION_SAVED_EVENT,
{ {
assignmentId: this.assign!.id, assignmentId: this.assign!.id,
submissionId: this.userSubmission!.id, submissionId: this.userSubmission!.id,
@ -465,7 +470,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave {
if (!this.assign!.submissiondrafts) { if (!this.assign!.submissiondrafts) {
// No drafts allowed, so it was submitted. Trigger event. // No drafts allowed, so it was submitted. Trigger event.
CoreEvents.trigger( CoreEvents.trigger(
AddonModAssignProvider.SUBMITTED_FOR_GRADING_EVENT, ADDON_MOD_ASSIGN_SUBMITTED_FOR_GRADING_EVENT,
{ {
assignmentId: this.assign!.id, assignmentId: this.assign!.id,
submissionId: this.userSubmission!.id, submissionId: this.userSubmission!.id,
@ -500,7 +505,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave {
// Unblock the assignment. // Unblock the assignment.
if (this.assign) { if (this.assign) {
CoreSync.unblockOperation(AddonModAssignProvider.COMPONENT, this.assign.id); CoreSync.unblockOperation(ADDON_MOD_ASSIGN_COMPONENT, this.assign.id);
} }
} }

View File

@ -27,13 +27,13 @@ import {
AddonModAssignSubmissionForList, AddonModAssignSubmissionForList,
AddonModAssignSubmissionsSource, AddonModAssignSubmissionsSource,
} from '../../classes/submissions-source'; } from '../../classes/submissions-source';
import { AddonModAssignAssign, AddonModAssignProvider } from '../../services/assign'; import { AddonModAssignAssign } from '../../services/assign';
import { import {
AddonModAssignSyncProvider,
AddonModAssignManualSyncData, AddonModAssignManualSyncData,
AddonModAssignAutoSyncData, AddonModAssignAutoSyncData,
} from '../../services/assign-sync'; } from '../../services/assign-sync';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { ADDON_MOD_ASSIGN_AUTO_SYNCED, ADDON_MOD_ASSIGN_GRADED_EVENT, ADDON_MOD_ASSIGN_MANUAL_SYNCED } from '../../constants';
/** /**
* Page that displays a list of submissions of an assignment. * Page that displays a list of submissions of an assignment.
@ -56,7 +56,7 @@ export class AddonModAssignSubmissionListPage implements AfterViewInit, OnDestro
constructor() { constructor() {
// Update data if some grade changes. // Update data if some grade changes.
this.gradedObserver = CoreEvents.on( this.gradedObserver = CoreEvents.on(
AddonModAssignProvider.GRADED_EVENT, ADDON_MOD_ASSIGN_GRADED_EVENT,
(data) => { (data) => {
if ( if (
this.submissions.loaded && this.submissions.loaded &&
@ -72,7 +72,7 @@ export class AddonModAssignSubmissionListPage implements AfterViewInit, OnDestro
); );
// Refresh data if this assign is synchronized. // Refresh data if this assign is synchronized.
const events = [AddonModAssignSyncProvider.AUTO_SYNCED, AddonModAssignSyncProvider.MANUAL_SYNCED]; const events = [ADDON_MOD_ASSIGN_AUTO_SYNCED, ADDON_MOD_ASSIGN_MANUAL_SYNCED];
this.syncObserver = CoreEvents.onMultiple<AddonModAssignAutoSyncData | AddonModAssignManualSyncData>( this.syncObserver = CoreEvents.onMultiple<AddonModAssignAutoSyncData | AddonModAssignManualSyncData>(
events, events,
(data) => { (data) => {

View File

@ -17,7 +17,6 @@ import { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fi
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites'; import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
import { FileEntry, DirectoryEntry } from '@awesome-cordova-plugins/file/ngx'; import { FileEntry, DirectoryEntry } from '@awesome-cordova-plugins/file/ngx';
import { import {
AddonModAssignProvider,
AddonModAssignAssign, AddonModAssignAssign,
AddonModAssignSubmission, AddonModAssignSubmission,
AddonModAssignParticipant, AddonModAssignParticipant,
@ -37,6 +36,7 @@ import { AddonModAssignFeedbackDelegate } from './feedback-delegate';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { CoreFormFields } from '@singletons/form'; import { CoreFormFields } from '@singletons/form';
import { CoreFileEntry } from '@services/file-helper'; import { CoreFileEntry } from '@services/file-helper';
import { ADDON_MOD_ASSIGN_COMPONENT } from '../constants';
/** /**
* Service that provides some helper functions for assign. * Service that provides some helper functions for assign.
@ -650,7 +650,7 @@ export class AddonModAssignHelperProvider {
* @returns Promise resolved with the itemId. * @returns Promise resolved with the itemId.
*/ */
uploadFile(assignId: number, file: CoreFileEntry, itemId?: number, siteId?: string): Promise<number> { uploadFile(assignId: number, file: CoreFileEntry, itemId?: number, siteId?: string): Promise<number> {
return CoreFileUploader.uploadOrReuploadFile(file, itemId, AddonModAssignProvider.COMPONENT, assignId, siteId); return CoreFileUploader.uploadOrReuploadFile(file, itemId, ADDON_MOD_ASSIGN_COMPONENT, assignId, siteId);
} }
/** /**
@ -664,7 +664,7 @@ export class AddonModAssignHelperProvider {
* @returns Promise resolved with the itemId. * @returns Promise resolved with the itemId.
*/ */
uploadFiles(assignId: number, files: CoreFileEntry[], siteId?: string): Promise<number> { uploadFiles(assignId: number, files: CoreFileEntry[], siteId?: string): Promise<number> {
return CoreFileUploader.uploadOrReuploadFiles(files, AddonModAssignProvider.COMPONENT, assignId, siteId); return CoreFileUploader.uploadOrReuploadFiles(files, ADDON_MOD_ASSIGN_COMPONENT, assignId, siteId);
} }
/** /**

View File

@ -17,7 +17,6 @@ import { CoreEvents } from '@singletons/events';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreSyncBlockedError } from '@classes/base-sync'; import { CoreSyncBlockedError } from '@classes/base-sync';
import { import {
AddonModAssignProvider,
AddonModAssignAssign, AddonModAssignAssign,
AddonModAssignSubmission, AddonModAssignSubmission,
AddonModAssign, AddonModAssign,
@ -40,6 +39,7 @@ import { CoreNetworkError } from '@classes/errors/network-error';
import { CoreGradesFormattedItem, CoreGradesHelper } from '@features/grades/services/grades-helper'; import { CoreGradesFormattedItem, CoreGradesHelper } from '@features/grades/services/grades-helper';
import { AddonModAssignSubmissionDelegate } from './submission-delegate'; import { AddonModAssignSubmissionDelegate } from './submission-delegate';
import { AddonModAssignFeedbackDelegate } from './feedback-delegate'; import { AddonModAssignFeedbackDelegate } from './feedback-delegate';
import { ADDON_MOD_ASSIGN_AUTO_SYNCED, ADDON_MOD_ASSIGN_COMPONENT } from '../constants';
/** /**
* Service to sync assigns. * Service to sync assigns.
@ -47,9 +47,6 @@ import { AddonModAssignFeedbackDelegate } from './feedback-delegate';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class AddonModAssignSyncProvider extends CoreCourseActivitySyncBaseProvider<AddonModAssignSyncResult> { export class AddonModAssignSyncProvider extends CoreCourseActivitySyncBaseProvider<AddonModAssignSyncResult> {
static readonly AUTO_SYNCED = 'addon_mod_assign_autom_synced';
static readonly MANUAL_SYNCED = 'addon_mod_assign_manual_synced';
protected componentTranslatableString = 'assign'; protected componentTranslatableString = 'assign';
constructor() { constructor() {
@ -129,7 +126,7 @@ export class AddonModAssignSyncProvider extends CoreCourseActivitySyncBaseProvid
: await this.syncAssignIfNeeded(assignId, siteId); : await this.syncAssignIfNeeded(assignId, siteId);
if (result?.updated) { if (result?.updated) {
CoreEvents.trigger(AddonModAssignSyncProvider.AUTO_SYNCED, { CoreEvents.trigger(ADDON_MOD_ASSIGN_AUTO_SYNCED, {
assignId: assignId, assignId: assignId,
warnings: result.warnings, warnings: result.warnings,
gradesBlocked: result.gradesBlocked, gradesBlocked: result.gradesBlocked,
@ -170,7 +167,7 @@ export class AddonModAssignSyncProvider extends CoreCourseActivitySyncBaseProvid
} }
// Verify that assign isn't blocked. // Verify that assign isn't blocked.
if (CoreSync.isBlocked(AddonModAssignProvider.COMPONENT, assignId, siteId)) { if (CoreSync.isBlocked(ADDON_MOD_ASSIGN_COMPONENT, assignId, siteId)) {
this.logger.debug('Cannot sync assign ' + assignId + ' because it is blocked.'); this.logger.debug('Cannot sync assign ' + assignId + ' because it is blocked.');
throw new CoreSyncBlockedError(Translate.instant('core.errorsyncblocked', { $a: this.componentTranslate })); throw new CoreSyncBlockedError(Translate.instant('core.errorsyncblocked', { $a: this.componentTranslate }));
@ -193,7 +190,7 @@ export class AddonModAssignSyncProvider extends CoreCourseActivitySyncBaseProvid
protected async performSyncAssign(assignId: number, siteId: string): Promise<AddonModAssignSyncResult> { protected async performSyncAssign(assignId: number, siteId: string): Promise<AddonModAssignSyncResult> {
// Sync offline logs. // Sync offline logs.
await CoreUtils.ignoreErrors( await CoreUtils.ignoreErrors(
CoreCourseLogHelper.syncActivity(AddonModAssignProvider.COMPONENT, assignId, siteId), CoreCourseLogHelper.syncActivity(ADDON_MOD_ASSIGN_COMPONENT, assignId, siteId),
); );
const result: AddonModAssignSyncResult = { const result: AddonModAssignSyncResult = {
@ -433,7 +430,7 @@ export class AddonModAssignSyncProvider extends CoreCourseActivitySyncBaseProvid
}; };
// Check if this grade sync is blocked. // Check if this grade sync is blocked.
if (CoreSync.isBlocked(AddonModAssignProvider.COMPONENT, syncId, siteId)) { if (CoreSync.isBlocked(ADDON_MOD_ASSIGN_COMPONENT, syncId, siteId)) {
this.logger.error(`Cannot sync grade for assign ${assign.id} and user ${userId} because it is blocked.!!!!`); this.logger.error(`Cannot sync grade for assign ${assign.id} and user ${userId} because it is blocked.!!!!`);
throw new CoreSyncBlockedError(Translate.instant( throw new CoreSyncBlockedError(Translate.instant(

View File

@ -31,14 +31,21 @@ import { AddonModAssignSubmissionDelegate } from './submission-delegate';
import { CoreComments } from '@features/comments/services/comments'; import { CoreComments } from '@features/comments/services/comments';
import { AddonModAssignSubmissionFormatted } from './assign-helper'; import { AddonModAssignSubmissionFormatted } from './assign-helper';
import { CoreWSError } from '@classes/errors/wserror'; import { CoreWSError } from '@classes/errors/wserror';
import { AddonModAssignAutoSyncData, AddonModAssignManualSyncData, AddonModAssignSyncProvider } from './assign-sync'; import { AddonModAssignAutoSyncData, AddonModAssignManualSyncData } from './assign-sync';
import { CoreFormFields } from '@singletons/form'; import { CoreFormFields } from '@singletons/form';
import { CoreFileHelper } from '@services/file-helper'; import { CoreFileHelper } from '@services/file-helper';
import { CoreIonicColorNames } from '@singletons/colors'; import { CoreIonicColorNames } from '@singletons/colors';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site'; import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import { ContextLevel } from '@/core/constants'; import { ContextLevel } from '@/core/constants';
import {
const ROOT_CACHE_KEY = 'mmaModAssign:'; ADDON_MOD_ASSIGN_AUTO_SYNCED,
ADDON_MOD_ASSIGN_COMPONENT,
ADDON_MOD_ASSIGN_GRADED_EVENT,
ADDON_MOD_ASSIGN_MANUAL_SYNCED,
ADDON_MOD_ASSIGN_STARTED_EVENT,
ADDON_MOD_ASSIGN_SUBMISSION_SAVED_EVENT,
ADDON_MOD_ASSIGN_SUBMITTED_FOR_GRADING_EVENT,
} from '../constants';
declare module '@singletons/events' { declare module '@singletons/events' {
@ -48,12 +55,12 @@ declare module '@singletons/events' {
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
*/ */
export interface CoreEventsData { export interface CoreEventsData {
[AddonModAssignProvider.SUBMISSION_SAVED_EVENT]: AddonModAssignSubmissionSavedEventData; [ADDON_MOD_ASSIGN_SUBMISSION_SAVED_EVENT]: AddonModAssignSubmissionSavedEventData;
[AddonModAssignProvider.SUBMITTED_FOR_GRADING_EVENT]: AddonModAssignSubmittedForGradingEventData; [ADDON_MOD_ASSIGN_SUBMITTED_FOR_GRADING_EVENT]: AddonModAssignSubmittedForGradingEventData;
[AddonModAssignProvider.GRADED_EVENT]: AddonModAssignGradedEventData; [ADDON_MOD_ASSIGN_GRADED_EVENT]: AddonModAssignGradedEventData;
[AddonModAssignProvider.STARTED_EVENT]: AddonModAssignStartedEventData; [ADDON_MOD_ASSIGN_STARTED_EVENT]: AddonModAssignStartedEventData;
[AddonModAssignSyncProvider.MANUAL_SYNCED]: AddonModAssignManualSyncData; [ADDON_MOD_ASSIGN_MANUAL_SYNCED]: AddonModAssignManualSyncData;
[AddonModAssignSyncProvider.AUTO_SYNCED]: AddonModAssignAutoSyncData; [ADDON_MOD_ASSIGN_AUTO_SYNCED]: AddonModAssignAutoSyncData;
} }
} }
@ -64,19 +71,7 @@ declare module '@singletons/events' {
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class AddonModAssignProvider { export class AddonModAssignProvider {
static readonly COMPONENT = 'mmaModAssign'; protected static readonly ROOT_CACHE_KEY = 'mmaModAssign:';
static readonly SUBMISSION_COMPONENT = 'mmaModAssignSubmission';
static readonly UNLIMITED_ATTEMPTS = -1;
// Group submissions warnings.
static readonly WARN_GROUPS_REQUIRED = 'warnrequired';
static readonly WARN_GROUPS_OPTIONAL = 'warnoptional';
// Events.
static readonly SUBMISSION_SAVED_EVENT = 'addon_mod_assign_submission_saved';
static readonly SUBMITTED_FOR_GRADING_EVENT = 'addon_mod_assign_submitted_for_grading';
static readonly GRADED_EVENT = 'addon_mod_assign_graded';
static readonly STARTED_EVENT = 'addon_mod_assign_started';
/** /**
* Check if the user can submit in offline. This should only be used if submissionStatus.lastattempt.cansubmit cannot * Check if the user can submit in offline. This should only be used if submissionStatus.lastattempt.cansubmit cannot
@ -179,7 +174,7 @@ export class AddonModAssignProvider {
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getAssignmentCacheKey(courseId), cacheKey: this.getAssignmentCacheKey(courseId),
updateFrequency: CoreSite.FREQUENCY_RARELY, updateFrequency: CoreSite.FREQUENCY_RARELY,
component: AddonModAssignProvider.COMPONENT, component: ADDON_MOD_ASSIGN_COMPONENT,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -226,7 +221,7 @@ export class AddonModAssignProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected getAssignmentCacheKey(courseId: number): string { protected getAssignmentCacheKey(courseId: number): string {
return ROOT_CACHE_KEY + 'assignment:' + courseId; return AddonModAssignProvider.ROOT_CACHE_KEY + 'assignment:' + courseId;
} }
/** /**
@ -251,7 +246,7 @@ export class AddonModAssignProvider {
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getAssignmentUserMappingsCacheKey(assignId), cacheKey: this.getAssignmentUserMappingsCacheKey(assignId),
updateFrequency: CoreSite.FREQUENCY_OFTEN, updateFrequency: CoreSite.FREQUENCY_OFTEN,
component: AddonModAssignProvider.COMPONENT, component: ADDON_MOD_ASSIGN_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), ...CoreSites.getReadingStrategyPreSets(options.readingStrategy),
}; };
@ -279,7 +274,7 @@ export class AddonModAssignProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected getAssignmentUserMappingsCacheKey(assignId: number): string { protected getAssignmentUserMappingsCacheKey(assignId: number): string {
return ROOT_CACHE_KEY + 'usermappings:' + assignId; return AddonModAssignProvider.ROOT_CACHE_KEY + 'usermappings:' + assignId;
} }
/** /**
@ -297,7 +292,7 @@ export class AddonModAssignProvider {
}; };
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getAssignmentGradesCacheKey(assignId), cacheKey: this.getAssignmentGradesCacheKey(assignId),
component: AddonModAssignProvider.COMPONENT, component: ADDON_MOD_ASSIGN_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), ...CoreSites.getReadingStrategyPreSets(options.readingStrategy),
}; };
@ -326,7 +321,7 @@ export class AddonModAssignProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected getAssignmentGradesCacheKey(assignId: number): string { protected getAssignmentGradesCacheKey(assignId: number): string {
return ROOT_CACHE_KEY + 'assigngrades:' + assignId; return AddonModAssignProvider.ROOT_CACHE_KEY + 'assigngrades:' + assignId;
} }
/** /**
@ -461,7 +456,7 @@ export class AddonModAssignProvider {
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getSubmissionsCacheKey(assignId), cacheKey: this.getSubmissionsCacheKey(assignId),
updateFrequency: CoreSite.FREQUENCY_OFTEN, updateFrequency: CoreSite.FREQUENCY_OFTEN,
component: AddonModAssignProvider.COMPONENT, component: ADDON_MOD_ASSIGN_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), ...CoreSites.getReadingStrategyPreSets(options.readingStrategy),
}; };
@ -489,7 +484,7 @@ export class AddonModAssignProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected getSubmissionsCacheKey(assignId: number): string { protected getSubmissionsCacheKey(assignId: number): string {
return ROOT_CACHE_KEY + 'submissions:' + assignId; return AddonModAssignProvider.ROOT_CACHE_KEY + 'submissions:' + assignId;
} }
/** /**
@ -529,7 +524,7 @@ export class AddonModAssignProvider {
getCacheUsingCacheKey: true, getCacheUsingCacheKey: true,
filter: options.filter, filter: options.filter,
rewriteurls: options.filter, rewriteurls: options.filter,
component: AddonModAssignProvider.COMPONENT, component: ADDON_MOD_ASSIGN_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
// Don't cache when getting text without filters. // Don't cache when getting text without filters.
// @todo Change this to support offline editing. // @todo Change this to support offline editing.
@ -659,7 +654,7 @@ export class AddonModAssignProvider {
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.listParticipantsCacheKey(assignId, groupId), cacheKey: this.listParticipantsCacheKey(assignId, groupId),
updateFrequency: CoreSite.FREQUENCY_OFTEN, updateFrequency: CoreSite.FREQUENCY_OFTEN,
component: AddonModAssignProvider.COMPONENT, component: ADDON_MOD_ASSIGN_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), ...CoreSites.getReadingStrategyPreSets(options.readingStrategy),
}; };
@ -685,7 +680,7 @@ export class AddonModAssignProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected listParticipantsPrefixCacheKey(assignId: number): string { protected listParticipantsPrefixCacheKey(assignId: number): string {
return ROOT_CACHE_KEY + 'participants:' + assignId; return AddonModAssignProvider.ROOT_CACHE_KEY + 'participants:' + assignId;
} }
/** /**
@ -891,7 +886,7 @@ export class AddonModAssignProvider {
await CoreCourseLogHelper.log( await CoreCourseLogHelper.log(
'mod_assign_view_submission_status', 'mod_assign_view_submission_status',
params, params,
AddonModAssignProvider.COMPONENT, ADDON_MOD_ASSIGN_COMPONENT,
assignid, assignid,
siteId, siteId,
); );
@ -912,7 +907,7 @@ export class AddonModAssignProvider {
await CoreCourseLogHelper.log( await CoreCourseLogHelper.log(
'mod_assign_view_grading_table', 'mod_assign_view_grading_table',
params, params,
AddonModAssignProvider.COMPONENT, ADDON_MOD_ASSIGN_COMPONENT,
assignid, assignid,
siteId, siteId,
); );
@ -933,7 +928,7 @@ export class AddonModAssignProvider {
await CoreCourseLogHelper.log( await CoreCourseLogHelper.log(
'mod_assign_view_assign', 'mod_assign_view_assign',
params, params,
AddonModAssignProvider.COMPONENT, ADDON_MOD_ASSIGN_COMPONENT,
assignid, assignid,
siteId, siteId,
); );

View File

@ -17,6 +17,7 @@ import { Injectable, Type } from '@angular/core';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate'; import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler'; import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
import { ADDON_MOD_ASSIGN_PAGE_NAME } from '../../constants';
/** /**
* Handler to support assign modules. * Handler to support assign modules.
@ -24,11 +25,9 @@ import { CoreModuleHandlerBase } from '@features/course/classes/module-base-hand
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class AddonModAssignModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler { export class AddonModAssignModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler {
static readonly PAGE_NAME = 'mod_assign';
name = 'AddonModAssign'; name = 'AddonModAssign';
modName = 'assign'; modName = 'assign';
protected pageName = AddonModAssignModuleHandlerService.PAGE_NAME; protected pageName = ADDON_MOD_ASSIGN_PAGE_NAME;
supportedFeatures = { supportedFeatures = {
[CoreConstants.FEATURE_GROUPS]: true, [CoreConstants.FEATURE_GROUPS]: true,

View File

@ -18,7 +18,6 @@ import { makeSingleton } from '@singletons';
import { import {
AddonModAssign, AddonModAssign,
AddonModAssignAssign, AddonModAssignAssign,
AddonModAssignProvider,
AddonModAssignSubmission, AddonModAssignSubmission,
AddonModAssignSubmissionStatusOptions, AddonModAssignSubmissionStatusOptions,
} from '../assign'; } from '../assign';
@ -35,6 +34,7 @@ import { AddonModAssignSync, AddonModAssignSyncResult } from '../assign-sync';
import { CoreUser } from '@features/user/services/user'; import { CoreUser } from '@features/user/services/user';
import { CoreGradesHelper } from '@features/grades/services/grades-helper'; import { CoreGradesHelper } from '@features/grades/services/grades-helper';
import { CoreCourses } from '@features/courses/services/courses'; import { CoreCourses } from '@features/courses/services/courses';
import { ADDON_MOD_ASSIGN_COMPONENT } from '../../constants';
/** /**
* Handler to prefetch assigns. * Handler to prefetch assigns.
@ -44,7 +44,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref
name = 'AddonModAssign'; name = 'AddonModAssign';
modName = 'assign'; modName = 'assign';
component = AddonModAssignProvider.COMPONENT; component = ADDON_MOD_ASSIGN_COMPONENT;
updatesNames = /^configuration$|^.*files$|^submissions$|^grades$|^gradeitems$|^outcomes$|^comments$/; updatesNames = /^configuration$|^.*files$|^submissions$|^grades$|^gradeitems$|^outcomes$|^comments$/;
/** /**

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { AddonModAssign, AddonModAssignProvider } from '@addons/mod/assign/services/assign'; import { AddonModAssign } from '@addons/mod/assign/services/assign';
import { AddonModAssignHelper } from '@addons/mod/assign/services/assign-helper'; import { AddonModAssignHelper } from '@addons/mod/assign/services/assign-helper';
import { AddonModAssignOffline } from '@addons/mod/assign/services/assign-offline'; import { AddonModAssignOffline } from '@addons/mod/assign/services/assign-offline';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
@ -23,6 +23,7 @@ import { AddonModAssignSubmissionFileHandlerService } from '../services/handler'
import { FileEntry } from '@awesome-cordova-plugins/file/ngx'; import { FileEntry } from '@awesome-cordova-plugins/file/ngx';
import { AddonModAssignSubmissionPluginBaseComponent } from '@addons/mod/assign/classes/base-submission-plugin-component'; import { AddonModAssignSubmissionPluginBaseComponent } from '@addons/mod/assign/classes/base-submission-plugin-component';
import { CoreFileEntry } from '@services/file-helper'; import { CoreFileEntry } from '@services/file-helper';
import { ADDON_MOD_ASSIGN_COMPONENT } from '@addons/mod/assign/constants';
/** /**
* Component to render a file submission plugin. * Component to render a file submission plugin.
@ -33,7 +34,7 @@ import { CoreFileEntry } from '@services/file-helper';
}) })
export class AddonModAssignSubmissionFileComponent extends AddonModAssignSubmissionPluginBaseComponent implements OnInit { export class AddonModAssignSubmissionFileComponent extends AddonModAssignSubmissionPluginBaseComponent implements OnInit {
component = AddonModAssignProvider.COMPONENT; component = ADDON_MOD_ASSIGN_COMPONENT;
files: CoreFileEntry[] = []; files: CoreFileEntry[] = [];
maxSize?: number; maxSize?: number;

View File

@ -16,7 +16,6 @@ import {
AddonModAssignAssign, AddonModAssignAssign,
AddonModAssignSubmission, AddonModAssignSubmission,
AddonModAssignPlugin, AddonModAssignPlugin,
AddonModAssignProvider,
AddonModAssign, AddonModAssign,
} from '@addons/mod/assign/services/assign'; } from '@addons/mod/assign/services/assign';
import { AddonModAssignHelper } from '@addons/mod/assign/services/assign-helper'; import { AddonModAssignHelper } from '@addons/mod/assign/services/assign-helper';
@ -32,6 +31,7 @@ import { makeSingleton } from '@singletons';
import { AddonModAssignSubmissionFileComponent } from '../component/file'; import { AddonModAssignSubmissionFileComponent } from '../component/file';
import { FileEntry } from '@awesome-cordova-plugins/file/ngx'; import { FileEntry } from '@awesome-cordova-plugins/file/ngx';
import type { AddonModAssignSubmissionPluginBaseComponent } from '@addons/mod/assign/classes/base-submission-plugin-component'; import type { AddonModAssignSubmissionPluginBaseComponent } from '@addons/mod/assign/classes/base-submission-plugin-component';
import { ADDON_MOD_ASSIGN_COMPONENT } from '@addons/mod/assign/constants';
/** /**
* Handler for file submission plugin. * Handler for file submission plugin.
@ -65,10 +65,10 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
* @inheritdoc * @inheritdoc
*/ */
clearTmpData(assign: AddonModAssignAssign): void { clearTmpData(assign: AddonModAssignAssign): void {
const files = CoreFileSession.getFiles(AddonModAssignProvider.COMPONENT, assign.id); const files = CoreFileSession.getFiles(ADDON_MOD_ASSIGN_COMPONENT, assign.id);
// Clear the files in session for this assign. // Clear the files in session for this assign.
CoreFileSession.clearFiles(AddonModAssignProvider.COMPONENT, assign.id); CoreFileSession.clearFiles(ADDON_MOD_ASSIGN_COMPONENT, assign.id);
// Now delete the local files from the tmp folder. // Now delete the local files from the tmp folder.
CoreFileUploader.clearTmpFiles(files); CoreFileUploader.clearTmpFiles(files);
@ -148,7 +148,7 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
// Check if there's any change. // Check if there's any change.
const hasChanged = await this.hasDataChanged(assign, submission, plugin); const hasChanged = await this.hasDataChanged(assign, submission, plugin);
if (hasChanged) { if (hasChanged) {
const files = CoreFileSession.getFiles(AddonModAssignProvider.COMPONENT, assign.id); const files = CoreFileSession.getFiles(ADDON_MOD_ASSIGN_COMPONENT, assign.id);
return CoreFileHelper.getTotalFilesSize(files); return CoreFileHelper.getTotalFilesSize(files);
} else { } else {
@ -183,7 +183,7 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
numFiles = pluginFiles && pluginFiles.length; numFiles = pluginFiles && pluginFiles.length;
} }
const currentFiles = CoreFileSession.getFiles(AddonModAssignProvider.COMPONENT, assign.id); const currentFiles = CoreFileSession.getFiles(ADDON_MOD_ASSIGN_COMPONENT, assign.id);
if (currentFiles.length != numFiles) { if (currentFiles.length != numFiles) {
// Number of files has changed. // Number of files has changed.
@ -230,7 +230,7 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
} }
// Data has changed, we need to upload new files and re-upload all the existing files. // Data has changed, we need to upload new files and re-upload all the existing files.
const currentFiles = CoreFileSession.getFiles(AddonModAssignProvider.COMPONENT, assign.id); const currentFiles = CoreFileSession.getFiles(ADDON_MOD_ASSIGN_COMPONENT, assign.id);
const error = CoreUtils.hasRepeatedFilenames(currentFiles); const error = CoreUtils.hasRepeatedFilenames(currentFiles);
if (error) { if (error) {

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
import { AddonModAssignSubmissionPluginBaseComponent } from '@addons/mod/assign/classes/base-submission-plugin-component'; import { AddonModAssignSubmissionPluginBaseComponent } from '@addons/mod/assign/classes/base-submission-plugin-component';
import { AddonModAssignProvider, AddonModAssign } from '@addons/mod/assign/services/assign'; import { AddonModAssign } from '@addons/mod/assign/services/assign';
import { AddonModAssignOffline } from '@addons/mod/assign/services/assign-offline'; import { AddonModAssignOffline } from '@addons/mod/assign/services/assign-offline';
import { Component, OnInit, ElementRef } from '@angular/core'; import { Component, OnInit, ElementRef } from '@angular/core';
import { FormBuilder, FormControl } from '@angular/forms'; import { FormBuilder, FormControl } from '@angular/forms';
@ -22,6 +22,7 @@ import { CoreTextUtils } from '@services/utils/text';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { AddonModAssignSubmissionOnlineTextPluginData } from '../services/handler'; import { AddonModAssignSubmissionOnlineTextPluginData } from '../services/handler';
import { ContextLevel } from '@/core/constants'; import { ContextLevel } from '@/core/constants';
import { ADDON_MOD_ASSIGN_COMPONENT } from '@addons/mod/assign/constants';
/** /**
* Component to render an onlinetext submission plugin. * Component to render an onlinetext submission plugin.
@ -34,7 +35,7 @@ export class AddonModAssignSubmissionOnlineTextComponent extends AddonModAssignS
control?: FormControl<string>; control?: FormControl<string>;
words = 0; words = 0;
component = AddonModAssignProvider.COMPONENT; component = ADDON_MOD_ASSIGN_COMPONENT;
text = ''; text = '';
loaded = false; loaded = false;
wordLimitEnabled = false; wordLimitEnabled = false;

View File

@ -35,4 +35,4 @@ const routes: Routes = [
AddonModBBBIndexPage, AddonModBBBIndexPage,
], ],
}) })
export class AddonModBBBLazyModule {} export default class AddonModBBBLazyModule {}

View File

@ -19,12 +19,13 @@ import { CoreCourseModuleDelegate } from '@features/course/services/module-deleg
import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module'; import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module';
import { AddonModBBBIndexLinkHandler } from './services/handlers/index-link'; import { AddonModBBBIndexLinkHandler } from './services/handlers/index-link';
import { AddonModBBBListLinkHandler } from './services/handlers/list-link'; import { AddonModBBBListLinkHandler } from './services/handlers/list-link';
import { AddonModBBBModuleHandler, ADDON_MOD_BBB_MAIN_MENU_PAGE_NAME } from './services/handlers/module'; import { AddonModBBBModuleHandler } from './services/handlers/module';
import { ADDON_MOD_BBB_PAGE_NAME } from './constants';
const routes: Routes = [ const routes: Routes = [
{ {
path: ADDON_MOD_BBB_MAIN_MENU_PAGE_NAME, path: ADDON_MOD_BBB_PAGE_NAME,
loadChildren: () => import('./bigbluebuttonbn-lazy.module').then(m => m.AddonModBBBLazyModule), loadChildren: () => import('./bigbluebuttonbn-lazy.module'),
}, },
]; ];

View File

@ -30,8 +30,8 @@ import {
AddonModBBBData, AddonModBBBData,
AddonModBBBMeetingInfo, AddonModBBBMeetingInfo,
AddonModBBBRecordingPlaybackTypes, AddonModBBBRecordingPlaybackTypes,
AddonModBBBService,
} from '../../services/bigbluebuttonbn'; } from '../../services/bigbluebuttonbn';
import { ADDON_MOD_BBB_COMPONENT } from '../../constants';
/** /**
* Component that displays a Big Blue Button activity. * Component that displays a Big Blue Button activity.
@ -43,7 +43,7 @@ import {
}) })
export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityComponent implements OnInit { export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityComponent implements OnInit {
component = AddonModBBBService.COMPONENT; component = ADDON_MOD_BBB_COMPONENT;
pluginName = 'bigbluebuttonbn'; pluginName = 'bigbluebuttonbn';
bbb?: AddonModBBBData; bbb?: AddonModBBBData;
groupInfo?: CoreGroupInfo; groupInfo?: CoreGroupInfo;

View File

@ -0,0 +1,16 @@
// (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.
export const ADDON_MOD_BBB_COMPONENT = 'mmaModBigBlueButtonBN';
export const ADDON_MOD_BBB_PAGE_NAME = 'mod_bigbluebuttonbn';

View File

@ -24,8 +24,7 @@ import { CoreTextUtils } from '@services/utils/text';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws'; import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
import { makeSingleton, Translate } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
import { ADDON_MOD_BBB_COMPONENT } from '../constants';
const ROOT_CACHE_KEY = 'AddonModBBB:';
/** /**
* Service that provides some features for Big Blue Button activity. * Service that provides some features for Big Blue Button activity.
@ -33,7 +32,7 @@ const ROOT_CACHE_KEY = 'AddonModBBB:';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class AddonModBBBService { export class AddonModBBBService {
static readonly COMPONENT = 'mmaModBigBlueButtonBN'; protected static readonly ROOT_CACHE_KEY = 'AddonModBBB:';
/** /**
* End a meeting. * End a meeting.
@ -75,7 +74,7 @@ export class AddonModBBBService {
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getBBBsCacheKey(courseId), cacheKey: this.getBBBsCacheKey(courseId),
updateFrequency: CoreSite.FREQUENCY_RARELY, updateFrequency: CoreSite.FREQUENCY_RARELY,
component: AddonModBBBService.COMPONENT, component: ADDON_MOD_BBB_COMPONENT,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -100,7 +99,7 @@ export class AddonModBBBService {
* @returns Cache key. * @returns Cache key.
*/ */
protected getBBBsCacheKey(courseId: number): string { protected getBBBsCacheKey(courseId: number): string {
return ROOT_CACHE_KEY + 'bbb:' + courseId; return AddonModBBBService.ROOT_CACHE_KEY + 'bbb:' + courseId;
} }
/** /**
@ -166,7 +165,7 @@ export class AddonModBBBService {
cacheKey: this.getMeetingInfoCacheKey(id, groupId), cacheKey: this.getMeetingInfoCacheKey(id, groupId),
getCacheUsingCacheKey: true, getCacheUsingCacheKey: true,
uniqueCacheKey: true, uniqueCacheKey: true,
component: AddonModBBBService.COMPONENT, component: ADDON_MOD_BBB_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -205,7 +204,7 @@ export class AddonModBBBService {
* @returns Cache key prefix. * @returns Cache key prefix.
*/ */
protected getMeetingInfoCacheKeyPrefix(id: number): string { protected getMeetingInfoCacheKeyPrefix(id: number): string {
return ROOT_CACHE_KEY + 'meetingInfo:' + id + ':'; return AddonModBBBService.ROOT_CACHE_KEY + 'meetingInfo:' + id + ':';
} }
/** /**
@ -229,7 +228,7 @@ export class AddonModBBBService {
}; };
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getRecordingsCacheKey(id, groupId), cacheKey: this.getRecordingsCacheKey(id, groupId),
component: AddonModBBBService.COMPONENT, component: ADDON_MOD_BBB_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -270,7 +269,7 @@ export class AddonModBBBService {
* @returns Cache key prefix. * @returns Cache key prefix.
*/ */
protected getRecordingsCacheKeyPrefix(id: number): string { protected getRecordingsCacheKeyPrefix(id: number): string {
return ROOT_CACHE_KEY + 'recordings:' + id + ':'; return AddonModBBBService.ROOT_CACHE_KEY + 'recordings:' + id + ':';
} }
/** /**
@ -288,7 +287,7 @@ export class AddonModBBBService {
await CoreCourseLogHelper.log( await CoreCourseLogHelper.log(
'mod_bigbluebuttonbn_view_bigbluebuttonbn', 'mod_bigbluebuttonbn_view_bigbluebuttonbn',
params, params,
AddonModBBBService.COMPONENT, ADDON_MOD_BBB_COMPONENT,
id, id,
siteId, siteId,
); );

View File

@ -22,8 +22,7 @@ import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonModBBBIndexComponent } from '../../components/index'; import { AddonModBBBIndexComponent } from '../../components/index';
import { AddonModBBB } from '../bigbluebuttonbn'; import { AddonModBBB } from '../bigbluebuttonbn';
import { ADDON_MOD_BBB_PAGE_NAME } from '../../constants';
export const ADDON_MOD_BBB_MAIN_MENU_PAGE_NAME = 'mod_bigbluebuttonbn';
/** /**
* Handler to support Big Blue Button activities. * Handler to support Big Blue Button activities.
@ -33,7 +32,7 @@ export class AddonModBBBModuleHandlerService extends CoreModuleHandlerBase imple
name = 'AddonModBBB'; name = 'AddonModBBB';
modName = 'bigbluebuttonbn'; modName = 'bigbluebuttonbn';
protected pageName = ADDON_MOD_BBB_MAIN_MENU_PAGE_NAME; protected pageName = ADDON_MOD_BBB_PAGE_NAME;
protected sitePluginHandler?: CoreSitePluginsModuleHandler; protected sitePluginHandler?: CoreSitePluginsModuleHandler;
supportedFeatures = { supportedFeatures = {

View File

@ -43,4 +43,4 @@ const routes: Routes = [
AddonModBookContentsPage, AddonModBookContentsPage,
], ],
}) })
export class AddonModBookLazyModule {} export default class AddonModBookLazyModule {}

View File

@ -19,18 +19,19 @@ import { CoreCourseModuleDelegate } from '@features/course/services/module-deleg
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module'; import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module';
import { CoreTagAreaDelegate } from '@features/tag/services/tag-area-delegate'; import { CoreTagAreaDelegate } from '@features/tag/services/tag-area-delegate';
import { AddonModBookModuleHandler, AddonModBookModuleHandlerService } from './services/handlers/module'; import { AddonModBookModuleHandler } from './services/handlers/module';
import { AddonModBookIndexLinkHandler } from './services/handlers/index-link'; import { AddonModBookIndexLinkHandler } from './services/handlers/index-link';
import { AddonModBookListLinkHandler } from './services/handlers/list-link'; import { AddonModBookListLinkHandler } from './services/handlers/list-link';
import { AddonModBookPrefetchHandler } from './services/handlers/prefetch'; import { AddonModBookPrefetchHandler } from './services/handlers/prefetch';
import { AddonModBookTagAreaHandler } from './services/handlers/tag-area'; import { AddonModBookTagAreaHandler } from './services/handlers/tag-area';
import { CORE_SITE_SCHEMAS } from '@services/sites'; import { CORE_SITE_SCHEMAS } from '@services/sites';
import { BOOK_SITE_SCHEMA } from './services/database/book'; import { BOOK_SITE_SCHEMA } from './services/database/book';
import { ADDON_MOD_BOOK_PAGE_NAME } from './constants';
const routes: Routes = [ const routes: Routes = [
{ {
path: AddonModBookModuleHandlerService.PAGE_NAME, path: ADDON_MOD_BOOK_PAGE_NAME,
loadChildren: () => import('./book-lazy.module').then(m => m.AddonModBookLazyModule), loadChildren: () => import('./book-lazy.module'),
}, },
]; ];

View File

@ -14,12 +14,12 @@
import { Component, Optional, OnInit, OnDestroy } from '@angular/core'; import { Component, Optional, OnInit, OnDestroy } from '@angular/core';
import { CoreCourseModuleMainResourceComponent } from '@features/course/classes/main-resource-component'; import { CoreCourseModuleMainResourceComponent } from '@features/course/classes/main-resource-component';
import { AddonModBook, AddonModBookBookWSData, AddonModBookNumbering, AddonModBookTocChapter } from '../../services/book'; import { AddonModBook, AddonModBookBookWSData, AddonModBookTocChapter } from '../../services/book';
import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; import { CoreCourseContentsPage } from '@features/course/pages/contents/contents';
import { CoreCourse } from '@features/course/services/course'; import { CoreCourse } from '@features/course/services/course';
import { CoreNavigator } from '@services/navigator'; import { CoreNavigator } from '@services/navigator';
import { AddonModBookModuleHandlerService } from '../../services/handlers/module';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { ADDON_MOD_BOOK_PAGE_NAME, AddonModBookNumbering } from '../../constants';
/** /**
* Component that displays a book entry page. * Component that displays a book entry page.
@ -116,7 +116,7 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp
*/ */
async openBook(chapterId?: number): Promise<void> { async openBook(chapterId?: number): Promise<void> {
await CoreNavigator.navigateToSitePath( await CoreNavigator.navigateToSitePath(
`${AddonModBookModuleHandlerService.PAGE_NAME}/${this.courseId}/${this.module.id}/contents`, `${ADDON_MOD_BOOK_PAGE_NAME}/${this.courseId}/${this.module.id}/contents`,
{ params: { chapterId } }, { params: { chapterId } },
); );

View File

@ -14,7 +14,8 @@
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { ModalController } from '@singletons'; import { ModalController } from '@singletons';
import { AddonModBookTocChapter, AddonModBookBookWSData, AddonModBookNumbering } from '../../services/book'; import { AddonModBookTocChapter, AddonModBookBookWSData } from '../../services/book';
import { AddonModBookNumbering } from '../../constants';
/** /**
* Modal to display the TOC of a book. * Modal to display the TOC of a book.

View File

@ -0,0 +1,34 @@
// (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.
export const ADDON_MOD_BOOK_COMPONENT = 'mmaModBook';
export const ADDON_MOD_BOOK_PAGE_NAME = 'mod_book';
/**
* Constants to define how the chapters and subchapters of a book should be displayed in that table of contents.
*/
export const enum AddonModBookNumbering {
NONE = 0,
NUMBERS = 1,
BULLETS = 2,
INDENTED = 3,
}
/**
* Constants to define the navigation style used within a book.
*/
export const enum AddonModBookNavStyle {
TOC_ONLY = 0,
IMAGE = 1,
TEXT = 2,
}

View File

@ -35,12 +35,11 @@ import {
AddonModBook, AddonModBook,
AddonModBookBookWSData, AddonModBookBookWSData,
AddonModBookContentsMap, AddonModBookContentsMap,
AddonModBookNavStyle,
AddonModBookProvider,
AddonModBookTocChapter, AddonModBookTocChapter,
} from '../../services/book'; } from '../../services/book';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { CoreUrlUtils } from '@services/utils/url'; import { CoreUrlUtils } from '@services/utils/url';
import { ADDON_MOD_BOOK_COMPONENT, AddonModBookNavStyle } from '../../constants';
/** /**
* Page that displays a book contents. * Page that displays a book contents.
@ -58,7 +57,7 @@ export class AddonModBookContentsPage implements OnInit, OnDestroy {
cmId!: number; cmId!: number;
courseId!: number; courseId!: number;
initialChapterId?: number; initialChapterId?: number;
component = AddonModBookProvider.COMPONENT; component = ADDON_MOD_BOOK_COMPONENT;
manager?: CoreSwipeSlidesItemsManager<LoadedChapter, AddonModBookSlidesItemsManagerSource>; manager?: CoreSwipeSlidesItemsManager<LoadedChapter, AddonModBookSlidesItemsManagerSource>;
warning = ''; warning = '';
displayNavBar = true; displayNavBar = true;

View File

@ -27,27 +27,7 @@ import { CoreDomUtils } from '@services/utils/dom';
import { CoreFile } from '@services/file'; import { CoreFile } from '@services/file';
import { CoreError } from '@classes/errors/error'; import { CoreError } from '@classes/errors/error';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site'; import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import { ADDON_MOD_BOOK_COMPONENT } from '../constants';
/**
* Constants to define how the chapters and subchapters of a book should be displayed in that table of contents.
*/
export const enum AddonModBookNumbering {
NONE = 0,
NUMBERS = 1,
BULLETS = 2,
INDENTED = 3,
}
/**
* Constants to define the navigation style used within a book.
*/
export const enum AddonModBookNavStyle {
TOC_ONLY = 0,
IMAGE = 1,
TEXT = 2,
}
const ROOT_CACHE_KEY = 'mmaModBook:';
/** /**
* Service that provides some features for books. * Service that provides some features for books.
@ -55,7 +35,7 @@ const ROOT_CACHE_KEY = 'mmaModBook:';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class AddonModBookProvider { export class AddonModBookProvider {
static readonly COMPONENT = 'mmaModBook'; protected static readonly ROOT_CACHE_KEY = 'mmaModBook:';
/** /**
* Get a book by course module ID. * Get a book by course module ID.
@ -92,7 +72,7 @@ export class AddonModBookProvider {
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getBookDataCacheKey(courseId), cacheKey: this.getBookDataCacheKey(courseId),
updateFrequency: CoreSite.FREQUENCY_RARELY, updateFrequency: CoreSite.FREQUENCY_RARELY,
component: AddonModBookProvider.COMPONENT, component: ADDON_MOD_BOOK_COMPONENT,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), ...CoreSites.getReadingStrategyPreSets(options.readingStrategy),
}; };
@ -114,7 +94,7 @@ export class AddonModBookProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected getBookDataCacheKey(courseId: number): string { protected getBookDataCacheKey(courseId: number): string {
return ROOT_CACHE_KEY + 'book:' + courseId; return AddonModBookProvider.ROOT_CACHE_KEY + 'book:' + courseId;
} }
/** /**
@ -140,7 +120,7 @@ export class AddonModBookProvider {
const siteId = CoreSites.getCurrentSiteId(); const siteId = CoreSites.getCurrentSiteId();
const url = await CoreFilepool.downloadUrl(siteId, indexUrl, false, AddonModBookProvider.COMPONENT, moduleId); const url = await CoreFilepool.downloadUrl(siteId, indexUrl, false, ADDON_MOD_BOOK_COMPONENT, moduleId);
const content = await CoreWS.getText(url); const content = await CoreWS.getText(url);
@ -226,7 +206,7 @@ export class AddonModBookProvider {
*/ */
async getLastChapterViewed(id: number, siteId?: string): Promise<number | undefined> { async getLastChapterViewed(id: number, siteId?: string): Promise<number | undefined> {
const site = await CoreSites.getSite(siteId); const site = await CoreSites.getSite(siteId);
const entry = await site.getLastViewed(AddonModBookProvider.COMPONENT, id); const entry = await site.getLastViewed(ADDON_MOD_BOOK_COMPONENT, id);
const chapterId = Number(entry?.value); const chapterId = Number(entry?.value);
@ -327,7 +307,7 @@ export class AddonModBookProvider {
const promises: Promise<void>[] = []; const promises: Promise<void>[] = [];
promises.push(this.invalidateBookData(courseId, siteId)); promises.push(this.invalidateBookData(courseId, siteId));
promises.push(CoreFilepool.invalidateFilesByComponent(siteId, AddonModBookProvider.COMPONENT, moduleId)); promises.push(CoreFilepool.invalidateFilesByComponent(siteId, ADDON_MOD_BOOK_COMPONENT, moduleId));
promises.push(CoreCourse.invalidateModule(moduleId, siteId)); promises.push(CoreCourse.invalidateModule(moduleId, siteId));
return CoreUtils.allPromises(promises); return CoreUtils.allPromises(promises);
@ -372,7 +352,7 @@ export class AddonModBookProvider {
await CoreCourseLogHelper.log( await CoreCourseLogHelper.log(
'mod_book_view_book', 'mod_book_view_book',
params, params,
AddonModBookProvider.COMPONENT, ADDON_MOD_BOOK_COMPONENT,
id, id,
siteId, siteId,
); );
@ -390,7 +370,7 @@ export class AddonModBookProvider {
async storeLastChapterViewed(id: number, chapterId: number, courseId: number, siteId?: string): Promise<void> { async storeLastChapterViewed(id: number, chapterId: number, courseId: number, siteId?: string): Promise<void> {
const site = await CoreSites.getSite(siteId); const site = await CoreSites.getSite(siteId);
await site.storeLastViewed(AddonModBookProvider.COMPONENT, id, chapterId, { data: String(courseId) }); await site.storeLastViewed(ADDON_MOD_BOOK_COMPONENT, id, chapterId, { data: String(courseId) });
} }
} }

View File

@ -18,6 +18,7 @@ import { CoreConstants, ModPurpose } from '@/core/constants';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate'; import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler'; import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
import { ADDON_MOD_BOOK_PAGE_NAME } from '../../constants';
/** /**
* Handler to support book modules. * Handler to support book modules.
@ -25,11 +26,9 @@ import { CoreModuleHandlerBase } from '@features/course/classes/module-base-hand
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class AddonModBookModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler { export class AddonModBookModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler {
static readonly PAGE_NAME = 'mod_book';
name = 'AddonModBook'; name = 'AddonModBook';
modName = 'book'; modName = 'book';
protected pageName = AddonModBookModuleHandlerService.PAGE_NAME; protected pageName = ADDON_MOD_BOOK_PAGE_NAME;
supportedFeatures = { supportedFeatures = {
[CoreConstants.FEATURE_MOD_ARCHETYPE]: CoreConstants.MOD_ARCHETYPE_RESOURCE, [CoreConstants.FEATURE_MOD_ARCHETYPE]: CoreConstants.MOD_ARCHETYPE_RESOURCE,

View File

@ -19,7 +19,8 @@ import { CoreCourseModuleData } from '@features/course/services/course-helper';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreWSFile } from '@services/ws'; import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonModBook, AddonModBookProvider } from '../book'; import { AddonModBook } from '../book';
import { ADDON_MOD_BOOK_COMPONENT } from '../../constants';
/** /**
* Handler to prefetch books. * Handler to prefetch books.
@ -29,7 +30,7 @@ export class AddonModBookPrefetchHandlerService extends CoreCourseResourcePrefet
name = 'AddonModBook'; name = 'AddonModBook';
modName = 'book'; modName = 'book';
component = AddonModBookProvider.COMPONENT; component = ADDON_MOD_BOOK_COMPONENT;
updatesNames = /^configuration$|^.*files$|^entries$/; updatesNames = /^configuration$|^.*files$|^entries$/;
/** /**

View File

@ -80,4 +80,4 @@ const routes: Routes = [
AddonModChatSessionMessagesPage, AddonModChatSessionMessagesPage,
], ],
}) })
export class AddonModChatLazyModule {} export default class AddonModChatLazyModule {}

View File

@ -28,7 +28,7 @@ import { ADDON_MOD_CHAT_COMPONENT, ADDON_MOD_CHAT_PAGE_NAME } from './constants'
const routes: Routes = [ const routes: Routes = [
{ {
path: ADDON_MOD_CHAT_PAGE_NAME, path: ADDON_MOD_CHAT_PAGE_NAME,
loadChildren: () => import('./chat-lazy.module').then(m => m.AddonModChatLazyModule), loadChildren: () => import('./chat-lazy.module'),
}, },
]; ];

View File

@ -16,7 +16,6 @@ import { Component, ViewChild, OnInit, OnDestroy } from '@angular/core';
import { CoreSendMessageFormComponent } from '@components/send-message-form/send-message-form'; import { CoreSendMessageFormComponent } from '@components/send-message-form/send-message-form';
import { CanLeave } from '@guards/can-leave'; import { CanLeave } from '@guards/can-leave';
import { IonContent } from '@ionic/angular'; import { IonContent } from '@ionic/angular';
import { CoreApp } from '@services/app';
import { CoreNetwork } from '@services/network'; import { CoreNetwork } from '@services/network';
import { CoreNavigator } from '@services/navigator'; import { CoreNavigator } from '@services/navigator';
import { CoreSites } from '@services/sites'; import { CoreSites } from '@services/sites';
@ -30,6 +29,7 @@ import { AddonModChat, AddonModChatUser } from '../../services/chat';
import { AddonModChatFormattedMessage, AddonModChatHelper } from '../../services/chat-helper'; import { AddonModChatFormattedMessage, AddonModChatHelper } from '../../services/chat-helper';
import { CoreTime } from '@singletons/time'; import { CoreTime } from '@singletons/time';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { CoreKeyboard } from '@singletons/keyboard';
/** /**
* Page that displays a chat session. * Page that displays a chat session.
@ -323,7 +323,7 @@ export class AddonModChatChatPage implements OnInit, OnDestroy, CanLeave {
} catch (error) { } catch (error) {
// Only close the keyboard if an error happens, we want the user to be able to send multiple // Only close the keyboard if an error happens, we want the user to be able to send multiple
// messages without the keyboard being closed. // messages without the keyboard being closed.
CoreApp.closeKeyboard(); CoreKeyboard.close();
this.newMessage = text; this.newMessage = text;
CoreDomUtils.showErrorModalDefault(error, 'addon.mod_chat.errorwhilesendingmessage', true); CoreDomUtils.showErrorModalDefault(error, 'addon.mod_chat.errorwhilesendingmessage', true);

View File

@ -35,4 +35,4 @@ const routes: Routes = [
AddonModChoiceIndexPage, AddonModChoiceIndexPage,
], ],
}) })
export class AddonModChoiceLazyModule {} export default class AddonModChoiceLazyModule {}

View File

@ -25,15 +25,15 @@ import { CORE_SITE_SCHEMAS } from '@services/sites';
import { OFFLINE_SITE_SCHEMA } from './services/database/choice'; import { OFFLINE_SITE_SCHEMA } from './services/database/choice';
import { AddonModChoiceIndexLinkHandler } from './services/handlers/index-link'; import { AddonModChoiceIndexLinkHandler } from './services/handlers/index-link';
import { AddonModChoiceListLinkHandler } from './services/handlers/list-link'; import { AddonModChoiceListLinkHandler } from './services/handlers/list-link';
import { AddonModChoiceModuleHandler, AddonModChoiceModuleHandlerService } from './services/handlers/module'; import { AddonModChoiceModuleHandler } from './services/handlers/module';
import { AddonModChoicePrefetchHandler } from './services/handlers/prefetch'; import { AddonModChoicePrefetchHandler } from './services/handlers/prefetch';
import { AddonModChoiceSyncCronHandler } from './services/handlers/sync-cron'; import { AddonModChoiceSyncCronHandler } from './services/handlers/sync-cron';
import { ADDON_MOD_CHOICE_COMPONENT } from './constants'; import { ADDON_MOD_CHOICE_COMPONENT, ADDON_MOD_CHOICE_PAGE_NAME } from './constants';
const routes: Routes = [ const routes: Routes = [
{ {
path: AddonModChoiceModuleHandlerService.PAGE_NAME, path: ADDON_MOD_CHOICE_PAGE_NAME,
loadChildren: () => import('./choice-lazy.module').then(m => m.AddonModChoiceLazyModule), loadChildren: () => import('./choice-lazy.module'),
}, },
]; ];

View File

@ -32,11 +32,15 @@ import { AddonModChoiceOffline } from '../../services/choice-offline';
import { import {
AddonModChoiceAutoSyncData, AddonModChoiceAutoSyncData,
AddonModChoiceSync, AddonModChoiceSync,
AddonModChoiceSyncProvider,
AddonModChoiceSyncResult, AddonModChoiceSyncResult,
} from '../../services/choice-sync'; } from '../../services/choice-sync';
import { AddonModChoicePrefetchHandler } from '../../services/handlers/prefetch'; import { AddonModChoicePrefetchHandler } from '../../services/handlers/prefetch';
import { ADDON_MOD_CHOICE_COMPONENT, ADDON_MOD_CHOICE_PUBLISH_ANONYMOUS, AddonModChoiceShowResults } from '../../constants'; import {
ADDON_MOD_CHOICE_AUTO_SYNCED,
ADDON_MOD_CHOICE_COMPONENT,
ADDON_MOD_CHOICE_PUBLISH_ANONYMOUS,
AddonModChoiceShowResults,
} from '../../constants';
/** /**
* Component that displays a choice. * Component that displays a choice.
@ -64,7 +68,7 @@ export class AddonModChoiceIndexComponent extends CoreCourseModuleMainActivityCo
publishInfo?: string; // Message explaining the user what will happen with his choices. publishInfo?: string; // Message explaining the user what will happen with his choices.
protected userId?: number; protected userId?: number;
protected syncEventName = AddonModChoiceSyncProvider.AUTO_SYNCED; protected syncEventName = ADDON_MOD_CHOICE_AUTO_SYNCED;
protected hasAnsweredOnline = false; protected hasAnsweredOnline = false;
protected now = CoreTimeUtils.timestamp(); protected now = CoreTimeUtils.timestamp();

View File

@ -13,6 +13,7 @@
// limitations under the License. // limitations under the License.
export const ADDON_MOD_CHOICE_COMPONENT = 'mmaModChoice'; export const ADDON_MOD_CHOICE_COMPONENT = 'mmaModChoice';
export const ADDON_MOD_CHOICE_PAGE_NAME = 'mod_choice';
/** /**
* Possible show results values. * Possible show results values.
@ -27,3 +28,5 @@ export const enum AddonModChoiceShowResults {
// Possible choice publish values. // Possible choice publish values.
export const ADDON_MOD_CHOICE_PUBLISH_ANONYMOUS = false; export const ADDON_MOD_CHOICE_PUBLISH_ANONYMOUS = false;
export const ADDON_MOD_CHOICE_PUBLISH_NAMES = true; export const ADDON_MOD_CHOICE_PUBLISH_NAMES = true;
export const ADDON_MOD_CHOICE_AUTO_SYNCED = 'addon_mod_choice_autom_synced';

View File

@ -26,7 +26,7 @@ import { CoreEvents } from '@singletons/events';
import { AddonModChoice } from './choice'; import { AddonModChoice } from './choice';
import { AddonModChoiceOffline } from './choice-offline'; import { AddonModChoiceOffline } from './choice-offline';
import { AddonModChoicePrefetchHandler } from './handlers/prefetch'; import { AddonModChoicePrefetchHandler } from './handlers/prefetch';
import { ADDON_MOD_CHOICE_COMPONENT } from '../constants'; import { ADDON_MOD_CHOICE_AUTO_SYNCED, ADDON_MOD_CHOICE_COMPONENT } from '../constants';
/** /**
* Service to sync choices. * Service to sync choices.
@ -34,8 +34,6 @@ import { ADDON_MOD_CHOICE_COMPONENT } from '../constants';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class AddonModChoiceSyncProvider extends CoreCourseActivitySyncBaseProvider<AddonModChoiceSyncResult> { export class AddonModChoiceSyncProvider extends CoreCourseActivitySyncBaseProvider<AddonModChoiceSyncResult> {
static readonly AUTO_SYNCED = 'addon_mod_choice_autom_synced';
protected componentTranslatableString = 'choice'; protected componentTranslatableString = 'choice';
constructor() { constructor() {
@ -82,7 +80,7 @@ export class AddonModChoiceSyncProvider extends CoreCourseActivitySyncBaseProvid
if (result?.updated) { if (result?.updated) {
// Sync successful, send event. // Sync successful, send event.
CoreEvents.trigger(AddonModChoiceSyncProvider.AUTO_SYNCED, { CoreEvents.trigger(ADDON_MOD_CHOICE_AUTO_SYNCED, {
choiceId: response.choiceid, choiceId: response.choiceid,
userId: response.userid, userId: response.userid,
warnings: result.warnings, warnings: result.warnings,

View File

@ -25,9 +25,9 @@ import { CoreUtils } from '@services/utils/utils';
import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws'; import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
import { makeSingleton, Translate } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
import { AddonModChoiceOffline } from './choice-offline'; import { AddonModChoiceOffline } from './choice-offline';
import { AddonModChoiceAutoSyncData, AddonModChoiceSyncProvider } from './choice-sync'; import { AddonModChoiceAutoSyncData } from './choice-sync';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site'; import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import { ADDON_MOD_CHOICE_COMPONENT, AddonModChoiceShowResults } from '../constants'; import { ADDON_MOD_CHOICE_AUTO_SYNCED, ADDON_MOD_CHOICE_COMPONENT, AddonModChoiceShowResults } from '../constants';
/** /**
* Service that provides some features for choices. * Service that provides some features for choices.
@ -611,7 +611,7 @@ declare module '@singletons/events' {
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
*/ */
export interface CoreEventsData { export interface CoreEventsData {
[AddonModChoiceSyncProvider.AUTO_SYNCED]: AddonModChoiceAutoSyncData; [ADDON_MOD_CHOICE_AUTO_SYNCED]: AddonModChoiceAutoSyncData;
} }
} }

View File

@ -17,6 +17,7 @@ import { Injectable, Type } from '@angular/core';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler'; import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate'; import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { ADDON_MOD_CHOICE_PAGE_NAME } from '../../constants';
/** /**
* Handler to support choice modules. * Handler to support choice modules.
@ -24,11 +25,9 @@ import { makeSingleton } from '@singletons';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class AddonModChoiceModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler { export class AddonModChoiceModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler {
static readonly PAGE_NAME = 'mod_choice';
name = 'AddonModChoice'; name = 'AddonModChoice';
modName = 'choice'; modName = 'choice';
protected pageName = AddonModChoiceModuleHandlerService.PAGE_NAME; protected pageName = ADDON_MOD_CHOICE_PAGE_NAME;
supportedFeatures = { supportedFeatures = {
[CoreConstants.FEATURE_GROUPS]: true, [CoreConstants.FEATURE_GROUPS]: true,

View File

@ -24,14 +24,13 @@ import {
AddonModDataData, AddonModDataData,
AddonModDataEntry, AddonModDataEntry,
AddonModDataGetDataAccessInformationWSResponse, AddonModDataGetDataAccessInformationWSResponse,
AddonModDataProvider,
AddonModDataTemplateMode, AddonModDataTemplateMode,
} from '../../services/data'; } from '../../services/data';
import { AddonModDataHelper } from '../../services/data-helper'; import { AddonModDataHelper } from '../../services/data-helper';
import { AddonModDataOffline } from '../../services/data-offline'; import { AddonModDataOffline } from '../../services/data-offline';
import { AddonModDataModuleHandlerService } from '../../services/handlers/module';
import { CoreDomUtils } from '@services/utils/dom'; import { CoreDomUtils } from '@services/utils/dom';
import { AddonModDataActionsMenuComponent, AddonModDataActionsMenuItem } from '../actionsmenu/actionsmenu'; import { AddonModDataActionsMenuComponent, AddonModDataActionsMenuItem } from '../actionsmenu/actionsmenu';
import { ADDON_MOD_DATA_ENTRY_CHANGED, ADDON_MOD_DATA_PAGE_NAME } from '../../constants';
/** /**
* Component that displays a database action. * Component that displays a database action.
@ -101,7 +100,7 @@ export class AddonModDataActionComponent implements OnInit {
title: this.title, title: this.title,
}; };
const basePath = AddonModDataModuleHandlerService.PAGE_NAME; const basePath = ADDON_MOD_DATA_PAGE_NAME;
CoreNavigator.navigateToSitePath( CoreNavigator.navigateToSitePath(
`${basePath}/${this.database.course}/${this.database.coursemodule}/edit/${this.entry.id}`, `${basePath}/${this.database.course}/${this.database.coursemodule}/edit/${this.entry.id}`,
{ params }, { params },
@ -120,7 +119,7 @@ export class AddonModDataActionComponent implements OnInit {
sortDirection: this.sortDirection, sortDirection: this.sortDirection,
}; };
const basePath = AddonModDataModuleHandlerService.PAGE_NAME; const basePath = ADDON_MOD_DATA_PAGE_NAME;
CoreNavigator.navigateToSitePath( CoreNavigator.navigateToSitePath(
`${basePath}/${this.database.course}/${this.database.coursemodule}/${this.entry.id}`, `${basePath}/${this.database.course}/${this.database.coursemodule}/${this.entry.id}`,
{ params }, { params },
@ -140,7 +139,7 @@ export class AddonModDataActionComponent implements OnInit {
// Found. Just delete the action. // Found. Just delete the action.
await AddonModDataOffline.deleteEntry(dataId, entryId, AddonModDataAction.DELETE, this.siteId); await AddonModDataOffline.deleteEntry(dataId, entryId, AddonModDataAction.DELETE, this.siteId);
CoreEvents.trigger(AddonModDataProvider.ENTRY_CHANGED, { dataId: dataId, entryId: entryId }, this.siteId); CoreEvents.trigger(ADDON_MOD_DATA_ENTRY_CHANGED, { dataId: dataId, entryId: entryId }, this.siteId);
} }
/** /**

View File

@ -29,7 +29,6 @@ import { CoreTimeUtils } from '@services/utils/time';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { import {
AddonModDataProvider,
AddonModData, AddonModData,
AddonModDataEntry, AddonModDataEntry,
AddonModDataTemplateType, AddonModDataTemplateType,
@ -40,13 +39,19 @@ import {
AddonModDataSearchEntriesAdvancedField, AddonModDataSearchEntriesAdvancedField,
} from '../../services/data'; } from '../../services/data';
import { AddonModDataHelper, AddonModDatDisplayFieldsOptions } from '../../services/data-helper'; import { AddonModDataHelper, AddonModDatDisplayFieldsOptions } from '../../services/data-helper';
import { AddonModDataAutoSyncData, AddonModDataSyncProvider, AddonModDataSyncResult } from '../../services/data-sync'; import { AddonModDataAutoSyncData, AddonModDataSyncResult } from '../../services/data-sync';
import { AddonModDataModuleHandlerService } from '../../services/handlers/module';
import { AddonModDataPrefetchHandler } from '../../services/handlers/prefetch'; import { AddonModDataPrefetchHandler } from '../../services/handlers/prefetch';
import { AddonModDataComponentsCompileModule } from '../components-compile.module'; import { AddonModDataComponentsCompileModule } from '../components-compile.module';
import { AddonModDataSearchComponent } from '../search/search'; import { AddonModDataSearchComponent } from '../search/search';
import { CoreUrlUtils } from '@services/utils/url'; import { CoreUrlUtils } from '@services/utils/url';
import { CoreTime } from '@singletons/time'; import { CoreTime } from '@singletons/time';
import {
ADDON_MOD_DATA_AUTO_SYNCED,
ADDON_MOD_DATA_COMPONENT,
ADDON_MOD_DATA_ENTRIES_PER_PAGE,
ADDON_MOD_DATA_ENTRY_CHANGED,
ADDON_MOD_DATA_PAGE_NAME,
} from '../../constants';
const contentToken = '<!-- CORE-DATABASE-CONTENT-GOES-HERE -->'; const contentToken = '<!-- CORE-DATABASE-CONTENT-GOES-HERE -->';
@ -60,7 +65,7 @@ const contentToken = '<!-- CORE-DATABASE-CONTENT-GOES-HERE -->';
}) })
export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComponent implements OnInit, OnDestroy { export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComponent implements OnInit, OnDestroy {
component = AddonModDataProvider.COMPONENT; component = ADDON_MOD_DATA_COMPONENT;
pluginName = 'data'; pluginName = 'data';
access?: AddonModDataGetDataAccessInformationWSResponse; access?: AddonModDataGetDataAccessInformationWSResponse;
@ -110,7 +115,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
hasOfflineRatings = false; hasOfflineRatings = false;
protected syncEventName = AddonModDataSyncProvider.AUTO_SYNCED; protected syncEventName = ADDON_MOD_DATA_AUTO_SYNCED;
protected hasComments = false; protected hasComments = false;
protected fieldsArray: AddonModDataField[] = []; protected fieldsArray: AddonModDataField[] = [];
protected entryChangedObserver?: CoreEventObserver; protected entryChangedObserver?: CoreEventObserver;
@ -134,7 +139,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
this.selectedGroup = this.group || 0; this.selectedGroup = this.group || 0;
// Refresh entries on change. // Refresh entries on change.
this.entryChangedObserver = CoreEvents.on(AddonModDataProvider.ENTRY_CHANGED, (eventData) => { this.entryChangedObserver = CoreEvents.on(ADDON_MOD_DATA_ENTRY_CHANGED, (eventData) => {
if (this.database?.id == eventData.dataId) { if (this.database?.id == eventData.dataId) {
this.showLoading = true; this.showLoading = true;
@ -303,8 +308,8 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
this.isEmpty = !numEntries && !numOfflineEntries; this.isEmpty = !numEntries && !numOfflineEntries;
this.hasNextPage = numEntries >= AddonModDataProvider.PER_PAGE && ((this.search.page + 1) * this.hasNextPage = numEntries >= ADDON_MOD_DATA_ENTRIES_PER_PAGE && ((this.search.page + 1) *
AddonModDataProvider.PER_PAGE) < entries.totalcount; ADDON_MOD_DATA_ENTRIES_PER_PAGE) < entries.totalcount;
this.hasOffline = !!entries.hasOfflineActions; this.hasOffline = !!entries.hasOfflineActions;
@ -355,7 +360,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
const actions = AddonModDataHelper.getActions(this.database!, this.access!, entry, AddonModDataTemplateMode.LIST); const actions = AddonModDataHelper.getActions(this.database!, this.access!, entry, AddonModDataTemplateMode.LIST);
const options: AddonModDatDisplayFieldsOptions = {}; const options: AddonModDatDisplayFieldsOptions = {};
if (!this.search.searching) { if (!this.search.searching) {
options.offset = this.search.page * AddonModDataProvider.PER_PAGE + index - numOfflineEntries; options.offset = this.search.page * ADDON_MOD_DATA_ENTRIES_PER_PAGE + index - numOfflineEntries;
options.sortBy = this.search.sortBy; options.sortBy = this.search.sortBy;
options.sortDirection = this.search.sortDirection; options.sortDirection = this.search.sortDirection;
} }
@ -489,7 +494,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
}; };
CoreNavigator.navigateToSitePath( CoreNavigator.navigateToSitePath(
`${AddonModDataModuleHandlerService.PAGE_NAME}/${this.courseId}/${this.module.id}/edit`, `${ADDON_MOD_DATA_PAGE_NAME}/${this.courseId}/${this.module.id}/edit`,
{ params }, { params },
); );
} }
@ -509,14 +514,14 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
if (!this.search.searching) { if (!this.search.searching) {
const pageXOffset = this.entries.findIndex((entry) => entry.id == entryId); const pageXOffset = this.entries.findIndex((entry) => entry.id == entryId);
if (pageXOffset >= 0) { if (pageXOffset >= 0) {
params.offset = this.search.page * AddonModDataProvider.PER_PAGE + pageXOffset; params.offset = this.search.page * ADDON_MOD_DATA_ENTRIES_PER_PAGE + pageXOffset;
params.sortBy = this.search.sortBy; params.sortBy = this.search.sortBy;
params.sortDirection = this.search.sortDirection; params.sortDirection = this.search.sortDirection;
} }
} }
CoreNavigator.navigateToSitePath( CoreNavigator.navigateToSitePath(
`${AddonModDataModuleHandlerService.PAGE_NAME}/${this.courseId}/${this.module.id}/${entryId}`, `${ADDON_MOD_DATA_PAGE_NAME}/${this.courseId}/${this.module.id}/${entryId}`,
{ params }, { params },
); );
} }
@ -550,7 +555,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
} }
const params: Record<string, unknown> = { const params: Record<string, unknown> = {
perpage: AddonModDataProvider.PER_PAGE, perpage: ADDON_MOD_DATA_ENTRIES_PER_PAGE,
search: !this.search.searchingAdvanced ? this.search.text : '', search: !this.search.searchingAdvanced ? this.search.text : '',
sort: this.search.sortBy, sort: this.search.sortBy,
order: this.search.sortDirection, order: this.search.sortDirection,

View File

@ -13,3 +13,11 @@
// limitations under the License. // limitations under the License.
export const ADDON_MOD_DATA_FEATURE_NAME = 'CoreCourseModuleDelegate_AddonModData'; export const ADDON_MOD_DATA_FEATURE_NAME = 'CoreCourseModuleDelegate_AddonModData';
export const ADDON_MOD_DATA_COMPONENT = 'mmaModData';
export const ADDON_MOD_DATA_PAGE_NAME = 'mod_data';
export const ADDON_MOD_DATA_ENTRIES_PER_PAGE = 25;
export const ADDON_MOD_DATA_ENTRY_CHANGED = 'addon_mod_data_entry_changed';
export const ADDON_MOD_DATA_AUTO_SYNCED = 'addon_mod_data_autom_synced';

View File

@ -62,4 +62,4 @@ const routes: Routes = [
AddonModDataEditPage, AddonModDataEditPage,
], ],
}) })
export class AddonModDataLazyModule {} export default class AddonModDataLazyModule {}

View File

@ -21,25 +21,25 @@ import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-ro
import { CoreTagAreaDelegate } from '@features/tag/services/tag-area-delegate'; import { CoreTagAreaDelegate } from '@features/tag/services/tag-area-delegate';
import { CoreCronDelegate } from '@services/cron'; import { CoreCronDelegate } from '@services/cron';
import { CORE_SITE_SCHEMAS } from '@services/sites'; import { CORE_SITE_SCHEMAS } from '@services/sites';
import { AddonModDataProvider } from './services/data';
import { ADDON_MOD_DATA_OFFLINE_SITE_SCHEMA } from './services/database/data'; import { ADDON_MOD_DATA_OFFLINE_SITE_SCHEMA } from './services/database/data';
import { AddonModDataApproveLinkHandler } from './services/handlers/approve-link'; import { AddonModDataApproveLinkHandler } from './services/handlers/approve-link';
import { AddonModDataDeleteLinkHandler } from './services/handlers/delete-link'; import { AddonModDataDeleteLinkHandler } from './services/handlers/delete-link';
import { AddonModDataEditLinkHandler } from './services/handlers/edit-link'; import { AddonModDataEditLinkHandler } from './services/handlers/edit-link';
import { AddonModDataIndexLinkHandler } from './services/handlers/index-link'; import { AddonModDataIndexLinkHandler } from './services/handlers/index-link';
import { AddonModDataListLinkHandler } from './services/handlers/list-link'; import { AddonModDataListLinkHandler } from './services/handlers/list-link';
import { AddonModDataModuleHandler, AddonModDataModuleHandlerService } from './services/handlers/module'; import { AddonModDataModuleHandler } from './services/handlers/module';
import { AddonModDataPrefetchHandler } from './services/handlers/prefetch'; import { AddonModDataPrefetchHandler } from './services/handlers/prefetch';
import { AddonModDataShowLinkHandler } from './services/handlers/show-link'; import { AddonModDataShowLinkHandler } from './services/handlers/show-link';
import { AddonModDataSyncCronHandler } from './services/handlers/sync-cron'; import { AddonModDataSyncCronHandler } from './services/handlers/sync-cron';
import { AddonModDataTagAreaHandler } from './services/handlers/tag-area'; import { AddonModDataTagAreaHandler } from './services/handlers/tag-area';
import { AddonModDataFieldModule } from './fields/field.module'; import { AddonModDataFieldModule } from './fields/field.module';
import { CoreCourseHelper } from '@features/course/services/course-helper'; import { CoreCourseHelper } from '@features/course/services/course-helper';
import { ADDON_MOD_DATA_COMPONENT, ADDON_MOD_DATA_PAGE_NAME } from './constants';
const routes: Routes = [ const routes: Routes = [
{ {
path: AddonModDataModuleHandlerService.PAGE_NAME, path: ADDON_MOD_DATA_PAGE_NAME,
loadChildren: () => import('./data-lazy.module').then(m => m.AddonModDataLazyModule), loadChildren: () => import('./data-lazy.module'),
}, },
]; ];
@ -69,7 +69,7 @@ const routes: Routes = [
CoreContentLinksDelegate.registerHandler(AddonModDataEditLinkHandler.instance); CoreContentLinksDelegate.registerHandler(AddonModDataEditLinkHandler.instance);
CoreTagAreaDelegate.registerHandler(AddonModDataTagAreaHandler.instance); CoreTagAreaDelegate.registerHandler(AddonModDataTagAreaHandler.instance);
CoreCourseHelper.registerModuleReminderClick(AddonModDataProvider.COMPONENT); CoreCourseHelper.registerModuleReminderClick(ADDON_MOD_DATA_COMPONENT);
}, },
}, },
], ],

View File

@ -13,10 +13,11 @@
// limitations under the License. // limitations under the License.
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { AddonModDataEntryField, AddonModDataProvider } from '@addons/mod/data/services/data'; import { AddonModDataEntryField } from '@addons/mod/data/services/data';
import { AddonModDataFieldPluginBaseComponent } from '@addons/mod/data/classes/base-field-plugin-component'; import { AddonModDataFieldPluginBaseComponent } from '@addons/mod/data/classes/base-field-plugin-component';
import { CoreFileSession } from '@services/file-session'; import { CoreFileSession } from '@services/file-session';
import { CoreFileEntry } from '@services/file-helper'; import { CoreFileEntry } from '@services/file-helper';
import { ADDON_MOD_DATA_COMPONENT } from '@addons/mod/data/constants';
/** /**
* Component to render data file field. * Component to render data file field.
@ -59,7 +60,7 @@ export class AddonModDataFieldFileComponent extends AddonModDataFieldPluginBaseC
return; return;
} }
this.component = AddonModDataProvider.COMPONENT; this.component = ADDON_MOD_DATA_COMPONENT;
this.componentId = this.database!.coursemodule; this.componentId = this.database!.coursemodule;
this.updateValue(this.value); this.updateValue(this.value);

View File

@ -15,7 +15,6 @@
import { import {
AddonModDataEntryField, AddonModDataEntryField,
AddonModDataField, AddonModDataField,
AddonModDataProvider,
AddonModDataSearchEntriesAdvancedFieldFormatted, AddonModDataSearchEntriesAdvancedFieldFormatted,
AddonModDataSubfieldData, AddonModDataSubfieldData,
} from '@addons/mod/data/services/data'; } from '@addons/mod/data/services/data';
@ -29,6 +28,7 @@ import { makeSingleton, Translate } from '@singletons';
import { AddonModDataFieldFileComponent } from '../component/file'; import { AddonModDataFieldFileComponent } from '../component/file';
import { CoreFileEntry } from '@services/file-helper'; import { CoreFileEntry } from '@services/file-helper';
import type { AddonModDataFieldPluginBaseComponent } from '@addons/mod/data/classes/base-field-plugin-component'; import type { AddonModDataFieldPluginBaseComponent } from '@addons/mod/data/classes/base-field-plugin-component';
import { ADDON_MOD_DATA_COMPONENT } from '@addons/mod/data/constants';
/** /**
* Handler for file data field plugin. * Handler for file data field plugin.
@ -79,14 +79,14 @@ export class AddonModDataFieldFileHandlerService implements AddonModDataFieldHan
* @inheritdoc * @inheritdoc
*/ */
getFieldEditFiles(field: AddonModDataField): CoreFileEntry[] { getFieldEditFiles(field: AddonModDataField): CoreFileEntry[] {
return CoreFileSession.getFiles(AddonModDataProvider.COMPONENT, field.dataid + '_' + field.id); return CoreFileSession.getFiles(ADDON_MOD_DATA_COMPONENT, field.dataid + '_' + field.id);
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
hasFieldDataChanged(field: AddonModDataField, inputData: CoreFormFields, originalFieldData: AddonModDataEntryField): boolean { hasFieldDataChanged(field: AddonModDataField, inputData: CoreFormFields, originalFieldData: AddonModDataEntryField): boolean {
const files = CoreFileSession.getFiles(AddonModDataProvider.COMPONENT, field.dataid + '_' + field.id) || []; const files = CoreFileSession.getFiles(ADDON_MOD_DATA_COMPONENT, field.dataid + '_' + field.id) || [];
let originalFiles = (originalFieldData && originalFieldData.files) || []; let originalFiles = (originalFieldData && originalFieldData.files) || [];
if (originalFiles.length) { if (originalFiles.length) {

View File

@ -12,13 +12,14 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { AddonModDataEntryField, AddonModDataProvider } from '@addons/mod/data/services/data'; import { AddonModDataEntryField } from '@addons/mod/data/services/data';
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { CoreFileEntry, CoreFileHelper } from '@services/file-helper'; import { CoreFileEntry, CoreFileHelper } from '@services/file-helper';
import { CoreFileSession } from '@services/file-session'; import { CoreFileSession } from '@services/file-session';
import { CoreDomUtils } from '@services/utils/dom'; import { CoreDomUtils } from '@services/utils/dom';
import { AddonModDataFieldPluginBaseComponent } from '../../../classes/base-field-plugin-component'; import { AddonModDataFieldPluginBaseComponent } from '../../../classes/base-field-plugin-component';
import { CoreFile } from '@services/file'; import { CoreFile } from '@services/file';
import { ADDON_MOD_DATA_COMPONENT } from '@addons/mod/data/constants';
/** /**
* Component to render data picture field. * Component to render data picture field.
@ -82,7 +83,7 @@ export class AddonModDataFieldPictureComponent extends AddonModDataFieldPluginBa
return; return;
} }
this.component = AddonModDataProvider.COMPONENT; this.component = ADDON_MOD_DATA_COMPONENT;
this.componentId = this.database!.coursemodule; this.componentId = this.database!.coursemodule;
this.updateValue(this.value); this.updateValue(this.value);

View File

@ -15,7 +15,6 @@
import { import {
AddonModDataEntryField, AddonModDataEntryField,
AddonModDataField, AddonModDataField,
AddonModDataProvider,
AddonModDataSearchEntriesAdvancedFieldFormatted, AddonModDataSearchEntriesAdvancedFieldFormatted,
AddonModDataSubfieldData, AddonModDataSubfieldData,
} from '@addons/mod/data/services/data'; } from '@addons/mod/data/services/data';
@ -29,6 +28,7 @@ import { makeSingleton, Translate } from '@singletons';
import { AddonModDataFieldPictureComponent } from '../component/picture'; import { AddonModDataFieldPictureComponent } from '../component/picture';
import { CoreFileEntry } from '@services/file-helper'; import { CoreFileEntry } from '@services/file-helper';
import type { AddonModDataFieldPluginBaseComponent } from '@addons/mod/data/classes/base-field-plugin-component'; import type { AddonModDataFieldPluginBaseComponent } from '@addons/mod/data/classes/base-field-plugin-component';
import { ADDON_MOD_DATA_COMPONENT } from '@addons/mod/data/constants';
/** /**
* Handler for picture data field plugin. * Handler for picture data field plugin.
@ -90,7 +90,7 @@ export class AddonModDataFieldPictureHandlerService implements AddonModDataField
* @inheritdoc * @inheritdoc
*/ */
getFieldEditFiles(field: AddonModDataField): CoreFileEntry[] { getFieldEditFiles(field: AddonModDataField): CoreFileEntry[] {
return CoreFileSession.getFiles(AddonModDataProvider.COMPONENT, field.dataid + '_' + field.id); return CoreFileSession.getFiles(ADDON_MOD_DATA_COMPONENT, field.dataid + '_' + field.id);
} }
/** /**

View File

@ -14,9 +14,10 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { AddonModDataFieldPluginBaseComponent } from '../../../classes/base-field-plugin-component'; import { AddonModDataFieldPluginBaseComponent } from '../../../classes/base-field-plugin-component';
import { AddonModDataEntryField, AddonModDataProvider } from '@addons/mod/data/services/data'; import { AddonModDataEntryField } from '@addons/mod/data/services/data';
import { CoreTextUtils } from '@services/utils/text'; import { CoreTextUtils } from '@services/utils/text';
import { CoreWSFile } from '@services/ws'; import { CoreWSFile } from '@services/ws';
import { ADDON_MOD_DATA_COMPONENT } from '@addons/mod/data/constants';
/** /**
* Component to render data number field. * Component to render data number field.
@ -46,7 +47,7 @@ export class AddonModDataFieldTextareaComponent extends AddonModDataFieldPluginB
* Initialize field. * Initialize field.
*/ */
protected init(): void { protected init(): void {
this.component = AddonModDataProvider.COMPONENT; this.component = ADDON_MOD_DATA_COMPONENT;
this.componentId = this.database?.coursemodule; this.componentId = this.database?.coursemodule;
if (this.displayMode) { if (this.displayMode) {

View File

@ -30,7 +30,6 @@ import { AddonModDataComponentsCompileModule } from '../../components/components
import { import {
AddonModDataData, AddonModDataData,
AddonModDataField, AddonModDataField,
AddonModDataProvider,
AddonModData, AddonModData,
AddonModDataTemplateType, AddonModDataTemplateType,
AddonModDataEntry, AddonModDataEntry,
@ -45,6 +44,7 @@ import { AddonModDataEntryFieldInitialized } from '../../classes/base-field-plug
import { CoreTextUtils } from '@services/utils/text'; import { CoreTextUtils } from '@services/utils/text';
import { CoreTime } from '@singletons/time'; import { CoreTime } from '@singletons/time';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { ADDON_MOD_DATA_COMPONENT, ADDON_MOD_DATA_ENTRY_CHANGED } from '../../constants';
/** /**
* Page that displays the view edit page. * Page that displays the view edit page.
@ -75,7 +75,7 @@ export class AddonModDataEditPage implements OnInit {
moduleId = 0; moduleId = 0;
database?: AddonModDataData; database?: AddonModDataData;
title = ''; title = '';
component = AddonModDataProvider.COMPONENT; component = ADDON_MOD_DATA_COMPONENT;
loaded = false; loaded = false;
selectedGroup = 0; selectedGroup = 0;
cssClass = ''; cssClass = '';
@ -369,7 +369,7 @@ export class AddonModDataEditPage implements OnInit {
try { try {
await Promise.all(promises); await Promise.all(promises);
CoreEvents.trigger( CoreEvents.trigger(
AddonModDataProvider.ENTRY_CHANGED, ADDON_MOD_DATA_ENTRY_CHANGED,
{ dataId: this.database!.id, entryId: this.entryId }, { dataId: this.database!.id, entryId: this.entryId },
this.siteId, this.siteId,

View File

@ -25,7 +25,7 @@ import { CoreDomUtils } from '@services/utils/dom';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { AddonModDataComponentsCompileModule } from '../../components/components-compile.module'; import { AddonModDataComponentsCompileModule } from '../../components/components-compile.module';
import { AddonModDataProvider, import {
AddonModData, AddonModData,
AddonModDataData, AddonModDataData,
AddonModDataGetDataAccessInformationWSResponse, AddonModDataGetDataAccessInformationWSResponse,
@ -35,9 +35,14 @@ import { AddonModDataProvider,
AddonModDataEntry, AddonModDataEntry,
} from '../../services/data'; } from '../../services/data';
import { AddonModDataHelper } from '../../services/data-helper'; import { AddonModDataHelper } from '../../services/data-helper';
import { AddonModDataSyncProvider } from '../../services/data-sync';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { CoreTime } from '@singletons/time'; import { CoreTime } from '@singletons/time';
import {
ADDON_MOD_DATA_AUTO_SYNCED,
ADDON_MOD_DATA_COMPONENT,
ADDON_MOD_DATA_ENTRIES_PER_PAGE,
ADDON_MOD_DATA_ENTRY_CHANGED,
} from '../../constants';
/** /**
* Page that displays the view entry page. * Page that displays the view entry page.
@ -66,7 +71,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
offset?: number; offset?: number;
title = ''; title = '';
moduleName = 'data'; moduleName = 'data';
component = AddonModDataProvider.COMPONENT; component = ADDON_MOD_DATA_COMPONENT;
entryLoaded = false; entryLoaded = false;
renderingEntry = false; renderingEntry = false;
loadingComments = false; loadingComments = false;
@ -102,7 +107,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
this.siteId = CoreSites.getCurrentSiteId(); this.siteId = CoreSites.getCurrentSiteId();
// Refresh data if this discussion is synchronized automatically. // Refresh data if this discussion is synchronized automatically.
this.syncObserver = CoreEvents.on(AddonModDataSyncProvider.AUTO_SYNCED, (data) => { this.syncObserver = CoreEvents.on(ADDON_MOD_DATA_AUTO_SYNCED, (data) => {
if (data.entryId === undefined) { if (data.entryId === undefined) {
return; return;
} }
@ -120,7 +125,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
}, this.siteId); }, this.siteId);
// Refresh entry on change. // Refresh entry on change.
this.entryChangedObserver = CoreEvents.on(AddonModDataProvider.ENTRY_CHANGED, (data) => { this.entryChangedObserver = CoreEvents.on(ADDON_MOD_DATA_ENTRY_CHANGED, (data) => {
if (data.entryId == this.entryId && this.database?.id == data.dataId) { if (data.entryId == this.entryId && this.database?.id == data.dataId) {
if (data.deleted) { if (data.deleted) {
// If deleted, go back. // If deleted, go back.
@ -331,7 +336,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
return; return;
} }
const perPage = AddonModDataProvider.PER_PAGE; const perPage = ADDON_MOD_DATA_ENTRIES_PER_PAGE;
const page = this.offset !== undefined && this.offset >= 0 const page = this.offset !== undefined && this.offset >= 0
? Math.floor(this.offset / perPage) ? Math.floor(this.offset / perPage)
: 0; : 0;

View File

@ -28,7 +28,6 @@ import { CoreEvents } from '@singletons/events';
import { import {
AddonModDataEntry, AddonModDataEntry,
AddonModData, AddonModData,
AddonModDataProvider,
AddonModDataSearchEntriesOptions, AddonModDataSearchEntriesOptions,
AddonModDataEntries, AddonModDataEntries,
AddonModDataEntryFields, AddonModDataEntryFields,
@ -44,6 +43,7 @@ import {
import { AddonModDataFieldsDelegate } from './data-fields-delegate'; import { AddonModDataFieldsDelegate } from './data-fields-delegate';
import { AddonModDataOffline, AddonModDataOfflineAction } from './data-offline'; import { AddonModDataOffline, AddonModDataOfflineAction } from './data-offline';
import { CoreFileEntry } from '@services/file-helper'; import { CoreFileEntry } from '@services/file-helper';
import { ADDON_MOD_DATA_COMPONENT, ADDON_MOD_DATA_ENTRY_CHANGED } from '../constants';
/** /**
* Service that provides helper functions for datas. * Service that provides helper functions for datas.
@ -171,7 +171,7 @@ export class AddonModDataHelperProvider {
await CoreUtils.ignoreErrors(Promise.all(promises)); await CoreUtils.ignoreErrors(Promise.all(promises));
CoreEvents.trigger(AddonModDataProvider.ENTRY_CHANGED, { dataId: dataId, entryId: entryId }, siteId); CoreEvents.trigger(ADDON_MOD_DATA_ENTRY_CHANGED, { dataId: dataId, entryId: entryId }, siteId);
CoreDomUtils.showToast( CoreDomUtils.showToast(
approve ? 'addon.mod_data.recordapproved' : 'addon.mod_data.recorddisapproved', approve ? 'addon.mod_data.recordapproved' : 'addon.mod_data.recorddisapproved',
@ -878,7 +878,7 @@ export class AddonModDataHelperProvider {
// Ignore errors. // Ignore errors.
} }
CoreEvents.trigger(AddonModDataProvider.ENTRY_CHANGED, { dataId, entryId, deleted: true }, siteId); CoreEvents.trigger(ADDON_MOD_DATA_ENTRY_CHANGED, { dataId, entryId, deleted: true }, siteId);
CoreDomUtils.showToast('addon.mod_data.recorddeleted', true, ToastDuration.LONG); CoreDomUtils.showToast('addon.mod_data.recorddeleted', true, ToastDuration.LONG);
@ -969,7 +969,7 @@ export class AddonModDataHelperProvider {
return 0; return 0;
} }
return CoreFileUploader.uploadOrReuploadFiles(files, AddonModDataProvider.COMPONENT, itemId, siteId); return CoreFileUploader.uploadOrReuploadFiles(files, ADDON_MOD_DATA_COMPONENT, itemId, siteId);
} }
} }

View File

@ -29,9 +29,10 @@ import { CoreTextUtils } from '@services/utils/text';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { Translate, makeSingleton } from '@singletons'; import { Translate, makeSingleton } from '@singletons';
import { CoreEvents } from '@singletons/events'; import { CoreEvents } from '@singletons/events';
import { AddonModDataProvider, AddonModData, AddonModDataData, AddonModDataAction } from './data'; import { AddonModData, AddonModDataData, AddonModDataAction } from './data';
import { AddonModDataHelper } from './data-helper'; import { AddonModDataHelper } from './data-helper';
import { AddonModDataOffline, AddonModDataOfflineAction } from './data-offline'; import { AddonModDataOffline, AddonModDataOfflineAction } from './data-offline';
import { ADDON_MOD_DATA_AUTO_SYNCED, ADDON_MOD_DATA_COMPONENT } from '../constants';
/** /**
* Service to sync databases. * Service to sync databases.
@ -39,8 +40,6 @@ import { AddonModDataOffline, AddonModDataOfflineAction } from './data-offline';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider<AddonModDataSyncResult> { export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider<AddonModDataSyncResult> {
static readonly AUTO_SYNCED = 'addon_mod_data_autom_synced';
protected componentTranslatableString = 'data'; protected componentTranslatableString = 'data';
constructor() { constructor() {
@ -93,7 +92,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
if (result && result.updated) { if (result && result.updated) {
// Sync done. Send event. // Sync done. Send event.
CoreEvents.trigger(AddonModDataSyncProvider.AUTO_SYNCED, { CoreEvents.trigger(ADDON_MOD_DATA_AUTO_SYNCED, {
dataId: dataId, dataId: dataId,
warnings: result.warnings, warnings: result.warnings,
}, siteId); }, siteId);
@ -142,7 +141,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
} }
// Verify that database isn't blocked. // Verify that database isn't blocked.
if (CoreSync.isBlocked(AddonModDataProvider.COMPONENT, dataId, siteId)) { if (CoreSync.isBlocked(ADDON_MOD_DATA_COMPONENT, dataId, siteId)) {
this.logger.debug(`Cannot sync database '${dataId}' because it is blocked.`); this.logger.debug(`Cannot sync database '${dataId}' because it is blocked.`);
throw new CoreSyncBlockedError(Translate.instant('core.errorsyncblocked', { $a: this.componentTranslate })); throw new CoreSyncBlockedError(Translate.instant('core.errorsyncblocked', { $a: this.componentTranslate }));
@ -165,7 +164,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
protected async performSyncDatabase(dataId: number, siteId: string): Promise<AddonModDataSyncResult> { protected async performSyncDatabase(dataId: number, siteId: string): Promise<AddonModDataSyncResult> {
// Sync offline logs. // Sync offline logs.
await CoreUtils.ignoreErrors( await CoreUtils.ignoreErrors(
CoreCourseLogHelper.syncActivity(AddonModDataProvider.COMPONENT, dataId, siteId), CoreCourseLogHelper.syncActivity(ADDON_MOD_DATA_COMPONENT, dataId, siteId),
); );
const result: AddonModDataSyncResult = { const result: AddonModDataSyncResult = {
@ -243,7 +242,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
} }
// Sync done. Send event. // Sync done. Send event.
CoreEvents.trigger(AddonModDataSyncProvider.AUTO_SYNCED, { CoreEvents.trigger(ADDON_MOD_DATA_AUTO_SYNCED, {
dataId: database.id, dataId: database.id,
entryId: syncEntryResult.entryId, entryId: syncEntryResult.entryId,
offlineEntryId: syncEntryResult.offlineId, offlineEntryId: syncEntryResult.offlineId,

View File

@ -28,10 +28,14 @@ import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
import { makeSingleton, Translate } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
import { AddonModDataFieldsDelegate } from './data-fields-delegate'; import { AddonModDataFieldsDelegate } from './data-fields-delegate';
import { AddonModDataOffline } from './data-offline'; import { AddonModDataOffline } from './data-offline';
import { AddonModDataAutoSyncData, AddonModDataSyncProvider } from './data-sync'; import { AddonModDataAutoSyncData } from './data-sync';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site'; import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import {
const ROOT_CACHE_KEY = 'mmaModData:'; ADDON_MOD_DATA_AUTO_SYNCED,
ADDON_MOD_DATA_COMPONENT,
ADDON_MOD_DATA_ENTRIES_PER_PAGE,
ADDON_MOD_DATA_ENTRY_CHANGED,
} from '../constants';
declare module '@singletons/events' { declare module '@singletons/events' {
@ -41,8 +45,8 @@ declare module '@singletons/events' {
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
*/ */
export interface CoreEventsData { export interface CoreEventsData {
[AddonModDataSyncProvider.AUTO_SYNCED]: AddonModDataAutoSyncData; [ADDON_MOD_DATA_AUTO_SYNCED]: AddonModDataAutoSyncData;
[AddonModDataProvider.ENTRY_CHANGED]: AddonModDataEntryChangedEventData; [ADDON_MOD_DATA_ENTRY_CHANGED]: AddonModDataEntryChangedEventData;
} }
} }
@ -90,9 +94,7 @@ export enum AddonModDataTemplateMode {
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class AddonModDataProvider { export class AddonModDataProvider {
static readonly COMPONENT = 'mmaModData'; protected static readonly ROOT_CACHE_KEY = 'mmaModData:';
static readonly PER_PAGE = 25;
static readonly ENTRY_CHANGED = 'addon_mod_data_entry_changed';
/** /**
* Adds a new entry to a database. * Adds a new entry to a database.
@ -504,7 +506,7 @@ export class AddonModDataProvider {
options.siteId = options.siteId || CoreSites.getCurrentSiteId(); options.siteId = options.siteId || CoreSites.getCurrentSiteId();
options = Object.assign({ options = Object.assign({
page: 0, page: 0,
perPage: AddonModDataProvider.PER_PAGE, perPage: ADDON_MOD_DATA_ENTRIES_PER_PAGE,
}, options); }, options);
return this.fetchEntriesRecursive(dataId, [], options); return this.fetchEntriesRecursive(dataId, [], options);
@ -543,7 +545,7 @@ export class AddonModDataProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected getDatabaseDataCacheKey(courseId: number): string { protected getDatabaseDataCacheKey(courseId: number): string {
return ROOT_CACHE_KEY + 'data:' + courseId; return AddonModDataProvider.ROOT_CACHE_KEY + 'data:' + courseId;
} }
/** /**
@ -553,7 +555,7 @@ export class AddonModDataProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected getDatabaseDataPrefixCacheKey(dataId: number): string { protected getDatabaseDataPrefixCacheKey(dataId: number): string {
return ROOT_CACHE_KEY + dataId; return AddonModDataProvider.ROOT_CACHE_KEY + dataId;
} }
/** /**
@ -579,7 +581,7 @@ export class AddonModDataProvider {
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getDatabaseDataCacheKey(courseId), cacheKey: this.getDatabaseDataCacheKey(courseId),
updateFrequency: CoreSite.FREQUENCY_RARELY, updateFrequency: CoreSite.FREQUENCY_RARELY,
component: AddonModDataProvider.COMPONENT, component: ADDON_MOD_DATA_COMPONENT,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
const response = const response =
@ -660,7 +662,7 @@ export class AddonModDataProvider {
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getDatabaseAccessInformationDataCacheKey(dataId, options.groupId), cacheKey: this.getDatabaseAccessInformationDataCacheKey(dataId, options.groupId),
component: AddonModDataProvider.COMPONENT, component: ADDON_MOD_DATA_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -681,7 +683,7 @@ export class AddonModDataProvider {
sort: 0, sort: 0,
order: 'DESC', order: 'DESC',
page: 0, page: 0,
perPage: AddonModDataProvider.PER_PAGE, perPage: ADDON_MOD_DATA_ENTRIES_PER_PAGE,
}, options); }, options);
const site = await CoreSites.getSite(options.siteId); const site = await CoreSites.getSite(options.siteId);
@ -699,7 +701,7 @@ export class AddonModDataProvider {
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getEntriesCacheKey(dataId, options.groupId), cacheKey: this.getEntriesCacheKey(dataId, options.groupId),
updateFrequency: CoreSite.FREQUENCY_SOMETIMES, updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
component: AddonModDataProvider.COMPONENT, component: ADDON_MOD_DATA_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -757,7 +759,7 @@ export class AddonModDataProvider {
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getEntryCacheKey(dataId, entryId), cacheKey: this.getEntryCacheKey(dataId, entryId),
updateFrequency: CoreSite.FREQUENCY_SOMETIMES, updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
component: AddonModDataProvider.COMPONENT, component: ADDON_MOD_DATA_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -809,7 +811,7 @@ export class AddonModDataProvider {
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getFieldsCacheKey(dataId), cacheKey: this.getFieldsCacheKey(dataId),
updateFrequency: CoreSite.FREQUENCY_RARELY, updateFrequency: CoreSite.FREQUENCY_RARELY,
component: AddonModDataProvider.COMPONENT, component: ADDON_MOD_DATA_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -911,7 +913,7 @@ export class AddonModDataProvider {
* @returns Promise resolved when the files are invalidated. * @returns Promise resolved when the files are invalidated.
*/ */
async invalidateFiles(moduleId: number, siteId?: string): Promise<void> { async invalidateFiles(moduleId: number, siteId?: string): Promise<void> {
await CoreFilepool.invalidateFilesByComponent(siteId, AddonModDataProvider.COMPONENT, moduleId); await CoreFilepool.invalidateFilesByComponent(siteId, ADDON_MOD_DATA_COMPONENT, moduleId);
} }
/** /**
@ -969,7 +971,7 @@ export class AddonModDataProvider {
await CoreCourseLogHelper.log( await CoreCourseLogHelper.log(
'mod_data_view_database', 'mod_data_view_database',
params, params,
AddonModDataProvider.COMPONENT, ADDON_MOD_DATA_COMPONENT,
id, id,
siteId, siteId,
); );
@ -989,7 +991,7 @@ export class AddonModDataProvider {
options.sort = options.sort || 0; options.sort = options.sort || 0;
options.order = options.order || 'DESC'; options.order = options.order || 'DESC';
options.page = options.page || 0; options.page = options.page || 0;
options.perPage = options.perPage || AddonModDataProvider.PER_PAGE; options.perPage = options.perPage || ADDON_MOD_DATA_ENTRIES_PER_PAGE;
options.readingStrategy = options.readingStrategy || CoreSitesReadingStrategy.PREFER_NETWORK; options.readingStrategy = options.readingStrategy || CoreSitesReadingStrategy.PREFER_NETWORK;
const params: AddonModDataSearchEntriesWSParams = { const params: AddonModDataSearchEntriesWSParams = {
@ -1000,7 +1002,7 @@ export class AddonModDataProvider {
perpage: options.perPage, perpage: options.perPage,
}; };
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
component: AddonModDataProvider.COMPONENT, component: ADDON_MOD_DATA_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -1087,7 +1089,7 @@ export type AddonModDataGetEntriesOptions = CoreCourseCommonModWSOptions & {
// -4: timemodified // -4: timemodified
order?: string; // The direction of the sorting: 'ASC' or 'DESC'. Defaults to 'DESC'. order?: string; // The direction of the sorting: 'ASC' or 'DESC'. Defaults to 'DESC'.
page?: number; // Page of records to return. Defaults to 0. page?: number; // Page of records to return. Defaults to 0.
perPage?: number; // Records per page to return. Defaults to AddonModDataProvider.PER_PAGE. perPage?: number; // Records per page to return. Defaults to ADDON_MOD_DATA_ENTRIES_PER_PAGE.
}; };
/** /**

View File

@ -21,8 +21,7 @@ import { CoreNavigator } from '@services/navigator';
import { CoreSitesReadingStrategy } from '@services/sites'; import { CoreSitesReadingStrategy } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom'; import { CoreDomUtils } from '@services/utils/dom';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonModDataModuleHandlerService } from './module'; import { ADDON_MOD_DATA_FEATURE_NAME, ADDON_MOD_DATA_PAGE_NAME } from '../../constants';
import { ADDON_MOD_DATA_FEATURE_NAME } from '../../constants';
/** /**
* Content links handler for database add or edit entry. * Content links handler for database add or edit entry.
@ -56,7 +55,7 @@ export class AddonModDataEditLinkHandlerService extends CoreContentLinksHandlerB
}; };
await CoreNavigator.navigateToSitePath( await CoreNavigator.navigateToSitePath(
`${AddonModDataModuleHandlerService.PAGE_NAME}/${module.course}/${module.id}/edit/${rId}`, `${ADDON_MOD_DATA_PAGE_NAME}/${module.course}/${module.id}/edit/${rId}`,
{ siteId, params: pageParams }, { siteId, params: pageParams },
); );
} finally { } finally {

View File

@ -17,6 +17,7 @@ import { Injectable, Type } from '@angular/core';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler'; import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate'; import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { ADDON_MOD_DATA_PAGE_NAME } from '../../constants';
/** /**
* Handler to support data modules. * Handler to support data modules.
@ -24,11 +25,9 @@ import { makeSingleton } from '@singletons';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class AddonModDataModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler { export class AddonModDataModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler {
static readonly PAGE_NAME = 'mod_data';
name = 'AddonModData'; name = 'AddonModData';
modName = 'data'; modName = 'data';
protected pageName = AddonModDataModuleHandlerService.PAGE_NAME; protected pageName = ADDON_MOD_DATA_PAGE_NAME;
supportedFeatures = { supportedFeatures = {
[CoreConstants.FEATURE_GROUPS]: true, [CoreConstants.FEATURE_GROUPS]: true,

View File

@ -24,9 +24,10 @@ import { CoreTimeUtils } from '@services/utils/time';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreWSFile } from '@services/ws'; import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonModDataProvider, AddonModDataEntry, AddonModData, AddonModDataData } from '../data'; import { AddonModDataEntry, AddonModData, AddonModDataData } from '../data';
import { AddonModDataSync, AddonModDataSyncResult } from '../data-sync'; import { AddonModDataSync, AddonModDataSyncResult } from '../data-sync';
import { ContextLevel } from '@/core/constants'; import { ContextLevel } from '@/core/constants';
import { ADDON_MOD_DATA_COMPONENT } from '../../constants';
/** /**
* Handler to prefetch databases. * Handler to prefetch databases.
@ -36,7 +37,7 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet
name = 'AddonModData'; name = 'AddonModData';
modName = 'data'; modName = 'data';
component = AddonModDataProvider.COMPONENT; component = ADDON_MOD_DATA_COMPONENT;
updatesNames = /^configuration$|^.*files$|^entries$|^gradeitems$|^outcomes$|^comments$|^ratings/; updatesNames = /^configuration$|^.*files$|^entries$|^gradeitems$|^outcomes$|^comments$|^ratings/;
/** /**

View File

@ -21,8 +21,7 @@ import { CoreNavigator } from '@services/navigator';
import { CoreSitesReadingStrategy } from '@services/sites'; import { CoreSitesReadingStrategy } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom'; import { CoreDomUtils } from '@services/utils/dom';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonModDataModuleHandlerService } from './module'; import { ADDON_MOD_DATA_FEATURE_NAME, ADDON_MOD_DATA_PAGE_NAME } from '../../constants';
import { ADDON_MOD_DATA_FEATURE_NAME } from '../../constants';
/** /**
* Content links handler for database show entry. * Content links handler for database show entry.
@ -67,7 +66,7 @@ export class AddonModDataShowLinkHandlerService extends CoreContentLinksHandlerB
} }
await CoreNavigator.navigateToSitePath( await CoreNavigator.navigateToSitePath(
`${AddonModDataModuleHandlerService.PAGE_NAME}/${module.course}/${module.id}/${rId}`, `${ADDON_MOD_DATA_PAGE_NAME}/${module.course}/${module.id}/${rId}`,
{ siteId, params: pageParams }, { siteId, params: pageParams },
); );
} finally { } finally {

View File

@ -16,13 +16,13 @@ import { CoreRoutedItemsManagerSource } from '@classes/items-management/routed-i
import { CoreGroupInfo, CoreGroups } from '@services/groups'; import { CoreGroupInfo, CoreGroups } from '@services/groups';
import { import {
AddonModFeedback, AddonModFeedback,
AddonModFeedbackProvider,
AddonModFeedbackWSAnonAttempt, AddonModFeedbackWSAnonAttempt,
AddonModFeedbackWSAttempt, AddonModFeedbackWSAttempt,
AddonModFeedbackWSFeedback, AddonModFeedbackWSFeedback,
} from '../services/feedback'; } from '../services/feedback';
import { AddonModFeedbackHelper } from '../services/feedback-helper'; import { AddonModFeedbackHelper } from '../services/feedback-helper';
import { Params } from '@angular/router'; import { Params } from '@angular/router';
import { ADDON_MOD_FEEDBACK_PER_PAGE } from '../constants';
/** /**
* Feedback attempts. * Feedback attempts.
@ -120,7 +120,7 @@ export class AddonModFeedbackAttemptsSource extends CoreRoutedItemsManagerSource
* @inheritdoc * @inheritdoc
*/ */
protected getPageLength(): number { protected getPageLength(): number {
return AddonModFeedbackProvider.PER_PAGE; return ADDON_MOD_FEEDBACK_PER_PAGE;
} }
/** /**
@ -146,10 +146,10 @@ export class AddonModFeedbackAttemptsSource extends CoreRoutedItemsManagerSource
const pageAttempts: AddonModFeedbackAttemptItem[] = [ const pageAttempts: AddonModFeedbackAttemptItem[] = [
// The page argument is ignored in the webservice when there is only one page, // The page argument is ignored in the webservice when there is only one page,
// so we should ignore the responses of pages beyond the first if that's the case. // so we should ignore the responses of pages beyond the first if that's the case.
...(page === 0 || result.totalattempts > AddonModFeedbackProvider.PER_PAGE) ...(page === 0 || result.totalattempts > ADDON_MOD_FEEDBACK_PER_PAGE)
? result.attempts ? result.attempts
: [], : [],
...(page === 0 || result.totalanonattempts > AddonModFeedbackProvider.PER_PAGE) ...(page === 0 || result.totalanonattempts > ADDON_MOD_FEEDBACK_PER_PAGE)
? result.anonattempts ? result.anonattempts
: [], : [],
]; ];

View File

@ -27,7 +27,6 @@ import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { import {
AddonModFeedback, AddonModFeedback,
AddonModFeedbackGetFeedbackAccessInformationWSResponse, AddonModFeedbackGetFeedbackAccessInformationWSResponse,
AddonModFeedbackProvider,
AddonModFeedbackWSFeedback, AddonModFeedbackWSFeedback,
AddonModFeedbackWSItem, AddonModFeedbackWSItem,
} from '../../services/feedback'; } from '../../services/feedback';
@ -38,8 +37,8 @@ import {
AddonModFeedbackSyncProvider, AddonModFeedbackSyncProvider,
AddonModFeedbackSyncResult, AddonModFeedbackSyncResult,
} from '../../services/feedback-sync'; } from '../../services/feedback-sync';
import { AddonModFeedbackModuleHandlerService } from '../../services/handlers/module';
import { AddonModFeedbackPrefetchHandler } from '../../services/handlers/prefetch'; import { AddonModFeedbackPrefetchHandler } from '../../services/handlers/prefetch';
import { ADDON_MOD_FEEDBACK_COMPONENT, ADDON_MOD_FEEDBACK_FORM_SUBMITTED, ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants';
/** /**
* Component that displays a feedback index page. * Component that displays a feedback index page.
@ -55,7 +54,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
@Input() tab = 'overview'; @Input() tab = 'overview';
@Input() group = 0; @Input() group = 0;
component = AddonModFeedbackProvider.COMPONENT; component = ADDON_MOD_FEEDBACK_COMPONENT;
pluginName = 'feedback'; pluginName = 'feedback';
feedback?: AddonModFeedbackWSFeedback; feedback?: AddonModFeedbackWSFeedback;
goPage?: number; goPage?: number;
@ -92,7 +91,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
super('AddonModLessonIndexComponent', content, courseContentsPage); super('AddonModLessonIndexComponent', content, courseContentsPage);
// Listen for form submit events. // Listen for form submit events.
this.submitObserver = CoreEvents.on(AddonModFeedbackProvider.FORM_SUBMITTED, async (data) => { this.submitObserver = CoreEvents.on(ADDON_MOD_FEEDBACK_FORM_SUBMITTED, async (data) => {
if (!this.feedback || data.feedbackId != this.feedback.id) { if (!this.feedback || data.feedbackId != this.feedback.id) {
return; return;
} }
@ -374,7 +373,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
*/ */
gotoAnswerQuestions(preview: boolean = false): void { gotoAnswerQuestions(preview: boolean = false): void {
CoreNavigator.navigateToSitePath( CoreNavigator.navigateToSitePath(
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${this.courseId}/${this.module.id}/form`, ADDON_MOD_FEEDBACK_PAGE_NAME + `/${this.courseId}/${this.module.id}/form`,
{ {
params: { params: {
preview, preview,
@ -407,7 +406,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
*/ */
openNonRespondents(): void { openNonRespondents(): void {
CoreNavigator.navigateToSitePath( CoreNavigator.navigateToSitePath(
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${this.courseId}/${this.module.id}/nonrespondents`, ADDON_MOD_FEEDBACK_PAGE_NAME + `/${this.courseId}/${this.module.id}/nonrespondents`,
{ {
params: { params: {
group: this.group, group: this.group,
@ -425,7 +424,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
} }
CoreNavigator.navigateToSitePath( CoreNavigator.navigateToSitePath(
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${this.courseId}/${this.module.id}/attempts`, ADDON_MOD_FEEDBACK_PAGE_NAME + `/${this.courseId}/${this.module.id}/attempts`,
{ {
params: { params: {
group: this.group, group: this.group,

View File

@ -0,0 +1,26 @@
// (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.
export const ADDON_MOD_FEEDBACK_COMPONENT = 'mmaModFeedback';
export const ADDON_MOD_FEEDBACK_PAGE_NAME = 'mod_feedback';
export const ADDON_MOD_FEEDBACK_FORM_SUBMITTED = 'addon_mod_feedback_form_submitted';
export const ADDON_MOD_FEEDBACK_LINE_SEP = '|';
export const ADDON_MOD_FEEDBACK_MULTICHOICE_TYPE_SEP = '>>>>>';
export const ADDON_MOD_FEEDBACK_MULTICHOICE_ADJUST_SEP = '<<<<<';
export const ADDON_MOD_FEEDBACK_MULTICHOICE_HIDENOSELECT = 'h';
export const ADDON_MOD_FEEDBACK_MULTICHOICERATED_VALUE_SEP = '####';
export const ADDON_MOD_FEEDBACK_PER_PAGE = 20;

View File

@ -86,4 +86,4 @@ const routes: Routes = [
AddonModFeedbackAttemptPage, AddonModFeedbackAttemptPage,
], ],
}) })
export class AddonModFeedbackLazyModule {} export default class AddonModFeedbackLazyModule {}

View File

@ -23,23 +23,23 @@ import { CorePushNotificationsDelegate } from '@features/pushnotifications/servi
import { CoreCronDelegate } from '@services/cron'; import { CoreCronDelegate } from '@services/cron';
import { CORE_SITE_SCHEMAS } from '@services/sites'; import { CORE_SITE_SCHEMAS } from '@services/sites';
import { OFFLINE_SITE_SCHEMA } from './services/database/feedback'; import { OFFLINE_SITE_SCHEMA } from './services/database/feedback';
import { AddonModFeedbackProvider } from './services/feedback';
import { AddonModFeedbackAnalysisLinkHandler } from './services/handlers/analysis-link'; import { AddonModFeedbackAnalysisLinkHandler } from './services/handlers/analysis-link';
import { AddonModFeedbackCompleteLinkHandler } from './services/handlers/complete-link'; import { AddonModFeedbackCompleteLinkHandler } from './services/handlers/complete-link';
import { AddonModFeedbackIndexLinkHandler } from './services/handlers/index-link'; import { AddonModFeedbackIndexLinkHandler } from './services/handlers/index-link';
import { AddonModFeedbackListLinkHandler } from './services/handlers/list-link'; import { AddonModFeedbackListLinkHandler } from './services/handlers/list-link';
import { AddonModFeedbackModuleHandlerService, AddonModFeedbackModuleHandler } from './services/handlers/module'; import { AddonModFeedbackModuleHandler } from './services/handlers/module';
import { AddonModFeedbackPrefetchHandler } from './services/handlers/prefetch'; import { AddonModFeedbackPrefetchHandler } from './services/handlers/prefetch';
import { AddonModFeedbackPrintLinkHandler } from './services/handlers/print-link'; import { AddonModFeedbackPrintLinkHandler } from './services/handlers/print-link';
import { AddonModFeedbackPushClickHandler } from './services/handlers/push-click'; import { AddonModFeedbackPushClickHandler } from './services/handlers/push-click';
import { AddonModFeedbackShowEntriesLinkHandler } from './services/handlers/show-entries-link'; import { AddonModFeedbackShowEntriesLinkHandler } from './services/handlers/show-entries-link';
import { AddonModFeedbackShowNonRespondentsLinkHandler } from './services/handlers/show-non-respondents-link'; import { AddonModFeedbackShowNonRespondentsLinkHandler } from './services/handlers/show-non-respondents-link';
import { AddonModFeedbackSyncCronHandler } from './services/handlers/sync-cron'; import { AddonModFeedbackSyncCronHandler } from './services/handlers/sync-cron';
import { ADDON_MOD_FEEDBACK_COMPONENT, ADDON_MOD_FEEDBACK_PAGE_NAME } from './constants';
const routes: Routes = [ const routes: Routes = [
{ {
path: AddonModFeedbackModuleHandlerService.PAGE_NAME, path: ADDON_MOD_FEEDBACK_PAGE_NAME,
loadChildren: () => import('./feedback-lazy.module').then(m => m.AddonModFeedbackLazyModule), loadChildren: () => import('./feedback-lazy.module'),
}, },
]; ];
@ -69,7 +69,7 @@ const routes: Routes = [
CoreContentLinksDelegate.registerHandler(AddonModFeedbackShowNonRespondentsLinkHandler.instance); CoreContentLinksDelegate.registerHandler(AddonModFeedbackShowNonRespondentsLinkHandler.instance);
CorePushNotificationsDelegate.registerClickHandler(AddonModFeedbackPushClickHandler.instance); CorePushNotificationsDelegate.registerClickHandler(AddonModFeedbackPushClickHandler.instance);
CoreCourseHelper.registerModuleReminderClick(AddonModFeedbackProvider.COMPONENT); CoreCourseHelper.registerModuleReminderClick(ADDON_MOD_FEEDBACK_COMPONENT);
}, },
}, },
], ],

View File

@ -22,13 +22,13 @@ import { CoreTextUtils } from '@services/utils/text';
import { AddonModFeedbackAttemptsSource } from '../../classes/feedback-attempts-source'; import { AddonModFeedbackAttemptsSource } from '../../classes/feedback-attempts-source';
import { import {
AddonModFeedback, AddonModFeedback,
AddonModFeedbackProvider,
AddonModFeedbackWSAnonAttempt, AddonModFeedbackWSAnonAttempt,
AddonModFeedbackWSFeedback, AddonModFeedbackWSFeedback,
} from '../../services/feedback'; } from '../../services/feedback';
import { AddonModFeedbackAttempt, AddonModFeedbackFormItem, AddonModFeedbackHelper } from '../../services/feedback-helper'; import { AddonModFeedbackAttempt, AddonModFeedbackFormItem, AddonModFeedbackHelper } from '../../services/feedback-helper';
import { CoreTime } from '@singletons/time'; import { CoreTime } from '@singletons/time';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { ADDON_MOD_FEEDBACK_COMPONENT } from '../../constants';
/** /**
* Page that displays a feedback attempt review. * Page that displays a feedback attempt review.
@ -46,7 +46,7 @@ export class AddonModFeedbackAttemptPage implements OnInit, OnDestroy {
attempts: AddonModFeedbackAttemptsSwipeManager; attempts: AddonModFeedbackAttemptsSwipeManager;
anonAttempt?: AddonModFeedbackWSAnonAttempt; anonAttempt?: AddonModFeedbackWSAnonAttempt;
items: AddonModFeedbackAttemptItem[] = []; items: AddonModFeedbackAttemptItem[] = [];
component = AddonModFeedbackProvider.COMPONENT; component = ADDON_MOD_FEEDBACK_COMPONENT;
loaded = false; loaded = false;
protected attemptId: number; protected attemptId: number;

View File

@ -30,14 +30,13 @@ import {
AddonModFeedback, AddonModFeedback,
AddonModFeedbackGetFeedbackAccessInformationWSResponse, AddonModFeedbackGetFeedbackAccessInformationWSResponse,
AddonModFeedbackPageItems, AddonModFeedbackPageItems,
AddonModFeedbackProvider,
AddonModFeedbackResponseValue, AddonModFeedbackResponseValue,
AddonModFeedbackWSFeedback, AddonModFeedbackWSFeedback,
} from '../../services/feedback'; } from '../../services/feedback';
import { AddonModFeedbackFormItem, AddonModFeedbackHelper } from '../../services/feedback-helper'; import { AddonModFeedbackFormItem, AddonModFeedbackHelper } from '../../services/feedback-helper';
import { AddonModFeedbackSync } from '../../services/feedback-sync'; import { AddonModFeedbackSync } from '../../services/feedback-sync';
import { AddonModFeedbackModuleHandlerService } from '../../services/handlers/module';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { ADDON_MOD_FEEDBACK_COMPONENT, ADDON_MOD_FEEDBACK_FORM_SUBMITTED, ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants';
/** /**
* Page that displays feedback form. * Page that displays feedback form.
@ -65,7 +64,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
courseId!: number; courseId!: number;
feedback?: AddonModFeedbackWSFeedback; feedback?: AddonModFeedbackWSFeedback;
completionPageContents?: string; completionPageContents?: string;
component = AddonModFeedbackProvider.COMPONENT; component = ADDON_MOD_FEEDBACK_COMPONENT;
offline = false; offline = false;
feedbackLoaded = false; feedbackLoaded = false;
access?: AddonModFeedbackGetFeedbackAccessInformationWSResponse; access?: AddonModFeedbackGetFeedbackAccessInformationWSResponse;
@ -356,7 +355,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
]); ]);
// If form has been submitted, the info has been already invalidated but we should update index view. // If form has been submitted, the info has been already invalidated but we should update index view.
CoreEvents.trigger(AddonModFeedbackProvider.FORM_SUBMITTED, { CoreEvents.trigger(ADDON_MOD_FEEDBACK_FORM_SUBMITTED, {
feedbackId: this.feedback!.id, feedbackId: this.feedback!.id,
tab: 'overview', tab: 'overview',
offline: this.completedOffline, offline: this.completedOffline,
@ -373,7 +372,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
// Invalidate access information so user will see home page updated (continue form). // Invalidate access information so user will see home page updated (continue form).
await AddonModFeedback.invalidateResumePageData(this.feedback!.id); await AddonModFeedback.invalidateResumePageData(this.feedback!.id);
CoreEvents.trigger(AddonModFeedbackProvider.FORM_SUBMITTED, { CoreEvents.trigger(ADDON_MOD_FEEDBACK_FORM_SUBMITTED, {
feedbackId: this.feedback!.id, feedbackId: this.feedback!.id,
tab: 'overview', tab: 'overview',
offline: this.completedOffline, offline: this.completedOffline,
@ -395,7 +394,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
showAnalysis(): void { showAnalysis(): void {
if (this.fromIndex) { if (this.fromIndex) {
// Previous page is the index page, go back. // Previous page is the index page, go back.
CoreEvents.trigger(AddonModFeedbackProvider.FORM_SUBMITTED, { CoreEvents.trigger(ADDON_MOD_FEEDBACK_FORM_SUBMITTED, {
feedbackId: this.feedback!.id, feedbackId: this.feedback!.id,
tab: 'analysis', tab: 'analysis',
offline: this.completedOffline, offline: this.completedOffline,
@ -406,7 +405,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
return; return;
} }
CoreNavigator.navigateToSitePath(AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${this.courseId}/${this.cmId}`, { CoreNavigator.navigateToSitePath(ADDON_MOD_FEEDBACK_PAGE_NAME + `/${this.courseId}/${this.cmId}`, {
params: { params: {
module: this.module, module: this.module,
tab: 'analysis', tab: 'analysis',

View File

@ -28,12 +28,18 @@ import {
AddonModFeedbackGetResponsesAnalysisWSResponse, AddonModFeedbackGetResponsesAnalysisWSResponse,
AddonModFeedbackGroupPaginatedOptions, AddonModFeedbackGroupPaginatedOptions,
AddonModFeedbackItem, AddonModFeedbackItem,
AddonModFeedbackProvider,
AddonModFeedbackResponseValue, AddonModFeedbackResponseValue,
AddonModFeedbackWSAttempt, AddonModFeedbackWSAttempt,
AddonModFeedbackWSNonRespondent, AddonModFeedbackWSNonRespondent,
} from './feedback'; } from './feedback';
import { AddonModFeedbackModuleHandlerService } from './handlers/module'; import {
ADDON_MOD_FEEDBACK_LINE_SEP,
ADDON_MOD_FEEDBACK_MULTICHOICE_TYPE_SEP,
ADDON_MOD_FEEDBACK_MULTICHOICE_ADJUST_SEP,
ADDON_MOD_FEEDBACK_MULTICHOICERATED_VALUE_SEP,
ADDON_MOD_FEEDBACK_MULTICHOICE_HIDENOSELECT,
ADDON_MOD_FEEDBACK_PAGE_NAME,
} from '../constants';
const MODE_RESPONSETIME = 1; const MODE_RESPONSETIME = 1;
const MODE_COURSE = 2; const MODE_COURSE = 2;
@ -184,7 +190,7 @@ export class AddonModFeedbackHelperProvider {
if (params.showcompleted === undefined) { if (params.showcompleted === undefined) {
// Param showcompleted not defined. Show entry list. // Param showcompleted not defined. Show entry list.
await CoreNavigator.navigateToSitePath( await CoreNavigator.navigateToSitePath(
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/attempts`, ADDON_MOD_FEEDBACK_PAGE_NAME + `/${module.course}/${module.id}/attempts`,
{ siteId }, { siteId },
); );
@ -198,7 +204,7 @@ export class AddonModFeedbackHelperProvider {
}); });
await CoreNavigator.navigateToSitePath( await CoreNavigator.navigateToSitePath(
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/attempts/${attempt.id}`, ADDON_MOD_FEEDBACK_PAGE_NAME + `/${module.course}/${module.id}/attempts/${attempt.id}`,
{ {
params: { params: {
feedbackId: module.instance, feedbackId: module.instance,
@ -295,7 +301,7 @@ export class AddonModFeedbackHelperProvider {
*/ */
protected getItemFormNumeric(item: AddonModFeedbackItem): AddonModFeedbackNumericItem { protected getItemFormNumeric(item: AddonModFeedbackItem): AddonModFeedbackNumericItem {
const range = item.presentation.split(AddonModFeedbackProvider.LINE_SEP) || []; const range = item.presentation.split(ADDON_MOD_FEEDBACK_LINE_SEP) || [];
const rangeFrom = range.length > 0 ? parseInt(range[0], 10) : undefined; const rangeFrom = range.length > 0 ? parseInt(range[0], 10) : undefined;
const rangeTo = range.length > 1 ? parseInt(range[1], 10) : undefined; const rangeTo = range.length > 1 ? parseInt(range[1], 10) : undefined;
@ -320,7 +326,7 @@ export class AddonModFeedbackHelperProvider {
protected getItemFormTextfield(item: AddonModFeedbackItem): AddonModFeedbackTextItem { protected getItemFormTextfield(item: AddonModFeedbackItem): AddonModFeedbackTextItem {
return Object.assign(item, { return Object.assign(item, {
templateName: 'textfield', templateName: 'textfield',
length: Number(item.presentation.split(AddonModFeedbackProvider.LINE_SEP)[1]) || 255, length: Number(item.presentation.split(ADDON_MOD_FEEDBACK_LINE_SEP)[1]) || 255,
value: item.rawValue !== undefined ? item.rawValue : '', value: item.rawValue !== undefined ? item.rawValue : '',
slottedLabel: true, slottedLabel: true,
}); });
@ -348,7 +354,7 @@ export class AddonModFeedbackHelperProvider {
*/ */
protected getItemFormMultichoice(item: AddonModFeedbackItem): AddonModFeedbackMultichoiceItem { protected getItemFormMultichoice(item: AddonModFeedbackItem): AddonModFeedbackMultichoiceItem {
let parts = item.presentation.split(AddonModFeedbackProvider.MULTICHOICE_TYPE_SEP) || []; let parts = item.presentation.split(ADDON_MOD_FEEDBACK_MULTICHOICE_TYPE_SEP) || [];
const subType = parts.length > 0 && parts[0] ? parts[0] : 'r'; const subType = parts.length > 0 && parts[0] ? parts[0] : 'r';
const formItem: AddonModFeedbackMultichoiceItem = Object.assign(item, { const formItem: AddonModFeedbackMultichoiceItem = Object.assign(item, {
@ -361,20 +367,20 @@ export class AddonModFeedbackHelperProvider {
formItem.presentation = parts.length > 1 ? parts[1] : ''; formItem.presentation = parts.length > 1 ? parts[1] : '';
if (formItem.subtype != 'd') { if (formItem.subtype != 'd') {
parts = formItem.presentation.split(AddonModFeedbackProvider.MULTICHOICE_ADJUST_SEP) || []; parts = formItem.presentation.split(ADDON_MOD_FEEDBACK_MULTICHOICE_ADJUST_SEP) || [];
formItem.presentation = parts.length > 0 ? parts[0] : ''; formItem.presentation = parts.length > 0 ? parts[0] : '';
// Horizontal are not supported right now. item.horizontal = parts.length > 1 && !!parts[1]; // Horizontal are not supported right now. item.horizontal = parts.length > 1 && !!parts[1];
} }
const choices = formItem.presentation.split(AddonModFeedbackProvider.LINE_SEP) || []; const choices = formItem.presentation.split(ADDON_MOD_FEEDBACK_LINE_SEP) || [];
formItem.choices = choices.map((choice, index) => { formItem.choices = choices.map((choice, index) => {
const weightValue = choice.split(AddonModFeedbackProvider.MULTICHOICERATED_VALUE_SEP) || ['']; const weightValue = choice.split(ADDON_MOD_FEEDBACK_MULTICHOICERATED_VALUE_SEP) || [''];
choice = weightValue.length == 1 ? weightValue[0] : '(' + weightValue[0] + ') ' + weightValue[1]; choice = weightValue.length == 1 ? weightValue[0] : '(' + weightValue[0] + ') ' + weightValue[1];
return { value: index + 1, label: choice }; return { value: index + 1, label: choice };
}); });
if (formItem.subtype === 'r' && formItem.options.search(AddonModFeedbackProvider.MULTICHOICE_HIDENOSELECT) == -1) { if (formItem.subtype === 'r' && formItem.options.search(ADDON_MOD_FEEDBACK_MULTICHOICE_HIDENOSELECT) == -1) {
formItem.choices.unshift({ value: 0, label: Translate.instant('addon.mod_feedback.not_selected') }); formItem.choices.unshift({ value: 0, label: Translate.instant('addon.mod_feedback.not_selected') });
formItem.value = formItem.rawValue !== undefined ? Number(formItem.rawValue) : 0; formItem.value = formItem.rawValue !== undefined ? Number(formItem.rawValue) : 0;
} else if (formItem.subtype === 'd') { } else if (formItem.subtype === 'd') {
@ -383,7 +389,7 @@ export class AddonModFeedbackHelperProvider {
} else if (formItem.subtype === 'c') { } else if (formItem.subtype === 'c') {
if (formItem.rawValue !== undefined) { if (formItem.rawValue !== undefined) {
formItem.rawValue = String(formItem.rawValue); formItem.rawValue = String(formItem.rawValue);
const values = formItem.rawValue.split(AddonModFeedbackProvider.LINE_SEP); const values = formItem.rawValue.split(ADDON_MOD_FEEDBACK_LINE_SEP);
formItem.choices.forEach((choice) => { formItem.choices.forEach((choice) => {
for (const x in values) { for (const x in values) {
if (choice.value == Number(values[x])) { if (choice.value == Number(values[x])) {

View File

@ -24,9 +24,10 @@ import { CoreSync, CoreSyncResult } from '@services/sync';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { makeSingleton, Translate } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
import { CoreEvents } from '@singletons/events'; import { CoreEvents } from '@singletons/events';
import { AddonModFeedback, AddonModFeedbackProvider, AddonModFeedbackWSFeedback } from './feedback'; import { AddonModFeedback, AddonModFeedbackWSFeedback } from './feedback';
import { AddonModFeedbackOffline, AddonModFeedbackOfflineResponse } from './feedback-offline'; import { AddonModFeedbackOffline, AddonModFeedbackOfflineResponse } from './feedback-offline';
import { AddonModFeedbackPrefetchHandler, AddonModFeedbackPrefetchHandlerService } from './handlers/prefetch'; import { AddonModFeedbackPrefetchHandler, AddonModFeedbackPrefetchHandlerService } from './handlers/prefetch';
import { ADDON_MOD_FEEDBACK_COMPONENT } from '../constants';
/** /**
* Service to sync feedbacks. * Service to sync feedbacks.
@ -137,7 +138,7 @@ export class AddonModFeedbackSyncProvider extends CoreCourseActivitySyncBaseProv
} }
// Verify that feedback isn't blocked. // Verify that feedback isn't blocked.
if (CoreSync.isBlocked(AddonModFeedbackProvider.COMPONENT, feedbackId, siteId)) { if (CoreSync.isBlocked(ADDON_MOD_FEEDBACK_COMPONENT, feedbackId, siteId)) {
this.logger.debug(`Cannot sync feedback '${feedbackId}' because it is blocked.`); this.logger.debug(`Cannot sync feedback '${feedbackId}' because it is blocked.`);
throw new CoreSyncBlockedError(Translate.instant('core.errorsyncblocked', { $a: this.componentTranslate })); throw new CoreSyncBlockedError(Translate.instant('core.errorsyncblocked', { $a: this.componentTranslate }));
@ -162,7 +163,7 @@ export class AddonModFeedbackSyncProvider extends CoreCourseActivitySyncBaseProv
}; };
// Sync offline logs. // Sync offline logs.
await CoreUtils.ignoreErrors(CoreCourseLogHelper.syncActivity(AddonModFeedbackProvider.COMPONENT, feedbackId, siteId)); await CoreUtils.ignoreErrors(CoreCourseLogHelper.syncActivity(ADDON_MOD_FEEDBACK_COMPONENT, feedbackId, siteId));
// Get offline responses to be sent. // Get offline responses to be sent.
const responses = await CoreUtils.ignoreErrors(AddonModFeedbackOffline.getFeedbackResponses(feedbackId, siteId)); const responses = await CoreUtils.ignoreErrors(AddonModFeedbackOffline.getFeedbackResponses(feedbackId, siteId));

View File

@ -26,8 +26,15 @@ import { makeSingleton, Translate } from '@singletons';
import { AddonModFeedbackOffline } from './feedback-offline'; import { AddonModFeedbackOffline } from './feedback-offline';
import { AddonModFeedbackAutoSyncData, AddonModFeedbackSyncProvider } from './feedback-sync'; import { AddonModFeedbackAutoSyncData, AddonModFeedbackSyncProvider } from './feedback-sync';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site'; import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import {
const ROOT_CACHE_KEY = 'AddonModFeedback:'; ADDON_MOD_FEEDBACK_COMPONENT,
ADDON_MOD_FEEDBACK_FORM_SUBMITTED,
ADDON_MOD_FEEDBACK_LINE_SEP,
ADDON_MOD_FEEDBACK_MULTICHOICE_ADJUST_SEP,
ADDON_MOD_FEEDBACK_MULTICHOICE_TYPE_SEP,
ADDON_MOD_FEEDBACK_MULTICHOICERATED_VALUE_SEP,
ADDON_MOD_FEEDBACK_PER_PAGE,
} from '../constants';
/** /**
* Service that provides some features for feedbacks. * Service that provides some features for feedbacks.
@ -35,14 +42,7 @@ const ROOT_CACHE_KEY = 'AddonModFeedback:';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class AddonModFeedbackProvider { export class AddonModFeedbackProvider {
static readonly COMPONENT = 'mmaModFeedback'; protected static readonly ROOT_CACHE_KEY = 'AddonModFeedback:';
static readonly FORM_SUBMITTED = 'addon_mod_feedback_form_submitted';
static readonly LINE_SEP = '|';
static readonly MULTICHOICE_TYPE_SEP = '>>>>>';
static readonly MULTICHOICE_ADJUST_SEP = '<<<<<';
static readonly MULTICHOICE_HIDENOSELECT = 'h';
static readonly MULTICHOICERATED_VALUE_SEP = '####';
static readonly PER_PAGE = 20;
/** /**
* Check dependency of a question item. * Check dependency of a question item.
@ -80,11 +80,11 @@ export class AddonModFeedbackProvider {
* @returns Return true if dependency is acomplished and it can be shown. False, otherwise. * @returns Return true if dependency is acomplished and it can be shown. False, otherwise.
*/ */
protected compareDependItemMultichoice(item: AddonModFeedbackItem, dependValue: string): boolean { protected compareDependItemMultichoice(item: AddonModFeedbackItem, dependValue: string): boolean {
const parts = item.presentation.split(AddonModFeedbackProvider.MULTICHOICE_TYPE_SEP) || []; const parts = item.presentation.split(ADDON_MOD_FEEDBACK_MULTICHOICE_TYPE_SEP) || [];
const subtype = parts.length > 0 && parts[0] ? parts[0] : 'r'; const subtype = parts.length > 0 && parts[0] ? parts[0] : 'r';
const choicesStr = (parts[1] || '').split(AddonModFeedbackProvider.MULTICHOICE_ADJUST_SEP)[0] || ''; const choicesStr = (parts[1] || '').split(ADDON_MOD_FEEDBACK_MULTICHOICE_ADJUST_SEP)[0] || '';
const choices = choicesStr.split(AddonModFeedbackProvider.LINE_SEP) || []; const choices = choicesStr.split(ADDON_MOD_FEEDBACK_LINE_SEP) || [];
let values: AddonModFeedbackResponseValue[]; let values: AddonModFeedbackResponseValue[];
if (subtype === 'c') { if (subtype === 'c') {
@ -92,7 +92,7 @@ export class AddonModFeedbackProvider {
values = ['']; values = [''];
} else { } else {
item.rawValue = '' + item.rawValue; item.rawValue = '' + item.rawValue;
values = item.rawValue.split(AddonModFeedbackProvider.LINE_SEP); values = item.rawValue.split(ADDON_MOD_FEEDBACK_LINE_SEP);
} }
} else { } else {
values = [item.rawValue || '']; values = [item.rawValue || ''];
@ -104,7 +104,7 @@ export class AddonModFeedbackProvider {
let value = choices[index]; let value = choices[index];
if (item.typ == 'multichoicerated') { if (item.typ == 'multichoicerated') {
value = value.split(AddonModFeedbackProvider.MULTICHOICERATED_VALUE_SEP)[1] || ''; value = value.split(ADDON_MOD_FEEDBACK_MULTICHOICERATED_VALUE_SEP)[1] || '';
} }
if (value.trim() == dependValue) { if (value.trim() == dependValue) {
@ -195,10 +195,10 @@ export class AddonModFeedbackProvider {
} }
// Treat multichoice checkboxes. // Treat multichoice checkboxes.
if (item.typ === 'multichoice' && item.presentation.split(AddonModFeedbackProvider.MULTICHOICE_TYPE_SEP)[0] === 'c') { if (item.typ === 'multichoice' && item.presentation.split(ADDON_MOD_FEEDBACK_MULTICHOICE_TYPE_SEP)[0] === 'c') {
offlineValues[item.id] = offlineValues[item.id].filter((value) => Number(value) > 0); offlineValues[item.id] = offlineValues[item.id].filter((value) => Number(value) > 0);
item.rawValue = offlineValues[item.id].join(AddonModFeedbackProvider.LINE_SEP); item.rawValue = offlineValues[item.id].join(ADDON_MOD_FEEDBACK_LINE_SEP);
} else { } else {
item.rawValue = offlineValues[item.id][0]; item.rawValue = offlineValues[item.id][0];
} }
@ -314,7 +314,7 @@ export class AddonModFeedbackProvider {
}; };
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getAnalysisDataCacheKey(feedbackId, options.groupId), cacheKey: this.getAnalysisDataCacheKey(feedbackId, options.groupId),
component: AddonModFeedbackProvider.COMPONENT, component: ADDON_MOD_FEEDBACK_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -429,7 +429,7 @@ export class AddonModFeedbackProvider {
}; };
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getCurrentCompletedTimeModifiedDataCacheKey(feedbackId), cacheKey: this.getCurrentCompletedTimeModifiedDataCacheKey(feedbackId),
component: AddonModFeedbackProvider.COMPONENT, component: ADDON_MOD_FEEDBACK_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -476,7 +476,7 @@ export class AddonModFeedbackProvider {
}; };
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getCurrentValuesDataCacheKey(feedbackId), cacheKey: this.getCurrentValuesDataCacheKey(feedbackId),
component: AddonModFeedbackProvider.COMPONENT, component: ADDON_MOD_FEEDBACK_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -529,7 +529,7 @@ export class AddonModFeedbackProvider {
}; };
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getFeedbackAccessInformationDataCacheKey(feedbackId), cacheKey: this.getFeedbackAccessInformationDataCacheKey(feedbackId),
component: AddonModFeedbackProvider.COMPONENT, component: ADDON_MOD_FEEDBACK_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -554,7 +554,7 @@ export class AddonModFeedbackProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected getFeedbackCacheKey(courseId: number): string { protected getFeedbackCacheKey(courseId: number): string {
return ROOT_CACHE_KEY + 'feedback:' + courseId; return AddonModFeedbackProvider.ROOT_CACHE_KEY + 'feedback:' + courseId;
} }
/** /**
@ -564,7 +564,7 @@ export class AddonModFeedbackProvider {
* @returns Cache key. * @returns Cache key.
*/ */
protected getFeedbackDataPrefixCacheKey(feedbackId: number): string { protected getFeedbackDataPrefixCacheKey(feedbackId: number): string {
return ROOT_CACHE_KEY + feedbackId; return AddonModFeedbackProvider.ROOT_CACHE_KEY + feedbackId;
} }
/** /**
@ -590,7 +590,7 @@ export class AddonModFeedbackProvider {
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getFeedbackCacheKey(courseId), cacheKey: this.getFeedbackCacheKey(courseId),
updateFrequency: CoreSite.FREQUENCY_RARELY, updateFrequency: CoreSite.FREQUENCY_RARELY,
component: AddonModFeedbackProvider.COMPONENT, component: ADDON_MOD_FEEDBACK_COMPONENT,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -648,7 +648,7 @@ export class AddonModFeedbackProvider {
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getItemsDataCacheKey(feedbackId), cacheKey: this.getItemsDataCacheKey(feedbackId),
updateFrequency: CoreSite.FREQUENCY_SOMETIMES, updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
component: AddonModFeedbackProvider.COMPONENT, component: ADDON_MOD_FEEDBACK_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -686,11 +686,11 @@ export class AddonModFeedbackProvider {
feedbackid: feedbackId, feedbackid: feedbackId,
groupid: options.groupId, groupid: options.groupId,
page: options.page, page: options.page,
perpage: AddonModFeedbackProvider.PER_PAGE, perpage: ADDON_MOD_FEEDBACK_PER_PAGE,
}; };
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getNonRespondentsDataCacheKey(feedbackId, options.groupId), cacheKey: this.getNonRespondentsDataCacheKey(feedbackId, options.groupId),
component: AddonModFeedbackProvider.COMPONENT, component: ADDON_MOD_FEEDBACK_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -862,11 +862,11 @@ export class AddonModFeedbackProvider {
feedbackid: feedbackId, feedbackid: feedbackId,
groupid: options.groupId, groupid: options.groupId,
page: options.page, page: options.page,
perpage: AddonModFeedbackProvider.PER_PAGE, perpage: ADDON_MOD_FEEDBACK_PER_PAGE,
}; };
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getResponsesAnalysisDataCacheKey(feedbackId, options.groupId), cacheKey: this.getResponsesAnalysisDataCacheKey(feedbackId, options.groupId),
component: AddonModFeedbackProvider.COMPONENT, component: ADDON_MOD_FEEDBACK_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -910,7 +910,7 @@ export class AddonModFeedbackProvider {
}; };
const preSets = { const preSets = {
cacheKey: this.getResumePageDataCacheKey(feedbackId), cacheKey: this.getResumePageDataCacheKey(feedbackId),
component: AddonModFeedbackProvider.COMPONENT, component: ADDON_MOD_FEEDBACK_COMPONENT,
componentId: options.cmId, componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -1024,7 +1024,7 @@ export class AddonModFeedbackProvider {
* @returns Promise resolved when the files are invalidated. * @returns Promise resolved when the files are invalidated.
*/ */
async invalidateFiles(moduleId: number, siteId?: string): Promise<void> { async invalidateFiles(moduleId: number, siteId?: string): Promise<void> {
return CoreFilepool.invalidateFilesByComponent(siteId, AddonModFeedbackProvider.COMPONENT, moduleId); return CoreFilepool.invalidateFilesByComponent(siteId, ADDON_MOD_FEEDBACK_COMPONENT, moduleId);
} }
/** /**
@ -1082,7 +1082,7 @@ export class AddonModFeedbackProvider {
const preSets: CoreSiteWSPreSets = { const preSets: CoreSiteWSPreSets = {
cacheKey: this.getCompletedDataCacheKey(feedbackId), cacheKey: this.getCompletedDataCacheKey(feedbackId),
updateFrequency: CoreSite.FREQUENCY_RARELY, updateFrequency: CoreSite.FREQUENCY_RARELY,
component: AddonModFeedbackProvider.COMPONENT, component: ADDON_MOD_FEEDBACK_COMPONENT,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
}; };
@ -1106,7 +1106,7 @@ export class AddonModFeedbackProvider {
await CoreCourseLogHelper.log( await CoreCourseLogHelper.log(
'mod_feedback_view_feedback', 'mod_feedback_view_feedback',
params, params,
AddonModFeedbackProvider.COMPONENT, ADDON_MOD_FEEDBACK_COMPONENT,
id, id,
siteId, siteId,
); );
@ -1252,7 +1252,7 @@ declare module '@singletons/events' {
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
*/ */
export interface CoreEventsData { export interface CoreEventsData {
[AddonModFeedbackProvider.FORM_SUBMITTED]: AddonModFeedbackFormSubmittedData; [ADDON_MOD_FEEDBACK_FORM_SUBMITTED]: AddonModFeedbackFormSubmittedData;
[AddonModFeedbackSyncProvider.AUTO_SYNCED]: AddonModFeedbackAutoSyncData; [AddonModFeedbackSyncProvider.AUTO_SYNCED]: AddonModFeedbackAutoSyncData;
} }

View File

@ -19,7 +19,7 @@ import { CoreCourse } from '@features/course/services/course';
import { CoreNavigator } from '@services/navigator'; import { CoreNavigator } from '@services/navigator';
import { CoreDomUtils } from '@services/utils/dom'; import { CoreDomUtils } from '@services/utils/dom';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonModFeedbackModuleHandlerService } from './module'; import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants';
/** /**
* Content links handler for a feedback analysis. * Content links handler for a feedback analysis.
@ -54,7 +54,7 @@ export class AddonModFeedbackAnalysisLinkHandlerService extends CoreContentLinks
); );
await CoreNavigator.navigateToSitePath( await CoreNavigator.navigateToSitePath(
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}`, ADDON_MOD_FEEDBACK_PAGE_NAME + `/${module.course}/${module.id}`,
{ {
params: { params: {
module, module,

View File

@ -20,7 +20,7 @@ import { CoreNavigator } from '@services/navigator';
import { CoreSitesReadingStrategy } from '@services/sites'; import { CoreSitesReadingStrategy } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom'; import { CoreDomUtils } from '@services/utils/dom';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonModFeedbackModuleHandlerService } from './module'; import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants';
/** /**
* Content links handler for feedback complete questions. * Content links handler for feedback complete questions.
@ -50,7 +50,7 @@ export class AddonModFeedbackCompleteLinkHandlerService extends CoreContentLinks
); );
await CoreNavigator.navigateToSitePath( await CoreNavigator.navigateToSitePath(
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/form`, ADDON_MOD_FEEDBACK_PAGE_NAME + `/${module.course}/${module.id}/form`,
{ {
params: { params: {
page: params.gopage !== undefined ? Number(params.gopage) : undefined, page: params.gopage !== undefined ? Number(params.gopage) : undefined,

View File

@ -17,6 +17,7 @@ import { Injectable, Type } from '@angular/core';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate'; import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler'; import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants';
/** /**
* Handler to support feedback modules. * Handler to support feedback modules.
@ -24,11 +25,9 @@ import { CoreModuleHandlerBase } from '@features/course/classes/module-base-hand
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class AddonModFeedbackModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler { export class AddonModFeedbackModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler {
static readonly PAGE_NAME = 'mod_feedback';
name = 'AddonModFeedback'; name = 'AddonModFeedback';
modName = 'feedback'; modName = 'feedback';
protected pageName = AddonModFeedbackModuleHandlerService.PAGE_NAME; protected pageName = ADDON_MOD_FEEDBACK_PAGE_NAME;
supportedFeatures = { supportedFeatures = {
[CoreConstants.FEATURE_GROUPS]: true, [CoreConstants.FEATURE_GROUPS]: true,

View File

@ -25,10 +25,10 @@ import { makeSingleton } from '@singletons';
import { import {
AddonModFeedback, AddonModFeedback,
AddonModFeedbackGetFeedbackAccessInformationWSResponse, AddonModFeedbackGetFeedbackAccessInformationWSResponse,
AddonModFeedbackProvider,
AddonModFeedbackWSFeedback, AddonModFeedbackWSFeedback,
} from '../feedback'; } from '../feedback';
import { AddonModFeedbackSync, AddonModFeedbackSyncResult } from '../feedback-sync'; import { AddonModFeedbackSync, AddonModFeedbackSyncResult } from '../feedback-sync';
import { ADDON_MOD_FEEDBACK_COMPONENT } from '../../constants';
/** /**
* Handler to prefetch feedbacks. * Handler to prefetch feedbacks.
@ -38,7 +38,7 @@ export class AddonModFeedbackPrefetchHandlerService extends CoreCourseActivityPr
name = 'AddonModFeedback'; name = 'AddonModFeedback';
modName = 'feedback'; modName = 'feedback';
component = AddonModFeedbackProvider.COMPONENT; component = ADDON_MOD_FEEDBACK_COMPONENT;
updatesNames = /^configuration$|^.*files$|^attemptsfinished|^attemptsunfinished$/; updatesNames = /^configuration$|^.*files$|^attemptsfinished|^attemptsunfinished$/;
/** /**

View File

@ -20,7 +20,7 @@ import { CoreNavigator } from '@services/navigator';
import { CoreSitesReadingStrategy } from '@services/sites'; import { CoreSitesReadingStrategy } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom'; import { CoreDomUtils } from '@services/utils/dom';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonModFeedbackModuleHandlerService } from './module'; import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants';
/** /**
* Content links handler for feedback print questions. * Content links handler for feedback print questions.
@ -50,7 +50,7 @@ export class AddonModFeedbackPrintLinkHandlerService extends CoreContentLinksHan
); );
await CoreNavigator.navigateToSitePath( await CoreNavigator.navigateToSitePath(
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/form`, ADDON_MOD_FEEDBACK_PAGE_NAME + `/${module.course}/${module.id}/form`,
{ {
params: { params: {
preview: true, preview: true,

Some files were not shown because too many files have changed in this diff Show More