MOBILE-4497 competency: Use adv features to check if competencies are on
parent
9fc9b166a9
commit
ff0108d796
|
@ -42,18 +42,34 @@ export class AddonCompetencyProvider {
|
||||||
static readonly REVIEW_STATUS_WAITING_FOR_REVIEW = 1;
|
static readonly REVIEW_STATUS_WAITING_FOR_REVIEW = 1;
|
||||||
static readonly REVIEW_STATUS_IN_REVIEW = 2;
|
static readonly REVIEW_STATUS_IN_REVIEW = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if competencies are enabled in a certain site.
|
||||||
|
*
|
||||||
|
* @param options Site ID or site object.
|
||||||
|
* @returns Whether competencies are enabled.
|
||||||
|
*/
|
||||||
|
async areCompetenciesEnabled(options?: {siteId?: string; site?: CoreSite}): Promise<boolean> {
|
||||||
|
const site = options?.site ? options.site : await CoreSites.getSite(options?.siteId);
|
||||||
|
|
||||||
|
if (!site) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return site.canUseAdvancedFeature('enablecompetencies') &&
|
||||||
|
!(site.isFeatureDisabled('CoreMainMenuDelegate_AddonCompetency') &&
|
||||||
|
site.isFeatureDisabled('CoreCourseOptionsDelegate_AddonCompetency') &&
|
||||||
|
site.isFeatureDisabled('CoreUserDelegate_AddonCompetency'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if all competencies features are disabled.
|
* Check if all competencies features are disabled.
|
||||||
*
|
*
|
||||||
* @param siteId Site ID. If not defined, current site.
|
* @param siteId Site ID. If not defined, current site.
|
||||||
* @returns Promise resolved with boolean: whether all competency features are disabled.
|
* @returns Promise resolved with boolean: whether all competency features are disabled.
|
||||||
|
* @deprecated since 4.4. Use areCompetenciesEnabled instead.
|
||||||
*/
|
*/
|
||||||
async allCompetenciesDisabled(siteId?: string): Promise<boolean> {
|
async allCompetenciesDisabled(siteId?: string): Promise<boolean> {
|
||||||
const site = await CoreSites.getSite(siteId);
|
return !(await this.areCompetenciesEnabled({ siteId }));
|
||||||
|
|
||||||
return site.isFeatureDisabled('CoreMainMenuDelegate_AddonCompetency') &&
|
|
||||||
site.isFeatureDisabled('CoreCourseOptionsDelegate_AddonCompetency') &&
|
|
||||||
site.isFeatureDisabled('CoreUserDelegate_AddonCompetency');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,6 +85,11 @@ export class AddonCompetencyProvider {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const enabled = await this.areCompetenciesEnabled({ siteId });
|
||||||
|
if (!enabled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await this.getCourseCompetenciesPage(courseId, siteId);
|
const response = await this.getCourseCompetenciesPage(courseId, siteId);
|
||||||
|
|
||||||
|
|
|
@ -70,10 +70,7 @@ export class AddonCompetencyCompetencyLinkHandlerService extends CoreContentLink
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async isEnabled(siteId: string): Promise<boolean> {
|
async isEnabled(siteId: string): Promise<boolean> {
|
||||||
// Handler is disabled if all competency features are disabled.
|
return AddonCompetency.areCompetenciesEnabled({ siteId });
|
||||||
const disabled = await AddonCompetency.allCompetenciesDisabled(siteId);
|
|
||||||
|
|
||||||
return !disabled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ export class AddonCompetencyCourseOptionHandlerService implements CoreCourseOpti
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async isEnabled(): Promise<boolean> {
|
async isEnabled(): Promise<boolean> {
|
||||||
return true;
|
return AddonCompetency.areCompetenciesEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -48,10 +48,7 @@ export class AddonCompetencyPlanLinkHandlerService extends CoreContentLinksHandl
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async isEnabled(siteId: string): Promise<boolean> {
|
async isEnabled(siteId: string): Promise<boolean> {
|
||||||
// Handler is disabled if all competency features are disabled.
|
return AddonCompetency.areCompetenciesEnabled({ siteId });
|
||||||
const disabled = await AddonCompetency.allCompetenciesDisabled(siteId);
|
|
||||||
|
|
||||||
return !disabled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,10 +49,7 @@ export class AddonCompetencyPlansLinkHandlerService extends CoreContentLinksHand
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async isEnabled(siteId: string): Promise<boolean> {
|
async isEnabled(siteId: string): Promise<boolean> {
|
||||||
// Handler is disabled if all competency features are disabled.
|
return AddonCompetency.areCompetenciesEnabled({ siteId });
|
||||||
const disabled = await AddonCompetency.allCompetenciesDisabled(siteId);
|
|
||||||
|
|
||||||
return !disabled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ export class AddonCompetencyPushClickHandlerService implements CorePushNotificat
|
||||||
if (CoreUtils.isTrueOrOne(notification.notif) && notification.moodlecomponent == 'moodle' &&
|
if (CoreUtils.isTrueOrOne(notification.notif) && notification.moodlecomponent == 'moodle' &&
|
||||||
(notification.name == 'competencyplancomment' || notification.name == 'competencyusercompcomment')) {
|
(notification.name == 'competencyplancomment' || notification.name == 'competencyusercompcomment')) {
|
||||||
// If all competency features are disabled, don't handle the click.
|
// If all competency features are disabled, don't handle the click.
|
||||||
return AddonCompetency.allCompetenciesDisabled(notification.site).then((disabled) => !disabled);
|
return AddonCompetency.areCompetenciesEnabled({ siteId: notification.site });
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -48,10 +48,7 @@ export class AddonCompetencyUserCompetencyLinkHandlerService extends CoreContent
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async isEnabled(siteId: string): Promise<boolean> {
|
async isEnabled(siteId: string): Promise<boolean> {
|
||||||
// Handler is disabled if all competency features are disabled.
|
return AddonCompetency.areCompetenciesEnabled({ siteId });
|
||||||
const disabled = await AddonCompetency.allCompetenciesDisabled(siteId);
|
|
||||||
|
|
||||||
return !disabled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ export class AddonCompetencyUserHandlerService implements CoreUserProfileHandler
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async isEnabled(): Promise<boolean> {
|
async isEnabled(): Promise<boolean> {
|
||||||
return true;
|
return AddonCompetency.areCompetenciesEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -175,6 +175,15 @@ Feature: Test competency navigation
|
||||||
Then I should find "Desserts are important" in the app
|
Then I should find "Desserts are important" in the app
|
||||||
But I should not find "Cakes" in the app
|
But I should not find "Cakes" in the app
|
||||||
|
|
||||||
|
Given the following config values are set as admin:
|
||||||
|
| enabled | 0 | core_competency |
|
||||||
|
When I entered the course "Course 1" as "student1" in the app
|
||||||
|
Then I should not find "Competencies" in the app
|
||||||
|
|
||||||
|
When I press the back button in the app
|
||||||
|
And I press the user menu button in the app
|
||||||
|
And I should not find "Learning plans" in the app
|
||||||
|
|
||||||
Scenario: Mobile navigation (teacher)
|
Scenario: Mobile navigation (teacher)
|
||||||
Given I entered the course "Course 1" as "teacher1" in the app
|
Given I entered the course "Course 1" as "teacher1" in the app
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue