MOBILE-4538 mod: Check module is enabled in related delegates

main
Pau Ferrer Ocaña 2024-03-08 15:31:10 +01:00
parent dc1b9e9575
commit ae4c1ce28a
16 changed files with 106 additions and 7 deletions

View File

@ -0,0 +1,15 @@
// (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_ASSIGN_FEATURE_NAME = 'CoreCourseModuleDelegate_AddonModAssign';

View File

@ -21,6 +21,8 @@ import { CoreWSFile } from '@services/ws';
import { AddonModAssignSubmissionFormatted } from './assign-helper'; import { AddonModAssignSubmissionFormatted } from './assign-helper';
import { CoreFormFields } from '@singletons/form'; import { CoreFormFields } from '@singletons/form';
import type { IAddonModAssignFeedbackPluginComponent } from '@addons/mod/assign/classes/base-feedback-plugin-component'; import type { IAddonModAssignFeedbackPluginComponent } from '@addons/mod/assign/classes/base-feedback-plugin-component';
import { CoreSites } from '@services/sites';
import { ADDON_MOD_ASSIGN_FEATURE_NAME } from '../constants';
/** /**
* Interface that all feedback handlers must implement. * Interface that all feedback handlers must implement.
@ -188,6 +190,13 @@ export class AddonModAssignFeedbackDelegateService extends CoreDelegate<AddonMod
super('AddonModAssignFeedbackDelegate'); super('AddonModAssignFeedbackDelegate');
} }
/**
* @inheritdoc
*/
async isEnabled(): Promise<boolean> {
return !(await CoreSites.isFeatureDisabled(ADDON_MOD_ASSIGN_FEATURE_NAME));
}
/** /**
* Discard the draft data of the feedback plugin. * Discard the draft data of the feedback plugin.
* *

View File

@ -20,6 +20,7 @@ import { CoreUrlUtils } from '@services/utils/url';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonModAssign } from '../assign'; import { AddonModAssign } from '../assign';
import { ADDON_MOD_ASSIGN_FEATURE_NAME } from '../../constants';
/** /**
* Handler for assign push notifications clicks. * Handler for assign push notifications clicks.
@ -29,7 +30,7 @@ export class AddonModAssignPushClickHandlerService implements CorePushNotificati
name = 'AddonModAssignPushClickHandler'; name = 'AddonModAssignPushClickHandler';
priority = 200; priority = 200;
featureName = 'CoreCourseModuleDelegate_AddonModAssign'; featureName = ADDON_MOD_ASSIGN_FEATURE_NAME;
/** /**
* Check if a notification click is handled by this handler. * Check if a notification click is handled by this handler.

View File

@ -21,6 +21,8 @@ import { CoreWSFile } from '@services/ws';
import { AddonModAssignSubmissionsDBRecordFormatted } from './assign-offline'; import { AddonModAssignSubmissionsDBRecordFormatted } from './assign-offline';
import { CoreFormFields } from '@singletons/form'; import { CoreFormFields } from '@singletons/form';
import type { AddonModAssignSubmissionPluginBaseComponent } from '@addons/mod/assign/classes/base-submission-plugin-component'; import type { AddonModAssignSubmissionPluginBaseComponent } from '@addons/mod/assign/classes/base-submission-plugin-component';
import { CoreSites } from '@services/sites';
import { ADDON_MOD_ASSIGN_FEATURE_NAME } from '../constants';
/** /**
* Interface that all submission handlers must implement. * Interface that all submission handlers must implement.
@ -280,6 +282,13 @@ export class AddonModAssignSubmissionDelegateService extends CoreDelegate<AddonM
super('AddonModAssignSubmissionDelegate'); super('AddonModAssignSubmissionDelegate');
} }
/**
* @inheritdoc
*/
async isEnabled(): Promise<boolean> {
return !(await CoreSites.isFeatureDisabled(ADDON_MOD_ASSIGN_FEATURE_NAME));
}
/** /**
* Whether the plugin can be edited in offline for existing submissions. * Whether the plugin can be edited in offline for existing submissions.
* *

View File

@ -0,0 +1,15 @@
// (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_DATA_FEATURE_NAME = 'CoreCourseModuleDelegate_AddonModData';

View File

@ -25,6 +25,8 @@ import { CoreFormFields } from '@singletons/form';
import { FileEntry } from '@awesome-cordova-plugins/file/ngx'; import { FileEntry } from '@awesome-cordova-plugins/file/ngx';
import { CoreFileEntry } from '@services/file-helper'; import { CoreFileEntry } from '@services/file-helper';
import type { AddonModDataFieldPluginBaseComponent } from '@addons/mod/data/classes/base-field-plugin-component'; import type { AddonModDataFieldPluginBaseComponent } from '@addons/mod/data/classes/base-field-plugin-component';
import { CoreSites } from '@services/sites';
import { ADDON_MOD_DATA_FEATURE_NAME } from '../constants';
/** /**
* Interface that all fields handlers must implement. * Interface that all fields handlers must implement.
@ -135,6 +137,13 @@ export class AddonModDataFieldsDelegateService extends CoreDelegate<AddonModData
super('AddonModDataFieldsDelegate'); super('AddonModDataFieldsDelegate');
} }
/**
* @inheritdoc
*/
async isEnabled(): Promise<boolean> {
return !(await CoreSites.isFeatureDisabled(ADDON_MOD_DATA_FEATURE_NAME));
}
/** /**
* Get the component to use for a certain field field. * Get the component to use for a certain field field.
* *

View File

@ -17,6 +17,7 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonModDataHelper } from '../data-helper'; import { AddonModDataHelper } from '../data-helper';
import { ADDON_MOD_DATA_FEATURE_NAME } from '../../constants';
/** /**
* Content links handler for database approve/disapprove entry. * Content links handler for database approve/disapprove entry.
@ -26,7 +27,7 @@ import { AddonModDataHelper } from '../data-helper';
export class AddonModDataApproveLinkHandlerService extends CoreContentLinksHandlerBase { export class AddonModDataApproveLinkHandlerService extends CoreContentLinksHandlerBase {
name = 'AddonModDataApproveLinkHandler'; name = 'AddonModDataApproveLinkHandler';
featureName = 'CoreCourseModuleDelegate_AddonModData'; featureName = ADDON_MOD_DATA_FEATURE_NAME;
pattern = /\/mod\/data\/view\.php.*([?&](d|approve|disapprove)=\d+)/; pattern = /\/mod\/data\/view\.php.*([?&](d|approve|disapprove)=\d+)/;
priority = 50; // Higher priority than the default link handler for view.php. priority = 50; // Higher priority than the default link handler for view.php.

View File

@ -17,6 +17,7 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonModDataHelper } from '../data-helper'; import { AddonModDataHelper } from '../data-helper';
import { ADDON_MOD_DATA_FEATURE_NAME } from '../../constants';
/** /**
* Content links handler for database delete entry. * Content links handler for database delete entry.
@ -26,7 +27,7 @@ import { AddonModDataHelper } from '../data-helper';
export class AddonModDataDeleteLinkHandlerService extends CoreContentLinksHandlerBase { export class AddonModDataDeleteLinkHandlerService extends CoreContentLinksHandlerBase {
name = 'AddonModDataDeleteLinkHandler'; name = 'AddonModDataDeleteLinkHandler';
featureName = 'CoreCourseModuleDelegate_AddonModData'; featureName = ADDON_MOD_DATA_FEATURE_NAME;
pattern = /\/mod\/data\/view\.php.*([?&](d|delete)=\d+)/; pattern = /\/mod\/data\/view\.php.*([?&](d|delete)=\d+)/;
/** /**

View File

@ -22,6 +22,7 @@ import { CoreSitesReadingStrategy } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom'; import { CoreDomUtils } from '@services/utils/dom';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonModDataModuleHandlerService } from './module'; import { AddonModDataModuleHandlerService } from './module';
import { ADDON_MOD_DATA_FEATURE_NAME } from '../../constants';
/** /**
* Content links handler for database add or edit entry. * Content links handler for database add or edit entry.
@ -31,7 +32,7 @@ import { AddonModDataModuleHandlerService } from './module';
export class AddonModDataEditLinkHandlerService extends CoreContentLinksHandlerBase { export class AddonModDataEditLinkHandlerService extends CoreContentLinksHandlerBase {
name = 'AddonModDataEditLinkHandler'; name = 'AddonModDataEditLinkHandler';
featureName = 'CoreCourseModuleDelegate_AddonModData'; featureName = ADDON_MOD_DATA_FEATURE_NAME;
pattern = /\/mod\/data\/edit\.php.*([?&](d|rid)=\d+)/; pattern = /\/mod\/data\/edit\.php.*([?&](d|rid)=\d+)/;
/** /**

View File

@ -22,6 +22,7 @@ import { CoreSitesReadingStrategy } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom'; import { CoreDomUtils } from '@services/utils/dom';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonModDataModuleHandlerService } from './module'; import { AddonModDataModuleHandlerService } from './module';
import { ADDON_MOD_DATA_FEATURE_NAME } from '../../constants';
/** /**
* Content links handler for database show entry. * Content links handler for database show entry.
@ -31,7 +32,7 @@ import { AddonModDataModuleHandlerService } from './module';
export class AddonModDataShowLinkHandlerService extends CoreContentLinksHandlerBase { export class AddonModDataShowLinkHandlerService extends CoreContentLinksHandlerBase {
name = 'AddonModDataShowLinkHandler'; name = 'AddonModDataShowLinkHandler';
featureName = 'CoreCourseModuleDelegate_AddonModData'; featureName = ADDON_MOD_DATA_FEATURE_NAME;
pattern = /\/mod\/data\/view\.php.*([?&](d|rid|page|group|mode)=\d+)/; pattern = /\/mod\/data\/view\.php.*([?&](d|rid|page|group|mode)=\d+)/;
priority = 50; // Higher priority than the default link handler for view.php. priority = 50; // Higher priority than the default link handler for view.php.

View File

@ -0,0 +1,15 @@
// (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_QUIZ_FEATURE_NAME = 'CoreCourseModuleDelegate_AddonModQuiz';

View File

@ -18,6 +18,8 @@ import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonModQuizAttemptWSData, AddonModQuizQuizWSData } from './quiz'; import { AddonModQuizAttemptWSData, AddonModQuizQuizWSData } from './quiz';
import { CoreSites } from '@services/sites';
import { ADDON_MOD_QUIZ_FEATURE_NAME } from '../constants';
/** /**
* Interface that all access rules handlers must implement. * Interface that all access rules handlers must implement.
@ -131,6 +133,13 @@ export class AddonModQuizAccessRuleDelegateService extends CoreDelegate<AddonMod
super('AddonModQuizAccessRulesDelegate'); super('AddonModQuizAccessRulesDelegate');
} }
/**
* @inheritdoc
*/
async isEnabled(): Promise<boolean> {
return !(await CoreSites.isFeatureDisabled(ADDON_MOD_QUIZ_FEATURE_NAME));
}
/** /**
* Get the handler for a certain rule. * Get the handler for a certain rule.
* *

View File

@ -23,6 +23,7 @@ import { makeSingleton } from '@singletons';
import { AddonModQuiz } from '../quiz'; import { AddonModQuiz } from '../quiz';
import { AddonModQuizHelper } from '../quiz-helper'; import { AddonModQuizHelper } from '../quiz-helper';
import { isSafeNumber } from '@/core/utils/types'; import { isSafeNumber } from '@/core/utils/types';
import { ADDON_MOD_QUIZ_FEATURE_NAME } from '../../constants';
/** /**
* Handler for quiz push notifications clicks. * Handler for quiz push notifications clicks.
@ -32,7 +33,7 @@ export class AddonModQuizPushClickHandlerService implements CorePushNotification
name = 'AddonModQuizPushClickHandler'; name = 'AddonModQuizPushClickHandler';
priority = 200; priority = 200;
featureName = 'CoreCourseModuleDelegate_AddonModQuiz'; featureName = ADDON_MOD_QUIZ_FEATURE_NAME;
protected readonly SUPPORTED_NAMES = ['submission', 'confirmation', 'attempt_overdue']; protected readonly SUPPORTED_NAMES = ['submission', 'confirmation', 'attempt_overdue'];

View File

@ -17,6 +17,7 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { AddonModQuizHelper } from '../quiz-helper'; import { AddonModQuizHelper } from '../quiz-helper';
import { ADDON_MOD_QUIZ_FEATURE_NAME } from '../../constants';
/** /**
* Handler to treat links to quiz review. * Handler to treat links to quiz review.
@ -25,7 +26,7 @@ import { AddonModQuizHelper } from '../quiz-helper';
export class AddonModQuizReviewLinkHandlerService extends CoreContentLinksHandlerBase { export class AddonModQuizReviewLinkHandlerService extends CoreContentLinksHandlerBase {
name = 'AddonModQuizReviewLinkHandler'; name = 'AddonModQuizReviewLinkHandler';
featureName = 'CoreCourseModuleDelegate_AddonModQuiz'; featureName = ADDON_MOD_QUIZ_FEATURE_NAME;
pattern = /\/mod\/quiz\/review\.php.*([&?]attempt=\d+)/; pattern = /\/mod\/quiz\/review\.php.*([&?]attempt=\d+)/;
/** /**

View File

@ -39,3 +39,5 @@ export const ADDON_MOD_WORKSHOP_PREFETCH_UPDATE_NAMES = new RegExp(
); );
export const ADDON_MOD_WORKSHOP_SYNC_CRON_NAME = 'AddonModWorkshopSyncCronHandler'; export const ADDON_MOD_WORKSHOP_SYNC_CRON_NAME = 'AddonModWorkshopSyncCronHandler';
export const ADDON_MOD_WORKSHOP_FEATURE_NAME = 'CoreCourseModuleDelegate_AddonModWorkshop';

View File

@ -17,6 +17,8 @@ import { CoreDelegateHandler, CoreDelegate } from '@classes/delegate';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { CoreFormFields } from '@singletons/form'; import { CoreFormFields } from '@singletons/form';
import { AddonModWorkshopGetAssessmentFormDefinitionData, AddonModWorkshopGetAssessmentFormFieldsParsedData } from './workshop'; import { AddonModWorkshopGetAssessmentFormDefinitionData, AddonModWorkshopGetAssessmentFormFieldsParsedData } from './workshop';
import { CoreSites } from '@services/sites';
import { ADDON_MOD_WORKSHOP_FEATURE_NAME } from '../constants';
/** /**
* Interface that all assessment strategy handlers must implement. * Interface that all assessment strategy handlers must implement.
@ -86,6 +88,13 @@ export class AddonWorkshopAssessmentStrategyDelegateService extends CoreDelegate
super('AddonWorkshopAssessmentStrategyDelegate'); super('AddonWorkshopAssessmentStrategyDelegate');
} }
/**
* @inheritdoc
*/
async isEnabled(): Promise<boolean> {
return !(await CoreSites.isFeatureDisabled(ADDON_MOD_WORKSHOP_FEATURE_NAME));
}
/** /**
* Check if an assessment strategy plugin is supported. * Check if an assessment strategy plugin is supported.
* *