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 { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler';
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.

View File

@ -14,7 +14,7 @@
import { Params } from '@angular/router';
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 { AddonCompetencyHelper } from '../services/competency-helper';
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 { 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 { AddonCompetencyCompetencySummaryPageModule } from './pages/competencysummary/competencysummary.module';
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 { AddonCompetencyCompetencyPage } from './pages/competency/competency.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 { AddonCompetencyCompetencySummaryPageModule } from './pages/competencysummary/competencysummary.module';
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 { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-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/user.module';
import { PARTICIPANTS_PAGE_NAME } from '@features/user/constants';
import { COURSE_PAGE_NAME } from '@features/course/constants';
import { ADDON_COMPETENCY_LEARNING_PLANS_PAGE, ADDON_COMPETENCY_COMPETENCIES_PAGE } from './constants';
/**
* 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 = [
{
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 { ContextLevel } from '@/core/constants';
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 { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker';
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 { CoreDomUtils } from '@services/utils/dom';
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 { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';

View File

@ -21,7 +21,7 @@ import { CoreUserProfile } from '@features/user/services/user';
import { CoreNavigator } from '@services/navigator';
import { CoreDomUtils } from '@services/utils/dom';
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 { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker';
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
// 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 { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
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 { makeSingleton } from '@singletons';
import { AddonCompetency } from '../competency';

View File

@ -24,7 +24,7 @@ import { AddonCompetency } from '../competency';
import { CoreCourseAnyCourseData, CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/services/courses';
import { CoreFilterHelper } from '@features/filter/services/filter-helper';
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.

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// 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 { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// 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 { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';

View File

@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// 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 { 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 { CorePushNotificationsNotificationBasicData } from '@features/pushnotifications/services/pushnotifications';
import { CoreNavigator } from '@services/navigator';

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// 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 { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';

View File

@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// 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 { COURSE_PAGE_NAME } from '@features/course/course.module';
import { COURSE_PAGE_NAME } from '@features/course/constants';
import { CoreUserProfile } from '@features/user/services/user';
import {
CoreUserProfileHandler,
@ -22,7 +22,7 @@ import {
CoreUserProfileHandlerData,
CoreUserDelegateContext,
} 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 { CoreSites } from '@services/sites';
import { makeSingleton } from '@singletons';

View File

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

View File

@ -34,7 +34,6 @@ import { CoreDomUtils } from '@services/utils/dom';
import { CoreUtils } from '@services/utils/utils';
import { CoreTextUtils } from '@services/utils/text';
import { CoreLogger } from '@singletons/logger';
import { CoreApp } from '@services/app';
import { CoreInfiniteLoadingComponent } from '@components/infinite-loading/infinite-loading';
import { Md5 } from 'ts-md5/dist/md5';
import moment from 'moment-timezone';
@ -45,6 +44,7 @@ import { CoreIonLoadingElement } from '@classes/ion-loading';
import { ActivatedRoute } from '@angular/router';
import { CoreConstants } from '@/core/constants';
import { CoreDom } from '@singletons/dom';
import { CoreKeyboard } from '@singletons/keyboard';
/**
* 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.
// 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);
this.removeMessage(message.hash!);

View File

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

View File

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

View File

@ -82,4 +82,4 @@ const routes: Routes = [
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 { CORE_SITE_SCHEMAS } from '@services/sites';
import { AddonModAssignFeedbackModule } from './feedback/feedback.module';
import { AddonModAssignProvider } from './services/assign';
import { OFFLINE_SITE_SCHEMA } from './services/database/assign';
import { AddonModAssignIndexLinkHandler } from './services/handlers/index-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 { AddonModAssignPushClickHandler } from './services/handlers/push-click';
import { AddonModAssignSyncCronHandler } from './services/handlers/sync-cron';
import { AddonModAssignSubmissionModule } from './submission/submission.module';
import { ADDON_MOD_ASSIGN_COMPONENT, ADDON_MOD_ASSIGN_PAGE_NAME } from './constants';
/**
* Get mod assign services.
@ -69,8 +69,8 @@ export async function getModAssignComponentModules(): Promise<unknown[]> {
const routes: Routes = [
{
path: AddonModAssignModuleHandlerService.PAGE_NAME,
loadChildren: () => import('./assign-lazy.module').then(m => m.AddonModAssignLazyModule),
path: ADDON_MOD_ASSIGN_PAGE_NAME,
loadChildren: () => import('./assign-lazy.module'),
},
];
@ -97,7 +97,7 @@ const routes: Routes = [
CoreCronDelegate.register(AddonModAssignSyncCronHandler.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';
import { AddonModAssignHelper, AddonModAssignSubmissionFormatted } from '../services/assign-helper';
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.
@ -116,7 +117,7 @@ export class AddonModAssignSubmissionsSource extends CoreRoutedItemsManagerSourc
if (result && result.updated) {
CoreEvents.trigger(
AddonModAssignSyncProvider.MANUAL_SYNCED,
ADDON_MOD_ASSIGN_MANUAL_SYNCED,
{
assignId: this.assign.id,
warnings: result.warnings,

View File

@ -20,11 +20,11 @@ import {
AddonModAssignAssign,
AddonModAssignSubmission,
AddonModAssignPlugin,
AddonModAssignProvider,
AddonModAssign,
} from '../../services/assign';
import { AddonModAssignHelper, AddonModAssignPluginConfig } from '../../services/assign-helper';
import { AddonModAssignFeedbackDelegate } from '../../services/feedback-delegate';
import { ADDON_MOD_ASSIGN_COMPONENT } from '../../constants';
/**
* 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 to render the plugin if it isn't supported.
component = AddonModAssignProvider.COMPONENT;
component = ADDON_MOD_ASSIGN_COMPONENT;
text = '';
files: CoreWSFile[] = [];
notSupported = false;

View File

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

View File

@ -18,13 +18,13 @@ import {
AddonModAssignAssign,
AddonModAssignSubmission,
AddonModAssignPlugin,
AddonModAssignProvider,
AddonModAssign,
} from '../../services/assign';
import { AddonModAssignHelper, AddonModAssignPluginConfig } from '../../services/assign-helper';
import { AddonModAssignSubmissionDelegate } from '../../services/submission-delegate';
import { CoreFileEntry } from '@services/file-helper';
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.
@ -47,7 +47,7 @@ export class AddonModAssignSubmissionPluginComponent implements OnInit {
data?: AddonModAssignSubmissionPluginData; // Data to pass to the component.
// Data to render the plugin if it isn't supported.
component = AddonModAssignProvider.COMPONENT;
component = ADDON_MOD_ASSIGN_COMPONENT;
text = '';
files: CoreFileEntry[] = [];
notSupported = false;

View File

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

View File

@ -13,3 +13,20 @@
// limitations under the License.
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 { 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 {
AddonModAssignFeedbackCommentsDraftData,
@ -26,6 +26,7 @@ import { AddonModAssignOffline } from '@addons/mod/assign/services/assign-offlin
import { CoreUtils } from '@services/utils/utils';
import { AddonModAssignFeedbackPluginBaseComponent } from '@addons/mod/assign/classes/base-feedback-plugin-component';
import { ContextLevel } from '@/core/constants';
import { ADDON_MOD_ASSIGN_COMPONENT } from '@addons/mod/assign/constants';
/**
* Component to render a comments feedback plugin.
*/
@ -36,7 +37,7 @@ import { ContextLevel } from '@/core/constants';
export class AddonModAssignFeedbackCommentsComponent extends AddonModAssignFeedbackPluginBaseComponent implements OnInit {
control?: FormControl<string>;
component = AddonModAssignProvider.COMPONENT;
component = ADDON_MOD_ASSIGN_COMPONENT;
text = '';
isSent = false;
loaded = false;

View File

@ -13,7 +13,8 @@
// limitations under the License.
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 { CoreWSFile } from '@services/ws';
@ -26,7 +27,7 @@ import { CoreWSFile } from '@services/ws';
})
export class AddonModAssignFeedbackEditPdfComponent extends AddonModAssignFeedbackPluginBaseComponent implements OnInit {
component = AddonModAssignProvider.COMPONENT;
component = ADDON_MOD_ASSIGN_COMPONENT;
files: CoreWSFile[] = [];
/**

View File

@ -13,7 +13,8 @@
// limitations under the License.
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 { CoreWSFile } from '@services/ws';
@ -26,7 +27,7 @@ import { CoreWSFile } from '@services/ws';
})
export class AddonModAssignFeedbackFileComponent extends AddonModAssignFeedbackPluginBaseComponent implements OnInit {
component = AddonModAssignProvider.COMPONENT;
component = ADDON_MOD_ASSIGN_COMPONENT;
files: CoreWSFile[] = [];
/**

View File

@ -27,7 +27,6 @@ import { CoreEvents } from '@singletons/events';
import {
AddonModAssignAssign,
AddonModAssignSubmission,
AddonModAssignProvider,
AddonModAssign,
AddonModAssignSubmissionStatusOptions,
AddonModAssignGetSubmissionStatusWSResponse,
@ -40,6 +39,12 @@ import { AddonModAssignSync } from '../../services/assign-sync';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile } from '@services/ws';
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.
@ -65,7 +70,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave {
timeLimitEndTime = 0; // If time limit is enabled, the end time for the timer.
activityInstructions?: string; // Activity instructions.
introAttachments?: CoreWSExternalFile[]; // Intro attachments.
component = AddonModAssignProvider.COMPONENT;
component = ADDON_MOD_ASSIGN_COMPONENT;
protected userId: number; // User doing the submission.
protected isBlind = false; // Whether blind is used.
@ -144,7 +149,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave {
if (!this.isDestroyed) {
// 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).
@ -276,7 +281,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave {
await AddonModAssign.startSubmission(this.assign.id);
CoreEvents.trigger(AddonModAssignProvider.STARTED_EVENT, {
CoreEvents.trigger(ADDON_MOD_ASSIGN_STARTED_EVENT, {
assignmentId: this.assign.id,
}, CoreSites.getCurrentSiteId());
@ -453,7 +458,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave {
CoreForms.triggerFormSubmittedEvent(this.formElement, sent, CoreSites.getCurrentSiteId());
CoreEvents.trigger(
AddonModAssignProvider.SUBMISSION_SAVED_EVENT,
ADDON_MOD_ASSIGN_SUBMISSION_SAVED_EVENT,
{
assignmentId: this.assign!.id,
submissionId: this.userSubmission!.id,
@ -465,7 +470,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave {
if (!this.assign!.submissiondrafts) {
// No drafts allowed, so it was submitted. Trigger event.
CoreEvents.trigger(
AddonModAssignProvider.SUBMITTED_FOR_GRADING_EVENT,
ADDON_MOD_ASSIGN_SUBMITTED_FOR_GRADING_EVENT,
{
assignmentId: this.assign!.id,
submissionId: this.userSubmission!.id,
@ -500,7 +505,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave {
// Unblock the assignment.
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,
AddonModAssignSubmissionsSource,
} from '../../classes/submissions-source';
import { AddonModAssignAssign, AddonModAssignProvider } from '../../services/assign';
import { AddonModAssignAssign } from '../../services/assign';
import {
AddonModAssignSyncProvider,
AddonModAssignManualSyncData,
AddonModAssignAutoSyncData,
} from '../../services/assign-sync';
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.
@ -56,7 +56,7 @@ export class AddonModAssignSubmissionListPage implements AfterViewInit, OnDestro
constructor() {
// Update data if some grade changes.
this.gradedObserver = CoreEvents.on(
AddonModAssignProvider.GRADED_EVENT,
ADDON_MOD_ASSIGN_GRADED_EVENT,
(data) => {
if (
this.submissions.loaded &&
@ -72,7 +72,7 @@ export class AddonModAssignSubmissionListPage implements AfterViewInit, OnDestro
);
// 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>(
events,
(data) => {

View File

@ -17,7 +17,6 @@ import { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fi
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
import { FileEntry, DirectoryEntry } from '@awesome-cordova-plugins/file/ngx';
import {
AddonModAssignProvider,
AddonModAssignAssign,
AddonModAssignSubmission,
AddonModAssignParticipant,
@ -37,6 +36,7 @@ import { AddonModAssignFeedbackDelegate } from './feedback-delegate';
import { makeSingleton } from '@singletons';
import { CoreFormFields } from '@singletons/form';
import { CoreFileEntry } from '@services/file-helper';
import { ADDON_MOD_ASSIGN_COMPONENT } from '../constants';
/**
* Service that provides some helper functions for assign.
@ -650,7 +650,7 @@ export class AddonModAssignHelperProvider {
* @returns Promise resolved with the itemId.
*/
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.
*/
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 { CoreSyncBlockedError } from '@classes/base-sync';
import {
AddonModAssignProvider,
AddonModAssignAssign,
AddonModAssignSubmission,
AddonModAssign,
@ -40,6 +39,7 @@ import { CoreNetworkError } from '@classes/errors/network-error';
import { CoreGradesFormattedItem, CoreGradesHelper } from '@features/grades/services/grades-helper';
import { AddonModAssignSubmissionDelegate } from './submission-delegate';
import { AddonModAssignFeedbackDelegate } from './feedback-delegate';
import { ADDON_MOD_ASSIGN_AUTO_SYNCED, ADDON_MOD_ASSIGN_COMPONENT } from '../constants';
/**
* Service to sync assigns.
@ -47,9 +47,6 @@ import { AddonModAssignFeedbackDelegate } from './feedback-delegate';
@Injectable({ providedIn: 'root' })
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';
constructor() {
@ -129,7 +126,7 @@ export class AddonModAssignSyncProvider extends CoreCourseActivitySyncBaseProvid
: await this.syncAssignIfNeeded(assignId, siteId);
if (result?.updated) {
CoreEvents.trigger(AddonModAssignSyncProvider.AUTO_SYNCED, {
CoreEvents.trigger(ADDON_MOD_ASSIGN_AUTO_SYNCED, {
assignId: assignId,
warnings: result.warnings,
gradesBlocked: result.gradesBlocked,
@ -170,7 +167,7 @@ export class AddonModAssignSyncProvider extends CoreCourseActivitySyncBaseProvid
}
// 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.');
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> {
// Sync offline logs.
await CoreUtils.ignoreErrors(
CoreCourseLogHelper.syncActivity(AddonModAssignProvider.COMPONENT, assignId, siteId),
CoreCourseLogHelper.syncActivity(ADDON_MOD_ASSIGN_COMPONENT, assignId, siteId),
);
const result: AddonModAssignSyncResult = {
@ -433,7 +430,7 @@ export class AddonModAssignSyncProvider extends CoreCourseActivitySyncBaseProvid
};
// 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.!!!!`);
throw new CoreSyncBlockedError(Translate.instant(

View File

@ -31,14 +31,21 @@ import { AddonModAssignSubmissionDelegate } from './submission-delegate';
import { CoreComments } from '@features/comments/services/comments';
import { AddonModAssignSubmissionFormatted } from './assign-helper';
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 { CoreFileHelper } from '@services/file-helper';
import { CoreIonicColorNames } from '@singletons/colors';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import { ContextLevel } from '@/core/constants';
const ROOT_CACHE_KEY = 'mmaModAssign:';
import {
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' {
@ -48,12 +55,12 @@ declare module '@singletons/events' {
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
*/
export interface CoreEventsData {
[AddonModAssignProvider.SUBMISSION_SAVED_EVENT]: AddonModAssignSubmissionSavedEventData;
[AddonModAssignProvider.SUBMITTED_FOR_GRADING_EVENT]: AddonModAssignSubmittedForGradingEventData;
[AddonModAssignProvider.GRADED_EVENT]: AddonModAssignGradedEventData;
[AddonModAssignProvider.STARTED_EVENT]: AddonModAssignStartedEventData;
[AddonModAssignSyncProvider.MANUAL_SYNCED]: AddonModAssignManualSyncData;
[AddonModAssignSyncProvider.AUTO_SYNCED]: AddonModAssignAutoSyncData;
[ADDON_MOD_ASSIGN_SUBMISSION_SAVED_EVENT]: AddonModAssignSubmissionSavedEventData;
[ADDON_MOD_ASSIGN_SUBMITTED_FOR_GRADING_EVENT]: AddonModAssignSubmittedForGradingEventData;
[ADDON_MOD_ASSIGN_GRADED_EVENT]: AddonModAssignGradedEventData;
[ADDON_MOD_ASSIGN_STARTED_EVENT]: AddonModAssignStartedEventData;
[ADDON_MOD_ASSIGN_MANUAL_SYNCED]: AddonModAssignManualSyncData;
[ADDON_MOD_ASSIGN_AUTO_SYNCED]: AddonModAssignAutoSyncData;
}
}
@ -64,19 +71,7 @@ declare module '@singletons/events' {
@Injectable({ providedIn: 'root' })
export class AddonModAssignProvider {
static readonly COMPONENT = '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';
protected static readonly ROOT_CACHE_KEY = 'mmaModAssign:';
/**
* 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 = {
cacheKey: this.getAssignmentCacheKey(courseId),
updateFrequency: CoreSite.FREQUENCY_RARELY,
component: AddonModAssignProvider.COMPONENT,
component: ADDON_MOD_ASSIGN_COMPONENT,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -226,7 +221,7 @@ export class AddonModAssignProvider {
* @returns Cache key.
*/
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 = {
cacheKey: this.getAssignmentUserMappingsCacheKey(assignId),
updateFrequency: CoreSite.FREQUENCY_OFTEN,
component: AddonModAssignProvider.COMPONENT,
component: ADDON_MOD_ASSIGN_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy),
};
@ -279,7 +274,7 @@ export class AddonModAssignProvider {
* @returns Cache key.
*/
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 = {
cacheKey: this.getAssignmentGradesCacheKey(assignId),
component: AddonModAssignProvider.COMPONENT,
component: ADDON_MOD_ASSIGN_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy),
};
@ -326,7 +321,7 @@ export class AddonModAssignProvider {
* @returns Cache key.
*/
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 = {
cacheKey: this.getSubmissionsCacheKey(assignId),
updateFrequency: CoreSite.FREQUENCY_OFTEN,
component: AddonModAssignProvider.COMPONENT,
component: ADDON_MOD_ASSIGN_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy),
};
@ -489,7 +484,7 @@ export class AddonModAssignProvider {
* @returns Cache key.
*/
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,
filter: options.filter,
rewriteurls: options.filter,
component: AddonModAssignProvider.COMPONENT,
component: ADDON_MOD_ASSIGN_COMPONENT,
componentId: options.cmId,
// Don't cache when getting text without filters.
// @todo Change this to support offline editing.
@ -659,7 +654,7 @@ export class AddonModAssignProvider {
const preSets: CoreSiteWSPreSets = {
cacheKey: this.listParticipantsCacheKey(assignId, groupId),
updateFrequency: CoreSite.FREQUENCY_OFTEN,
component: AddonModAssignProvider.COMPONENT,
component: ADDON_MOD_ASSIGN_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy),
};
@ -685,7 +680,7 @@ export class AddonModAssignProvider {
* @returns Cache key.
*/
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(
'mod_assign_view_submission_status',
params,
AddonModAssignProvider.COMPONENT,
ADDON_MOD_ASSIGN_COMPONENT,
assignid,
siteId,
);
@ -912,7 +907,7 @@ export class AddonModAssignProvider {
await CoreCourseLogHelper.log(
'mod_assign_view_grading_table',
params,
AddonModAssignProvider.COMPONENT,
ADDON_MOD_ASSIGN_COMPONENT,
assignid,
siteId,
);
@ -933,7 +928,7 @@ export class AddonModAssignProvider {
await CoreCourseLogHelper.log(
'mod_assign_view_assign',
params,
AddonModAssignProvider.COMPONENT,
ADDON_MOD_ASSIGN_COMPONENT,
assignid,
siteId,
);

View File

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

View File

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

View File

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

View File

@ -16,7 +16,6 @@ import {
AddonModAssignAssign,
AddonModAssignSubmission,
AddonModAssignPlugin,
AddonModAssignProvider,
AddonModAssign,
} from '@addons/mod/assign/services/assign';
import { AddonModAssignHelper } from '@addons/mod/assign/services/assign-helper';
@ -32,6 +31,7 @@ import { makeSingleton } from '@singletons';
import { AddonModAssignSubmissionFileComponent } from '../component/file';
import { FileEntry } from '@awesome-cordova-plugins/file/ngx';
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.
@ -65,10 +65,10 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
* @inheritdoc
*/
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.
CoreFileSession.clearFiles(AddonModAssignProvider.COMPONENT, assign.id);
CoreFileSession.clearFiles(ADDON_MOD_ASSIGN_COMPONENT, assign.id);
// Now delete the local files from the tmp folder.
CoreFileUploader.clearTmpFiles(files);
@ -148,7 +148,7 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
// Check if there's any change.
const hasChanged = await this.hasDataChanged(assign, submission, plugin);
if (hasChanged) {
const files = CoreFileSession.getFiles(AddonModAssignProvider.COMPONENT, assign.id);
const files = CoreFileSession.getFiles(ADDON_MOD_ASSIGN_COMPONENT, assign.id);
return CoreFileHelper.getTotalFilesSize(files);
} else {
@ -183,7 +183,7 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
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) {
// 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.
const currentFiles = CoreFileSession.getFiles(AddonModAssignProvider.COMPONENT, assign.id);
const currentFiles = CoreFileSession.getFiles(ADDON_MOD_ASSIGN_COMPONENT, assign.id);
const error = CoreUtils.hasRepeatedFilenames(currentFiles);
if (error) {

View File

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

View File

@ -35,4 +35,4 @@ const routes: Routes = [
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 { AddonModBBBIndexLinkHandler } from './services/handlers/index-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 = [
{
path: ADDON_MOD_BBB_MAIN_MENU_PAGE_NAME,
loadChildren: () => import('./bigbluebuttonbn-lazy.module').then(m => m.AddonModBBBLazyModule),
path: ADDON_MOD_BBB_PAGE_NAME,
loadChildren: () => import('./bigbluebuttonbn-lazy.module'),
},
];

View File

@ -30,8 +30,8 @@ import {
AddonModBBBData,
AddonModBBBMeetingInfo,
AddonModBBBRecordingPlaybackTypes,
AddonModBBBService,
} from '../../services/bigbluebuttonbn';
import { ADDON_MOD_BBB_COMPONENT } from '../../constants';
/**
* Component that displays a Big Blue Button activity.
@ -43,7 +43,7 @@ import {
})
export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityComponent implements OnInit {
component = AddonModBBBService.COMPONENT;
component = ADDON_MOD_BBB_COMPONENT;
pluginName = 'bigbluebuttonbn';
bbb?: AddonModBBBData;
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 { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
const ROOT_CACHE_KEY = 'AddonModBBB:';
import { ADDON_MOD_BBB_COMPONENT } from '../constants';
/**
* Service that provides some features for Big Blue Button activity.
@ -33,7 +32,7 @@ const ROOT_CACHE_KEY = 'AddonModBBB:';
@Injectable({ providedIn: 'root' })
export class AddonModBBBService {
static readonly COMPONENT = 'mmaModBigBlueButtonBN';
protected static readonly ROOT_CACHE_KEY = 'AddonModBBB:';
/**
* End a meeting.
@ -75,7 +74,7 @@ export class AddonModBBBService {
const preSets: CoreSiteWSPreSets = {
cacheKey: this.getBBBsCacheKey(courseId),
updateFrequency: CoreSite.FREQUENCY_RARELY,
component: AddonModBBBService.COMPONENT,
component: ADDON_MOD_BBB_COMPONENT,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -100,7 +99,7 @@ export class AddonModBBBService {
* @returns Cache key.
*/
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),
getCacheUsingCacheKey: true,
uniqueCacheKey: true,
component: AddonModBBBService.COMPONENT,
component: ADDON_MOD_BBB_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -205,7 +204,7 @@ export class AddonModBBBService {
* @returns Cache key prefix.
*/
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 = {
cacheKey: this.getRecordingsCacheKey(id, groupId),
component: AddonModBBBService.COMPONENT,
component: ADDON_MOD_BBB_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -270,7 +269,7 @@ export class AddonModBBBService {
* @returns Cache key prefix.
*/
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(
'mod_bigbluebuttonbn_view_bigbluebuttonbn',
params,
AddonModBBBService.COMPONENT,
ADDON_MOD_BBB_COMPONENT,
id,
siteId,
);

View File

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

View File

@ -43,4 +43,4 @@ const routes: Routes = [
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 { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module';
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 { AddonModBookListLinkHandler } from './services/handlers/list-link';
import { AddonModBookPrefetchHandler } from './services/handlers/prefetch';
import { AddonModBookTagAreaHandler } from './services/handlers/tag-area';
import { CORE_SITE_SCHEMAS } from '@services/sites';
import { BOOK_SITE_SCHEMA } from './services/database/book';
import { ADDON_MOD_BOOK_PAGE_NAME } from './constants';
const routes: Routes = [
{
path: AddonModBookModuleHandlerService.PAGE_NAME,
loadChildren: () => import('./book-lazy.module').then(m => m.AddonModBookLazyModule),
path: ADDON_MOD_BOOK_PAGE_NAME,
loadChildren: () => import('./book-lazy.module'),
},
];

View File

@ -14,12 +14,12 @@
import { Component, Optional, OnInit, OnDestroy } from '@angular/core';
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 { CoreCourse } from '@features/course/services/course';
import { CoreNavigator } from '@services/navigator';
import { AddonModBookModuleHandlerService } from '../../services/handlers/module';
import { CoreUtils } from '@services/utils/utils';
import { ADDON_MOD_BOOK_PAGE_NAME, AddonModBookNumbering } from '../../constants';
/**
* Component that displays a book entry page.
@ -116,7 +116,7 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp
*/
async openBook(chapterId?: number): Promise<void> {
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 } },
);

View File

@ -14,7 +14,8 @@
import { Component, Input, OnInit } from '@angular/core';
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.

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

View File

@ -27,27 +27,7 @@ import { CoreDomUtils } from '@services/utils/dom';
import { CoreFile } from '@services/file';
import { CoreError } from '@classes/errors/error';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
/**
* 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:';
import { ADDON_MOD_BOOK_COMPONENT } from '../constants';
/**
* Service that provides some features for books.
@ -55,7 +35,7 @@ const ROOT_CACHE_KEY = 'mmaModBook:';
@Injectable({ providedIn: 'root' })
export class AddonModBookProvider {
static readonly COMPONENT = 'mmaModBook';
protected static readonly ROOT_CACHE_KEY = 'mmaModBook:';
/**
* Get a book by course module ID.
@ -92,7 +72,7 @@ export class AddonModBookProvider {
const preSets: CoreSiteWSPreSets = {
cacheKey: this.getBookDataCacheKey(courseId),
updateFrequency: CoreSite.FREQUENCY_RARELY,
component: AddonModBookProvider.COMPONENT,
component: ADDON_MOD_BOOK_COMPONENT,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy),
};
@ -114,7 +94,7 @@ export class AddonModBookProvider {
* @returns Cache key.
*/
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 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);
@ -226,7 +206,7 @@ export class AddonModBookProvider {
*/
async getLastChapterViewed(id: number, siteId?: string): Promise<number | undefined> {
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);
@ -327,7 +307,7 @@ export class AddonModBookProvider {
const promises: Promise<void>[] = [];
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));
return CoreUtils.allPromises(promises);
@ -372,7 +352,7 @@ export class AddonModBookProvider {
await CoreCourseLogHelper.log(
'mod_book_view_book',
params,
AddonModBookProvider.COMPONENT,
ADDON_MOD_BOOK_COMPONENT,
id,
siteId,
);
@ -390,7 +370,7 @@ export class AddonModBookProvider {
async storeLastChapterViewed(id: number, chapterId: number, courseId: number, siteId?: string): Promise<void> {
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 { makeSingleton } from '@singletons';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
import { ADDON_MOD_BOOK_PAGE_NAME } from '../../constants';
/**
* Handler to support book modules.
@ -25,11 +26,9 @@ import { CoreModuleHandlerBase } from '@features/course/classes/module-base-hand
@Injectable({ providedIn: 'root' })
export class AddonModBookModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler {
static readonly PAGE_NAME = 'mod_book';
name = 'AddonModBook';
modName = 'book';
protected pageName = AddonModBookModuleHandlerService.PAGE_NAME;
protected pageName = ADDON_MOD_BOOK_PAGE_NAME;
supportedFeatures = {
[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 { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { AddonModBook, AddonModBookProvider } from '../book';
import { AddonModBook } from '../book';
import { ADDON_MOD_BOOK_COMPONENT } from '../../constants';
/**
* Handler to prefetch books.
@ -29,7 +30,7 @@ export class AddonModBookPrefetchHandlerService extends CoreCourseResourcePrefet
name = 'AddonModBook';
modName = 'book';
component = AddonModBookProvider.COMPONENT;
component = ADDON_MOD_BOOK_COMPONENT;
updatesNames = /^configuration$|^.*files$|^entries$/;
/**

View File

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

View File

@ -35,4 +35,4 @@ const routes: Routes = [
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 { AddonModChoiceIndexLinkHandler } from './services/handlers/index-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 { 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 = [
{
path: AddonModChoiceModuleHandlerService.PAGE_NAME,
loadChildren: () => import('./choice-lazy.module').then(m => m.AddonModChoiceLazyModule),
path: ADDON_MOD_CHOICE_PAGE_NAME,
loadChildren: () => import('./choice-lazy.module'),
},
];

View File

@ -32,11 +32,15 @@ import { AddonModChoiceOffline } from '../../services/choice-offline';
import {
AddonModChoiceAutoSyncData,
AddonModChoiceSync,
AddonModChoiceSyncProvider,
AddonModChoiceSyncResult,
} from '../../services/choice-sync';
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.
@ -64,7 +68,7 @@ export class AddonModChoiceIndexComponent extends CoreCourseModuleMainActivityCo
publishInfo?: string; // Message explaining the user what will happen with his choices.
protected userId?: number;
protected syncEventName = AddonModChoiceSyncProvider.AUTO_SYNCED;
protected syncEventName = ADDON_MOD_CHOICE_AUTO_SYNCED;
protected hasAnsweredOnline = false;
protected now = CoreTimeUtils.timestamp();

View File

@ -13,6 +13,7 @@
// limitations under the License.
export const ADDON_MOD_CHOICE_COMPONENT = 'mmaModChoice';
export const ADDON_MOD_CHOICE_PAGE_NAME = 'mod_choice';
/**
* Possible show results values.
@ -27,3 +28,5 @@ export const enum AddonModChoiceShowResults {
// Possible choice publish values.
export const ADDON_MOD_CHOICE_PUBLISH_ANONYMOUS = false;
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 { AddonModChoiceOffline } from './choice-offline';
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.
@ -34,8 +34,6 @@ import { ADDON_MOD_CHOICE_COMPONENT } from '../constants';
@Injectable({ providedIn: 'root' })
export class AddonModChoiceSyncProvider extends CoreCourseActivitySyncBaseProvider<AddonModChoiceSyncResult> {
static readonly AUTO_SYNCED = 'addon_mod_choice_autom_synced';
protected componentTranslatableString = 'choice';
constructor() {
@ -82,7 +80,7 @@ export class AddonModChoiceSyncProvider extends CoreCourseActivitySyncBaseProvid
if (result?.updated) {
// Sync successful, send event.
CoreEvents.trigger(AddonModChoiceSyncProvider.AUTO_SYNCED, {
CoreEvents.trigger(ADDON_MOD_CHOICE_AUTO_SYNCED, {
choiceId: response.choiceid,
userId: response.userid,
warnings: result.warnings,

View File

@ -25,9 +25,9 @@ import { CoreUtils } from '@services/utils/utils';
import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
import { AddonModChoiceOffline } from './choice-offline';
import { AddonModChoiceAutoSyncData, AddonModChoiceSyncProvider } from './choice-sync';
import { AddonModChoiceAutoSyncData } from './choice-sync';
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.
@ -611,7 +611,7 @@ declare module '@singletons/events' {
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
*/
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 { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { makeSingleton } from '@singletons';
import { ADDON_MOD_CHOICE_PAGE_NAME } from '../../constants';
/**
* Handler to support choice modules.
@ -24,11 +25,9 @@ import { makeSingleton } from '@singletons';
@Injectable({ providedIn: 'root' })
export class AddonModChoiceModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler {
static readonly PAGE_NAME = 'mod_choice';
name = 'AddonModChoice';
modName = 'choice';
protected pageName = AddonModChoiceModuleHandlerService.PAGE_NAME;
protected pageName = ADDON_MOD_CHOICE_PAGE_NAME;
supportedFeatures = {
[CoreConstants.FEATURE_GROUPS]: true,

View File

@ -24,14 +24,13 @@ import {
AddonModDataData,
AddonModDataEntry,
AddonModDataGetDataAccessInformationWSResponse,
AddonModDataProvider,
AddonModDataTemplateMode,
} from '../../services/data';
import { AddonModDataHelper } from '../../services/data-helper';
import { AddonModDataOffline } from '../../services/data-offline';
import { AddonModDataModuleHandlerService } from '../../services/handlers/module';
import { CoreDomUtils } from '@services/utils/dom';
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.
@ -101,7 +100,7 @@ export class AddonModDataActionComponent implements OnInit {
title: this.title,
};
const basePath = AddonModDataModuleHandlerService.PAGE_NAME;
const basePath = ADDON_MOD_DATA_PAGE_NAME;
CoreNavigator.navigateToSitePath(
`${basePath}/${this.database.course}/${this.database.coursemodule}/edit/${this.entry.id}`,
{ params },
@ -120,7 +119,7 @@ export class AddonModDataActionComponent implements OnInit {
sortDirection: this.sortDirection,
};
const basePath = AddonModDataModuleHandlerService.PAGE_NAME;
const basePath = ADDON_MOD_DATA_PAGE_NAME;
CoreNavigator.navigateToSitePath(
`${basePath}/${this.database.course}/${this.database.coursemodule}/${this.entry.id}`,
{ params },
@ -140,7 +139,7 @@ export class AddonModDataActionComponent implements OnInit {
// Found. Just delete the action.
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 { CoreEventObserver, CoreEvents } from '@singletons/events';
import {
AddonModDataProvider,
AddonModData,
AddonModDataEntry,
AddonModDataTemplateType,
@ -40,13 +39,19 @@ import {
AddonModDataSearchEntriesAdvancedField,
} from '../../services/data';
import { AddonModDataHelper, AddonModDatDisplayFieldsOptions } from '../../services/data-helper';
import { AddonModDataAutoSyncData, AddonModDataSyncProvider, AddonModDataSyncResult } from '../../services/data-sync';
import { AddonModDataModuleHandlerService } from '../../services/handlers/module';
import { AddonModDataAutoSyncData, AddonModDataSyncResult } from '../../services/data-sync';
import { AddonModDataPrefetchHandler } from '../../services/handlers/prefetch';
import { AddonModDataComponentsCompileModule } from '../components-compile.module';
import { AddonModDataSearchComponent } from '../search/search';
import { CoreUrlUtils } from '@services/utils/url';
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 -->';
@ -60,7 +65,7 @@ const contentToken = '<!-- CORE-DATABASE-CONTENT-GOES-HERE -->';
})
export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComponent implements OnInit, OnDestroy {
component = AddonModDataProvider.COMPONENT;
component = ADDON_MOD_DATA_COMPONENT;
pluginName = 'data';
access?: AddonModDataGetDataAccessInformationWSResponse;
@ -110,7 +115,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
hasOfflineRatings = false;
protected syncEventName = AddonModDataSyncProvider.AUTO_SYNCED;
protected syncEventName = ADDON_MOD_DATA_AUTO_SYNCED;
protected hasComments = false;
protected fieldsArray: AddonModDataField[] = [];
protected entryChangedObserver?: CoreEventObserver;
@ -134,7 +139,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
this.selectedGroup = this.group || 0;
// 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) {
this.showLoading = true;
@ -303,8 +308,8 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
this.isEmpty = !numEntries && !numOfflineEntries;
this.hasNextPage = numEntries >= AddonModDataProvider.PER_PAGE && ((this.search.page + 1) *
AddonModDataProvider.PER_PAGE) < entries.totalcount;
this.hasNextPage = numEntries >= ADDON_MOD_DATA_ENTRIES_PER_PAGE && ((this.search.page + 1) *
ADDON_MOD_DATA_ENTRIES_PER_PAGE) < entries.totalcount;
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 options: AddonModDatDisplayFieldsOptions = {};
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.sortDirection = this.search.sortDirection;
}
@ -489,7 +494,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
};
CoreNavigator.navigateToSitePath(
`${AddonModDataModuleHandlerService.PAGE_NAME}/${this.courseId}/${this.module.id}/edit`,
`${ADDON_MOD_DATA_PAGE_NAME}/${this.courseId}/${this.module.id}/edit`,
{ params },
);
}
@ -509,14 +514,14 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
if (!this.search.searching) {
const pageXOffset = this.entries.findIndex((entry) => entry.id == entryId);
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.sortDirection = this.search.sortDirection;
}
}
CoreNavigator.navigateToSitePath(
`${AddonModDataModuleHandlerService.PAGE_NAME}/${this.courseId}/${this.module.id}/${entryId}`,
`${ADDON_MOD_DATA_PAGE_NAME}/${this.courseId}/${this.module.id}/${entryId}`,
{ params },
);
}
@ -550,7 +555,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
}
const params: Record<string, unknown> = {
perpage: AddonModDataProvider.PER_PAGE,
perpage: ADDON_MOD_DATA_ENTRIES_PER_PAGE,
search: !this.search.searchingAdvanced ? this.search.text : '',
sort: this.search.sortBy,
order: this.search.sortDirection,

View File

@ -13,3 +13,11 @@
// limitations under the License.
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,
],
})
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 { CoreCronDelegate } from '@services/cron';
import { CORE_SITE_SCHEMAS } from '@services/sites';
import { AddonModDataProvider } from './services/data';
import { ADDON_MOD_DATA_OFFLINE_SITE_SCHEMA } from './services/database/data';
import { AddonModDataApproveLinkHandler } from './services/handlers/approve-link';
import { AddonModDataDeleteLinkHandler } from './services/handlers/delete-link';
import { AddonModDataEditLinkHandler } from './services/handlers/edit-link';
import { AddonModDataIndexLinkHandler } from './services/handlers/index-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 { AddonModDataShowLinkHandler } from './services/handlers/show-link';
import { AddonModDataSyncCronHandler } from './services/handlers/sync-cron';
import { AddonModDataTagAreaHandler } from './services/handlers/tag-area';
import { AddonModDataFieldModule } from './fields/field.module';
import { CoreCourseHelper } from '@features/course/services/course-helper';
import { ADDON_MOD_DATA_COMPONENT, ADDON_MOD_DATA_PAGE_NAME } from './constants';
const routes: Routes = [
{
path: AddonModDataModuleHandlerService.PAGE_NAME,
loadChildren: () => import('./data-lazy.module').then(m => m.AddonModDataLazyModule),
path: ADDON_MOD_DATA_PAGE_NAME,
loadChildren: () => import('./data-lazy.module'),
},
];
@ -69,7 +69,7 @@ const routes: Routes = [
CoreContentLinksDelegate.registerHandler(AddonModDataEditLinkHandler.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.
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 { CoreFileSession } from '@services/file-session';
import { CoreFileEntry } from '@services/file-helper';
import { ADDON_MOD_DATA_COMPONENT } from '@addons/mod/data/constants';
/**
* Component to render data file field.
@ -59,7 +60,7 @@ export class AddonModDataFieldFileComponent extends AddonModDataFieldPluginBaseC
return;
}
this.component = AddonModDataProvider.COMPONENT;
this.component = ADDON_MOD_DATA_COMPONENT;
this.componentId = this.database!.coursemodule;
this.updateValue(this.value);

View File

@ -15,7 +15,6 @@
import {
AddonModDataEntryField,
AddonModDataField,
AddonModDataProvider,
AddonModDataSearchEntriesAdvancedFieldFormatted,
AddonModDataSubfieldData,
} from '@addons/mod/data/services/data';
@ -29,6 +28,7 @@ import { makeSingleton, Translate } from '@singletons';
import { AddonModDataFieldFileComponent } from '../component/file';
import { CoreFileEntry } from '@services/file-helper';
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.
@ -79,14 +79,14 @@ export class AddonModDataFieldFileHandlerService implements AddonModDataFieldHan
* @inheritdoc
*/
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
*/
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) || [];
if (originalFiles.length) {

View File

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

View File

@ -15,7 +15,6 @@
import {
AddonModDataEntryField,
AddonModDataField,
AddonModDataProvider,
AddonModDataSearchEntriesAdvancedFieldFormatted,
AddonModDataSubfieldData,
} from '@addons/mod/data/services/data';
@ -29,6 +28,7 @@ import { makeSingleton, Translate } from '@singletons';
import { AddonModDataFieldPictureComponent } from '../component/picture';
import { CoreFileEntry } from '@services/file-helper';
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.
@ -90,7 +90,7 @@ export class AddonModDataFieldPictureHandlerService implements AddonModDataField
* @inheritdoc
*/
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 { 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 { CoreWSFile } from '@services/ws';
import { ADDON_MOD_DATA_COMPONENT } from '@addons/mod/data/constants';
/**
* Component to render data number field.
@ -46,7 +47,7 @@ export class AddonModDataFieldTextareaComponent extends AddonModDataFieldPluginB
* Initialize field.
*/
protected init(): void {
this.component = AddonModDataProvider.COMPONENT;
this.component = ADDON_MOD_DATA_COMPONENT;
this.componentId = this.database?.coursemodule;
if (this.displayMode) {

View File

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

View File

@ -25,7 +25,7 @@ import { CoreDomUtils } from '@services/utils/dom';
import { CoreUtils } from '@services/utils/utils';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { AddonModDataComponentsCompileModule } from '../../components/components-compile.module';
import { AddonModDataProvider,
import {
AddonModData,
AddonModDataData,
AddonModDataGetDataAccessInformationWSResponse,
@ -35,9 +35,14 @@ import { AddonModDataProvider,
AddonModDataEntry,
} from '../../services/data';
import { AddonModDataHelper } from '../../services/data-helper';
import { AddonModDataSyncProvider } from '../../services/data-sync';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
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.
@ -66,7 +71,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
offset?: number;
title = '';
moduleName = 'data';
component = AddonModDataProvider.COMPONENT;
component = ADDON_MOD_DATA_COMPONENT;
entryLoaded = false;
renderingEntry = false;
loadingComments = false;
@ -102,7 +107,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
this.siteId = CoreSites.getCurrentSiteId();
// 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) {
return;
}
@ -120,7 +125,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
}, this.siteId);
// 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.deleted) {
// If deleted, go back.
@ -331,7 +336,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
return;
}
const perPage = AddonModDataProvider.PER_PAGE;
const perPage = ADDON_MOD_DATA_ENTRIES_PER_PAGE;
const page = this.offset !== undefined && this.offset >= 0
? Math.floor(this.offset / perPage)
: 0;

View File

@ -28,7 +28,6 @@ import { CoreEvents } from '@singletons/events';
import {
AddonModDataEntry,
AddonModData,
AddonModDataProvider,
AddonModDataSearchEntriesOptions,
AddonModDataEntries,
AddonModDataEntryFields,
@ -44,6 +43,7 @@ import {
import { AddonModDataFieldsDelegate } from './data-fields-delegate';
import { AddonModDataOffline, AddonModDataOfflineAction } from './data-offline';
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.
@ -171,7 +171,7 @@ export class AddonModDataHelperProvider {
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(
approve ? 'addon.mod_data.recordapproved' : 'addon.mod_data.recorddisapproved',
@ -878,7 +878,7 @@ export class AddonModDataHelperProvider {
// 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);
@ -969,7 +969,7 @@ export class AddonModDataHelperProvider {
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 { Translate, makeSingleton } from '@singletons';
import { CoreEvents } from '@singletons/events';
import { AddonModDataProvider, AddonModData, AddonModDataData, AddonModDataAction } from './data';
import { AddonModData, AddonModDataData, AddonModDataAction } from './data';
import { AddonModDataHelper } from './data-helper';
import { AddonModDataOffline, AddonModDataOfflineAction } from './data-offline';
import { ADDON_MOD_DATA_AUTO_SYNCED, ADDON_MOD_DATA_COMPONENT } from '../constants';
/**
* Service to sync databases.
@ -39,8 +40,6 @@ import { AddonModDataOffline, AddonModDataOfflineAction } from './data-offline';
@Injectable({ providedIn: 'root' })
export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider<AddonModDataSyncResult> {
static readonly AUTO_SYNCED = 'addon_mod_data_autom_synced';
protected componentTranslatableString = 'data';
constructor() {
@ -93,7 +92,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
if (result && result.updated) {
// Sync done. Send event.
CoreEvents.trigger(AddonModDataSyncProvider.AUTO_SYNCED, {
CoreEvents.trigger(ADDON_MOD_DATA_AUTO_SYNCED, {
dataId: dataId,
warnings: result.warnings,
}, siteId);
@ -142,7 +141,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
}
// 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.`);
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> {
// Sync offline logs.
await CoreUtils.ignoreErrors(
CoreCourseLogHelper.syncActivity(AddonModDataProvider.COMPONENT, dataId, siteId),
CoreCourseLogHelper.syncActivity(ADDON_MOD_DATA_COMPONENT, dataId, siteId),
);
const result: AddonModDataSyncResult = {
@ -243,7 +242,7 @@ export class AddonModDataSyncProvider extends CoreCourseActivitySyncBaseProvider
}
// Sync done. Send event.
CoreEvents.trigger(AddonModDataSyncProvider.AUTO_SYNCED, {
CoreEvents.trigger(ADDON_MOD_DATA_AUTO_SYNCED, {
dataId: database.id,
entryId: syncEntryResult.entryId,
offlineEntryId: syncEntryResult.offlineId,

View File

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

View File

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

View File

@ -24,9 +24,10 @@ import { CoreTimeUtils } from '@services/utils/time';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { AddonModDataProvider, AddonModDataEntry, AddonModData, AddonModDataData } from '../data';
import { AddonModDataEntry, AddonModData, AddonModDataData } from '../data';
import { AddonModDataSync, AddonModDataSyncResult } from '../data-sync';
import { ContextLevel } from '@/core/constants';
import { ADDON_MOD_DATA_COMPONENT } from '../../constants';
/**
* Handler to prefetch databases.
@ -36,7 +37,7 @@ export class AddonModDataPrefetchHandlerService extends CoreCourseActivityPrefet
name = 'AddonModData';
modName = 'data';
component = AddonModDataProvider.COMPONENT;
component = ADDON_MOD_DATA_COMPONENT;
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 { CoreDomUtils } from '@services/utils/dom';
import { makeSingleton } from '@singletons';
import { AddonModDataModuleHandlerService } from './module';
import { ADDON_MOD_DATA_FEATURE_NAME } from '../../constants';
import { ADDON_MOD_DATA_FEATURE_NAME, ADDON_MOD_DATA_PAGE_NAME } from '../../constants';
/**
* Content links handler for database show entry.
@ -67,7 +66,7 @@ export class AddonModDataShowLinkHandlerService extends CoreContentLinksHandlerB
}
await CoreNavigator.navigateToSitePath(
`${AddonModDataModuleHandlerService.PAGE_NAME}/${module.course}/${module.id}/${rId}`,
`${ADDON_MOD_DATA_PAGE_NAME}/${module.course}/${module.id}/${rId}`,
{ siteId, params: pageParams },
);
} finally {

View File

@ -16,13 +16,13 @@ import { CoreRoutedItemsManagerSource } from '@classes/items-management/routed-i
import { CoreGroupInfo, CoreGroups } from '@services/groups';
import {
AddonModFeedback,
AddonModFeedbackProvider,
AddonModFeedbackWSAnonAttempt,
AddonModFeedbackWSAttempt,
AddonModFeedbackWSFeedback,
} from '../services/feedback';
import { AddonModFeedbackHelper } from '../services/feedback-helper';
import { Params } from '@angular/router';
import { ADDON_MOD_FEEDBACK_PER_PAGE } from '../constants';
/**
* Feedback attempts.
@ -120,7 +120,7 @@ export class AddonModFeedbackAttemptsSource extends CoreRoutedItemsManagerSource
* @inheritdoc
*/
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[] = [
// 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.
...(page === 0 || result.totalattempts > AddonModFeedbackProvider.PER_PAGE)
...(page === 0 || result.totalattempts > ADDON_MOD_FEEDBACK_PER_PAGE)
? result.attempts
: [],
...(page === 0 || result.totalanonattempts > AddonModFeedbackProvider.PER_PAGE)
...(page === 0 || result.totalanonattempts > ADDON_MOD_FEEDBACK_PER_PAGE)
? result.anonattempts
: [],
];

View File

@ -27,7 +27,6 @@ import { CoreEventObserver, CoreEvents } from '@singletons/events';
import {
AddonModFeedback,
AddonModFeedbackGetFeedbackAccessInformationWSResponse,
AddonModFeedbackProvider,
AddonModFeedbackWSFeedback,
AddonModFeedbackWSItem,
} from '../../services/feedback';
@ -38,8 +37,8 @@ import {
AddonModFeedbackSyncProvider,
AddonModFeedbackSyncResult,
} from '../../services/feedback-sync';
import { AddonModFeedbackModuleHandlerService } from '../../services/handlers/module';
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.
@ -55,7 +54,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
@Input() tab = 'overview';
@Input() group = 0;
component = AddonModFeedbackProvider.COMPONENT;
component = ADDON_MOD_FEEDBACK_COMPONENT;
pluginName = 'feedback';
feedback?: AddonModFeedbackWSFeedback;
goPage?: number;
@ -92,7 +91,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
super('AddonModLessonIndexComponent', content, courseContentsPage);
// 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) {
return;
}
@ -374,7 +373,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
*/
gotoAnswerQuestions(preview: boolean = false): void {
CoreNavigator.navigateToSitePath(
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${this.courseId}/${this.module.id}/form`,
ADDON_MOD_FEEDBACK_PAGE_NAME + `/${this.courseId}/${this.module.id}/form`,
{
params: {
preview,
@ -407,7 +406,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
*/
openNonRespondents(): void {
CoreNavigator.navigateToSitePath(
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${this.courseId}/${this.module.id}/nonrespondents`,
ADDON_MOD_FEEDBACK_PAGE_NAME + `/${this.courseId}/${this.module.id}/nonrespondents`,
{
params: {
group: this.group,
@ -425,7 +424,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
}
CoreNavigator.navigateToSitePath(
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${this.courseId}/${this.module.id}/attempts`,
ADDON_MOD_FEEDBACK_PAGE_NAME + `/${this.courseId}/${this.module.id}/attempts`,
{
params: {
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,
],
})
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 { CORE_SITE_SCHEMAS } from '@services/sites';
import { OFFLINE_SITE_SCHEMA } from './services/database/feedback';
import { AddonModFeedbackProvider } from './services/feedback';
import { AddonModFeedbackAnalysisLinkHandler } from './services/handlers/analysis-link';
import { AddonModFeedbackCompleteLinkHandler } from './services/handlers/complete-link';
import { AddonModFeedbackIndexLinkHandler } from './services/handlers/index-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 { AddonModFeedbackPrintLinkHandler } from './services/handlers/print-link';
import { AddonModFeedbackPushClickHandler } from './services/handlers/push-click';
import { AddonModFeedbackShowEntriesLinkHandler } from './services/handlers/show-entries-link';
import { AddonModFeedbackShowNonRespondentsLinkHandler } from './services/handlers/show-non-respondents-link';
import { AddonModFeedbackSyncCronHandler } from './services/handlers/sync-cron';
import { ADDON_MOD_FEEDBACK_COMPONENT, ADDON_MOD_FEEDBACK_PAGE_NAME } from './constants';
const routes: Routes = [
{
path: AddonModFeedbackModuleHandlerService.PAGE_NAME,
loadChildren: () => import('./feedback-lazy.module').then(m => m.AddonModFeedbackLazyModule),
path: ADDON_MOD_FEEDBACK_PAGE_NAME,
loadChildren: () => import('./feedback-lazy.module'),
},
];
@ -69,7 +69,7 @@ const routes: Routes = [
CoreContentLinksDelegate.registerHandler(AddonModFeedbackShowNonRespondentsLinkHandler.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 {
AddonModFeedback,
AddonModFeedbackProvider,
AddonModFeedbackWSAnonAttempt,
AddonModFeedbackWSFeedback,
} from '../../services/feedback';
import { AddonModFeedbackAttempt, AddonModFeedbackFormItem, AddonModFeedbackHelper } from '../../services/feedback-helper';
import { CoreTime } from '@singletons/time';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { ADDON_MOD_FEEDBACK_COMPONENT } from '../../constants';
/**
* Page that displays a feedback attempt review.
@ -46,7 +46,7 @@ export class AddonModFeedbackAttemptPage implements OnInit, OnDestroy {
attempts: AddonModFeedbackAttemptsSwipeManager;
anonAttempt?: AddonModFeedbackWSAnonAttempt;
items: AddonModFeedbackAttemptItem[] = [];
component = AddonModFeedbackProvider.COMPONENT;
component = ADDON_MOD_FEEDBACK_COMPONENT;
loaded = false;
protected attemptId: number;

View File

@ -30,14 +30,13 @@ import {
AddonModFeedback,
AddonModFeedbackGetFeedbackAccessInformationWSResponse,
AddonModFeedbackPageItems,
AddonModFeedbackProvider,
AddonModFeedbackResponseValue,
AddonModFeedbackWSFeedback,
} from '../../services/feedback';
import { AddonModFeedbackFormItem, AddonModFeedbackHelper } from '../../services/feedback-helper';
import { AddonModFeedbackSync } from '../../services/feedback-sync';
import { AddonModFeedbackModuleHandlerService } from '../../services/handlers/module';
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.
@ -65,7 +64,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
courseId!: number;
feedback?: AddonModFeedbackWSFeedback;
completionPageContents?: string;
component = AddonModFeedbackProvider.COMPONENT;
component = ADDON_MOD_FEEDBACK_COMPONENT;
offline = false;
feedbackLoaded = false;
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.
CoreEvents.trigger(AddonModFeedbackProvider.FORM_SUBMITTED, {
CoreEvents.trigger(ADDON_MOD_FEEDBACK_FORM_SUBMITTED, {
feedbackId: this.feedback!.id,
tab: 'overview',
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).
await AddonModFeedback.invalidateResumePageData(this.feedback!.id);
CoreEvents.trigger(AddonModFeedbackProvider.FORM_SUBMITTED, {
CoreEvents.trigger(ADDON_MOD_FEEDBACK_FORM_SUBMITTED, {
feedbackId: this.feedback!.id,
tab: 'overview',
offline: this.completedOffline,
@ -395,7 +394,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
showAnalysis(): void {
if (this.fromIndex) {
// Previous page is the index page, go back.
CoreEvents.trigger(AddonModFeedbackProvider.FORM_SUBMITTED, {
CoreEvents.trigger(ADDON_MOD_FEEDBACK_FORM_SUBMITTED, {
feedbackId: this.feedback!.id,
tab: 'analysis',
offline: this.completedOffline,
@ -406,7 +405,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
return;
}
CoreNavigator.navigateToSitePath(AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${this.courseId}/${this.cmId}`, {
CoreNavigator.navigateToSitePath(ADDON_MOD_FEEDBACK_PAGE_NAME + `/${this.courseId}/${this.cmId}`, {
params: {
module: this.module,
tab: 'analysis',

View File

@ -28,12 +28,18 @@ import {
AddonModFeedbackGetResponsesAnalysisWSResponse,
AddonModFeedbackGroupPaginatedOptions,
AddonModFeedbackItem,
AddonModFeedbackProvider,
AddonModFeedbackResponseValue,
AddonModFeedbackWSAttempt,
AddonModFeedbackWSNonRespondent,
} 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_COURSE = 2;
@ -184,7 +190,7 @@ export class AddonModFeedbackHelperProvider {
if (params.showcompleted === undefined) {
// Param showcompleted not defined. Show entry list.
await CoreNavigator.navigateToSitePath(
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/attempts`,
ADDON_MOD_FEEDBACK_PAGE_NAME + `/${module.course}/${module.id}/attempts`,
{ siteId },
);
@ -198,7 +204,7 @@ export class AddonModFeedbackHelperProvider {
});
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: {
feedbackId: module.instance,
@ -295,7 +301,7 @@ export class AddonModFeedbackHelperProvider {
*/
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 rangeTo = range.length > 1 ? parseInt(range[1], 10) : undefined;
@ -320,7 +326,7 @@ export class AddonModFeedbackHelperProvider {
protected getItemFormTextfield(item: AddonModFeedbackItem): AddonModFeedbackTextItem {
return Object.assign(item, {
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 : '',
slottedLabel: true,
});
@ -348,7 +354,7 @@ export class AddonModFeedbackHelperProvider {
*/
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 formItem: AddonModFeedbackMultichoiceItem = Object.assign(item, {
@ -361,20 +367,20 @@ export class AddonModFeedbackHelperProvider {
formItem.presentation = parts.length > 1 ? parts[1] : '';
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] : '';
// 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) => {
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];
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.value = formItem.rawValue !== undefined ? Number(formItem.rawValue) : 0;
} else if (formItem.subtype === 'd') {
@ -383,7 +389,7 @@ export class AddonModFeedbackHelperProvider {
} else if (formItem.subtype === 'c') {
if (formItem.rawValue !== undefined) {
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) => {
for (const x in values) {
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 { makeSingleton, Translate } from '@singletons';
import { CoreEvents } from '@singletons/events';
import { AddonModFeedback, AddonModFeedbackProvider, AddonModFeedbackWSFeedback } from './feedback';
import { AddonModFeedback, AddonModFeedbackWSFeedback } from './feedback';
import { AddonModFeedbackOffline, AddonModFeedbackOfflineResponse } from './feedback-offline';
import { AddonModFeedbackPrefetchHandler, AddonModFeedbackPrefetchHandlerService } from './handlers/prefetch';
import { ADDON_MOD_FEEDBACK_COMPONENT } from '../constants';
/**
* Service to sync feedbacks.
@ -137,7 +138,7 @@ export class AddonModFeedbackSyncProvider extends CoreCourseActivitySyncBaseProv
}
// 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.`);
throw new CoreSyncBlockedError(Translate.instant('core.errorsyncblocked', { $a: this.componentTranslate }));
@ -162,7 +163,7 @@ export class AddonModFeedbackSyncProvider extends CoreCourseActivitySyncBaseProv
};
// 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.
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 { AddonModFeedbackAutoSyncData, AddonModFeedbackSyncProvider } from './feedback-sync';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'AddonModFeedback:';
import {
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.
@ -35,14 +42,7 @@ const ROOT_CACHE_KEY = 'AddonModFeedback:';
@Injectable({ providedIn: 'root' })
export class AddonModFeedbackProvider {
static readonly COMPONENT = 'mmaModFeedback';
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;
protected static readonly ROOT_CACHE_KEY = 'AddonModFeedback:';
/**
* 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.
*/
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 choicesStr = (parts[1] || '').split(AddonModFeedbackProvider.MULTICHOICE_ADJUST_SEP)[0] || '';
const choices = choicesStr.split(AddonModFeedbackProvider.LINE_SEP) || [];
const choicesStr = (parts[1] || '').split(ADDON_MOD_FEEDBACK_MULTICHOICE_ADJUST_SEP)[0] || '';
const choices = choicesStr.split(ADDON_MOD_FEEDBACK_LINE_SEP) || [];
let values: AddonModFeedbackResponseValue[];
if (subtype === 'c') {
@ -92,7 +92,7 @@ export class AddonModFeedbackProvider {
values = [''];
} else {
item.rawValue = '' + item.rawValue;
values = item.rawValue.split(AddonModFeedbackProvider.LINE_SEP);
values = item.rawValue.split(ADDON_MOD_FEEDBACK_LINE_SEP);
}
} else {
values = [item.rawValue || ''];
@ -104,7 +104,7 @@ export class AddonModFeedbackProvider {
let value = choices[index];
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) {
@ -195,10 +195,10 @@ export class AddonModFeedbackProvider {
}
// 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);
item.rawValue = offlineValues[item.id].join(AddonModFeedbackProvider.LINE_SEP);
item.rawValue = offlineValues[item.id].join(ADDON_MOD_FEEDBACK_LINE_SEP);
} else {
item.rawValue = offlineValues[item.id][0];
}
@ -314,7 +314,7 @@ export class AddonModFeedbackProvider {
};
const preSets: CoreSiteWSPreSets = {
cacheKey: this.getAnalysisDataCacheKey(feedbackId, options.groupId),
component: AddonModFeedbackProvider.COMPONENT,
component: ADDON_MOD_FEEDBACK_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -429,7 +429,7 @@ export class AddonModFeedbackProvider {
};
const preSets: CoreSiteWSPreSets = {
cacheKey: this.getCurrentCompletedTimeModifiedDataCacheKey(feedbackId),
component: AddonModFeedbackProvider.COMPONENT,
component: ADDON_MOD_FEEDBACK_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -476,7 +476,7 @@ export class AddonModFeedbackProvider {
};
const preSets: CoreSiteWSPreSets = {
cacheKey: this.getCurrentValuesDataCacheKey(feedbackId),
component: AddonModFeedbackProvider.COMPONENT,
component: ADDON_MOD_FEEDBACK_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -529,7 +529,7 @@ export class AddonModFeedbackProvider {
};
const preSets: CoreSiteWSPreSets = {
cacheKey: this.getFeedbackAccessInformationDataCacheKey(feedbackId),
component: AddonModFeedbackProvider.COMPONENT,
component: ADDON_MOD_FEEDBACK_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -554,7 +554,7 @@ export class AddonModFeedbackProvider {
* @returns Cache key.
*/
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.
*/
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 = {
cacheKey: this.getFeedbackCacheKey(courseId),
updateFrequency: CoreSite.FREQUENCY_RARELY,
component: AddonModFeedbackProvider.COMPONENT,
component: ADDON_MOD_FEEDBACK_COMPONENT,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -648,7 +648,7 @@ export class AddonModFeedbackProvider {
const preSets: CoreSiteWSPreSets = {
cacheKey: this.getItemsDataCacheKey(feedbackId),
updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
component: AddonModFeedbackProvider.COMPONENT,
component: ADDON_MOD_FEEDBACK_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -686,11 +686,11 @@ export class AddonModFeedbackProvider {
feedbackid: feedbackId,
groupid: options.groupId,
page: options.page,
perpage: AddonModFeedbackProvider.PER_PAGE,
perpage: ADDON_MOD_FEEDBACK_PER_PAGE,
};
const preSets: CoreSiteWSPreSets = {
cacheKey: this.getNonRespondentsDataCacheKey(feedbackId, options.groupId),
component: AddonModFeedbackProvider.COMPONENT,
component: ADDON_MOD_FEEDBACK_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -862,11 +862,11 @@ export class AddonModFeedbackProvider {
feedbackid: feedbackId,
groupid: options.groupId,
page: options.page,
perpage: AddonModFeedbackProvider.PER_PAGE,
perpage: ADDON_MOD_FEEDBACK_PER_PAGE,
};
const preSets: CoreSiteWSPreSets = {
cacheKey: this.getResponsesAnalysisDataCacheKey(feedbackId, options.groupId),
component: AddonModFeedbackProvider.COMPONENT,
component: ADDON_MOD_FEEDBACK_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -910,7 +910,7 @@ export class AddonModFeedbackProvider {
};
const preSets = {
cacheKey: this.getResumePageDataCacheKey(feedbackId),
component: AddonModFeedbackProvider.COMPONENT,
component: ADDON_MOD_FEEDBACK_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -1024,7 +1024,7 @@ export class AddonModFeedbackProvider {
* @returns Promise resolved when the files are invalidated.
*/
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 = {
cacheKey: this.getCompletedDataCacheKey(feedbackId),
updateFrequency: CoreSite.FREQUENCY_RARELY,
component: AddonModFeedbackProvider.COMPONENT,
component: ADDON_MOD_FEEDBACK_COMPONENT,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -1106,7 +1106,7 @@ export class AddonModFeedbackProvider {
await CoreCourseLogHelper.log(
'mod_feedback_view_feedback',
params,
AddonModFeedbackProvider.COMPONENT,
ADDON_MOD_FEEDBACK_COMPONENT,
id,
siteId,
);
@ -1252,7 +1252,7 @@ declare module '@singletons/events' {
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
*/
export interface CoreEventsData {
[AddonModFeedbackProvider.FORM_SUBMITTED]: AddonModFeedbackFormSubmittedData;
[ADDON_MOD_FEEDBACK_FORM_SUBMITTED]: AddonModFeedbackFormSubmittedData;
[AddonModFeedbackSyncProvider.AUTO_SYNCED]: AddonModFeedbackAutoSyncData;
}

View File

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

View File

@ -20,7 +20,7 @@ import { CoreNavigator } from '@services/navigator';
import { CoreSitesReadingStrategy } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { makeSingleton } from '@singletons';
import { AddonModFeedbackModuleHandlerService } from './module';
import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants';
/**
* Content links handler for feedback complete questions.
@ -50,7 +50,7 @@ export class AddonModFeedbackCompleteLinkHandlerService extends CoreContentLinks
);
await CoreNavigator.navigateToSitePath(
AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/form`,
ADDON_MOD_FEEDBACK_PAGE_NAME + `/${module.course}/${module.id}/form`,
{
params: {
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 { makeSingleton } from '@singletons';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants';
/**
* Handler to support feedback modules.
@ -24,11 +25,9 @@ import { CoreModuleHandlerBase } from '@features/course/classes/module-base-hand
@Injectable({ providedIn: 'root' })
export class AddonModFeedbackModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler {
static readonly PAGE_NAME = 'mod_feedback';
name = 'AddonModFeedback';
modName = 'feedback';
protected pageName = AddonModFeedbackModuleHandlerService.PAGE_NAME;
protected pageName = ADDON_MOD_FEEDBACK_PAGE_NAME;
supportedFeatures = {
[CoreConstants.FEATURE_GROUPS]: true,

View File

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

View File

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

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