MOBILE-2323 learning plans: PR fixes

main
Albert Gasset 2018-03-13 10:21:43 +01:00
parent 61ab280b2d
commit 92085c4889
23 changed files with 95 additions and 207 deletions

View File

@ -26,7 +26,8 @@
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "gulp watch | ionic-app-scripts serve",
"ionic:build:before": "gulp"
"ionic:build:before": "gulp",
"ionic:watch:before": "gulp"
},
"dependencies": {
"@angular/animations": "^5.2.5",

View File

@ -19,14 +19,13 @@ import { AddonCompetencyCourseOptionHandler } from './providers/course-option-ha
import { AddonCompetencyMainMenuHandler } from './providers/mainmenu-handler';
import { AddonCompetencyUserHandler } from './providers/user-handler';
import { AddonCompetencyComponentsModule } from './components/components.module';
import { CoreCourseProvider } from '../../core/course/providers/course';
import { CoreCourseOptionsDelegate } from '../../core/course/providers/options-delegate';
import { CoreMainMenuDelegate } from '../../core/mainmenu/providers/delegate';
import { CoreUserDelegate } from '../../core/user/providers/user-delegate';
import { CoreUserProvider } from '../../core/user/providers/user';
import { CoreEventsProvider } from '../../providers/events';
import { CoreSitesProvider } from '../../providers/sites';
import { CoreCoursesProvider } from '../../core/courses/providers/courses';
import { CoreCourseOptionsDelegate } from '@core/course/providers/options-delegate';
import { CoreMainMenuDelegate } from '@core/mainmenu/providers/delegate';
import { CoreUserDelegate } from '@core/user/providers/user-delegate';
import { CoreUserProvider } from '@core/user/providers/user';
import { CoreEventsProvider } from '@providers/events';
import { CoreSitesProvider } from '@providers/sites';
import { CoreCoursesProvider } from '@core/courses/providers/courses';
@NgModule({
declarations: [

View File

@ -16,9 +16,9 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { IonicModule } from 'ionic-angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreComponentsModule } from '../../../components/components.module';
import { CoreDirectivesModule } from '../../../directives/directives.module';
import { CorePipesModule } from '../../../pipes/pipes.module';
import { CoreComponentsModule } from '@components/components.module';
import { CoreDirectivesModule } from '@directives/directives.module';
import { CorePipesModule } from '@pipes/pipes.module';
import { AddonCompetencyCourseComponent } from './course/course';
@NgModule({

View File

@ -18,7 +18,7 @@
<ion-item text-wrap *ngIf="competencies.statistics.leastproficientcount > 0">
<strong>{{ 'addon.competency.competenciesmostoftennotproficientincourse' | translate }}</strong>:
<p *ngFor="let comp of competencies.statistics.leastproficient">
<a ui-sref="openCompetencySummary(comp.id)">
<a (click)="openCompetencySummary(comp.id)">
{{ comp.shortname }} - {{ comp.idnumber }}
</a>
</p>
@ -43,7 +43,7 @@
<ion-card *ngFor="let competency of competencies.competencies">
<a ion-item text-wrap (click)="openCompetency(competency.competency.id)" [title]="competency.competency.shortname">
{{competency.competency.shortname}} <small>{{competency.competency.idnumber}}</small>
<ion-badge item-end *ngIf="competency.usercompetencycourse && competency.usercompetencycourse.gradename" [color]="competency.usercompetencycourse.proficiency ? 'success' : 'danger'">{{ competency.usercompetencycourse.gradename }}</ion-badge><br>
<ion-badge item-end *ngIf="competency.usercompetencycourse && competency.usercompetencycourse.gradename" [color]="competency.usercompetencycourse.proficiency ? 'success' : 'danger'">{{ competency.usercompetencycourse.gradename }}</ion-badge>
</a>
<ion-item text-wrap>
<div *ngIf="competency.competency.description">

View File

@ -12,11 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { Component, ViewChild, Input, Optional } from '@angular/core';
import { Component, ViewChild, Input } from '@angular/core';
import { Content, NavController } from 'ionic-angular';
import { TranslateService } from '@ngx-translate/core';
import { CoreAppProvider } from '../../../../providers/app';
import { CoreDomUtilsProvider } from '../../../../providers/utils/dom';
import { CoreAppProvider } from '@providers/app';
import { CoreDomUtilsProvider } from '@providers/utils/dom';
import { AddonCompetencyProvider } from '../../providers/competency';
import { AddonCompetencyHelperProvider } from '../../providers/helper';
@ -64,14 +64,8 @@ export class AddonCompetencyCourseComponent {
this.helperProvider.getProfile(this.userId).then((user) => {
this.user = user;
});
}, (message) => {
if (message) {
this.domUtils.showErrorModal(message);
} else {
this.domUtils.showErrorModal('Error getting course competencies data.');
}
return Promise.reject(null);
}).catch((message) => {
this.domUtils.showErrorModalDefault(message, 'Error getting course competencies data.');
});
}

View File

@ -15,9 +15,7 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreComponentsModule } from '../../../../components/components.module';
import { CoreDirectivesModule } from '../../../../directives/directives.module';
import { CorePipesModule } from '../../../../pipes/pipes.module';
import { CoreComponentsModule } from '@components/components.module';
import { AddonCompetencyCompetenciesPage } from './competencies';
@NgModule({
@ -26,8 +24,6 @@ import { AddonCompetencyCompetenciesPage } from './competencies';
],
imports: [
CoreComponentsModule,
CoreDirectivesModule,
CorePipesModule,
IonicPageModule.forChild(AddonCompetencyCompetenciesPage),
TranslateModule.forChild()
],

View File

@ -13,10 +13,10 @@
// limitations under the License.
import { Component, ViewChild } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { IonicPage, NavParams } from 'ionic-angular';
import { TranslateService } from '@ngx-translate/core';
import { CoreDomUtilsProvider } from '../../../../providers/utils/dom';
import { CoreSplitViewComponent } from '../../../../components/split-view/split-view';
import { CoreDomUtilsProvider } from '@providers/utils/dom';
import { CoreSplitViewComponent } from '@components/split-view/split-view';
import { AddonCompetencyProvider } from '../../providers/competency';
/**
@ -39,8 +39,8 @@ export class AddonCompetencyCompetenciesPage {
competencies = [];
title: string;
constructor(private navCtrl: NavController, navParams: NavParams, private translate: TranslateService,
private domUtils: CoreDomUtilsProvider, private competencyProvider: AddonCompetencyProvider) {
constructor(navParams: NavParams, private translate: TranslateService, private domUtils: CoreDomUtilsProvider,
private competencyProvider: AddonCompetencyProvider) {
this.planId = navParams.get('planId');
this.courseId = navParams.get('courseId');
this.competencyId = navParams.get('competencyId');
@ -95,13 +95,7 @@ export class AddonCompetencyCompetenciesPage {
}
this.competencies = response.competencies;
}).catch((message) => {
if (message) {
this.domUtils.showErrorModal(message);
} else {
this.domUtils.showErrorModal('Error getting competencies data.');
}
return Promise.reject(null);
this.domUtils.showErrorModalDefault(message, 'Error getting competencies data.');
});
}

View File

@ -15,9 +15,9 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreComponentsModule } from '../../../../components/components.module';
import { CoreDirectivesModule } from '../../../../directives/directives.module';
import { CorePipesModule } from '../../../../pipes/pipes.module';
import { CoreComponentsModule } from '@components/components.module';
import { CoreDirectivesModule } from '@directives/directives.module';
import { CorePipesModule } from '@pipes/pipes.module';
import { AddonCompetencyCompetencyPage } from './competency';
@NgModule({

View File

@ -15,9 +15,9 @@
import { Component, Optional } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { TranslateService } from '@ngx-translate/core';
import { CoreSitesProvider } from '../../../../providers/sites';
import { CoreDomUtilsProvider } from '../../../../providers/utils/dom';
import { CoreSplitViewComponent } from '../../../../components/split-view/split-view';
import { CoreSitesProvider } from '@providers/sites';
import { CoreDomUtilsProvider } from '@providers/utils/dom';
import { CoreSplitViewComponent } from '@components/split-view/split-view';
import { AddonCompetencyProvider } from '../../providers/competency';
/**
@ -103,14 +103,8 @@ export class AddonCompetencyCompetencyPage {
evidence.description = this.translate.instant(key, {$a: evidence.desca});
}
});
}, (message) => {
if (message) {
this.domUtils.showErrorModal(message);
} else {
this.domUtils.showErrorModal('Error getting competency data.');
}
return Promise.reject(null);
}).catch((message) => {
this.domUtils.showErrorModalDefault(message, 'Error getting competency data.');
});
}
@ -118,9 +112,9 @@ export class AddonCompetencyCompetencyPage {
* Convenience function to get the review status name translated.
*
* @param {number} status
* @return {any}
* @return {string}
*/
protected getStatusName(status: number): any {
protected getStatusName(status: number): string {
let statusTranslateName;
switch (status) {
case AddonCompetencyProvider.REVIEW_STATUS_IDLE:
@ -134,7 +128,7 @@ export class AddonCompetencyCompetencyPage {
break;
default:
// We can use the current status name.
return status;
return String(status);
}
return this.translate.instant('addon.competency.usercompetencystatus_' + statusTranslateName);

View File

@ -15,9 +15,8 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreComponentsModule } from '../../../../components/components.module';
import { CoreDirectivesModule } from '../../../../directives/directives.module';
import { CorePipesModule } from '../../../../pipes/pipes.module';
import { CoreComponentsModule } from '@components/components.module';
import { CoreDirectivesModule } from '@directives/directives.module';
import { AddonCompetencyCompetencySummaryPage } from './competencysummary';
@NgModule({
@ -27,7 +26,6 @@ import { AddonCompetencyCompetencySummaryPage } from './competencysummary';
imports: [
CoreComponentsModule,
CoreDirectivesModule,
CorePipesModule,
IonicPageModule.forChild(AddonCompetencyCompetencySummaryPage),
TranslateModule.forChild()
],

View File

@ -15,8 +15,8 @@
import { Component, Optional } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { TranslateService } from '@ngx-translate/core';
import { CoreDomUtilsProvider } from '../../../../providers/utils/dom';
import { CoreSplitViewComponent } from '../../../../components/split-view/split-view';
import { CoreDomUtilsProvider } from '@providers/utils/dom';
import { CoreSplitViewComponent } from '@components/split-view/split-view';
import { AddonCompetencyProvider } from '../../providers/competency';
/**
@ -57,14 +57,8 @@ export class AddonCompetencyCompetencySummaryPage {
protected fetchCompetency(): Promise<void> {
return this.competencyProvider.getCompetencySummary(this.competencyId).then((competency) => {
this.competency = competency;
}, (message) => {
if (message) {
this.domUtils.showErrorModal(message);
} else {
this.domUtils.showErrorModal('Error getting competency summary data.');
}
return Promise.reject(null);
}).catch((message) => {
this.domUtils.showErrorModalDefault(message, 'Error getting competency summary data.');
});
}

View File

@ -15,9 +15,6 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreComponentsModule } from '../../../../components/components.module';
import { CoreDirectivesModule } from '../../../../directives/directives.module';
import { CorePipesModule } from '../../../../pipes/pipes.module';
import { AddonCompetencyComponentsModule } from '../../components/components.module';
import { AddonCompetencyCourseCompetenciesPage } from './coursecompetencies';
@ -26,9 +23,6 @@ import { AddonCompetencyCourseCompetenciesPage } from './coursecompetencies';
AddonCompetencyCourseCompetenciesPage,
],
imports: [
CoreComponentsModule,
CoreDirectivesModule,
CorePipesModule,
IonicPageModule.forChild(AddonCompetencyCourseCompetenciesPage),
TranslateModule.forChild(),
AddonCompetencyComponentsModule

View File

@ -12,13 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { Component, ViewChild } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { TranslateService } from '@ngx-translate/core';
import { CoreAppProvider } from '../../../../providers/app';
import { CoreDomUtilsProvider } from '../../../../providers/utils/dom';
import { AddonCompetencyProvider } from '../../providers/competency';
import { AddonCompetencyHelperProvider } from '../../providers/helper';
import { Component } from '@angular/core';
import { IonicPage, NavParams } from 'ionic-angular';
/**
* Page that displays the list of competencies of a course.
@ -33,9 +28,7 @@ export class AddonCompetencyCourseCompetenciesPage {
protected courseId: number;
protected userId: number;
constructor(private navCtrl: NavController, navParams: NavParams, private translate: TranslateService,
private appProvider: CoreAppProvider, private domUtils: CoreDomUtilsProvider,
private competencyProvider: AddonCompetencyProvider, private helperProvider: AddonCompetencyHelperProvider) {
constructor(navParams: NavParams) {
this.courseId = navParams.get('courseId');
this.userId = navParams.get('userId');
}

View File

@ -15,9 +15,9 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreComponentsModule } from '../../../../components/components.module';
import { CoreDirectivesModule } from '../../../../directives/directives.module';
import { CorePipesModule } from '../../../../pipes/pipes.module';
import { CoreComponentsModule } from '@components/components.module';
import { CoreDirectivesModule } from '@directives/directives.module';
import { CorePipesModule } from '@pipes/pipes.module';
import { AddonCompetencyPlanPage } from './plan';
@NgModule({

View File

@ -15,9 +15,9 @@
import { Component, Optional } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { TranslateService } from '@ngx-translate/core';
import { CoreAppProvider } from '../../../../providers/app';
import { CoreDomUtilsProvider } from '../../../../providers/utils/dom';
import { CoreSplitViewComponent } from '../../../../components/split-view/split-view';
import { CoreAppProvider } from '@providers/app';
import { CoreDomUtilsProvider } from '@providers/utils/dom';
import { CoreSplitViewComponent } from '@components/split-view/split-view';
import { AddonCompetencyProvider } from '../../providers/competency';
import { AddonCompetencyHelperProvider } from '../../providers/helper';
@ -64,14 +64,8 @@ export class AddonCompetencyPlanPage {
this.user = user;
});
this.plan = plan;
}, (message) => {
if (message) {
this.domUtils.showErrorModal(message);
} else {
this.domUtils.showErrorModal('Error getting learning plan data.');
}
return Promise.reject(null);
}).catch((message) => {
this.domUtils.showErrorModalDefault(message, 'Error getting learning plan data.');
});
}
@ -82,16 +76,20 @@ export class AddonCompetencyPlanPage {
*/
openCompetency(competencyId: number): void {
const navCtrl = this.svComponent ? this.svComponent.getMasterNav() : this.navCtrl;
navCtrl.push('AddonCompetencyCompetenciesPage', {competencyId, planId: this.planId});
if (this.appProvider.isWide()) {
navCtrl.push('AddonCompetencyCompetenciesPage', {competencyId, planId: this.planId});
} else {
navCtrl.push('AddonCompetencyCompetencyPage', {competencyId, planId: this.planId});
}
}
/**
* Convenience function to get the status name translated.
*
* @param {number} status
* @return {any}
* @return {string}
*/
protected getStatusName(status: number): any {
protected getStatusName(status: number): string {
let statusTranslateName;
switch (status) {
case AddonCompetencyProvider.STATUS_DRAFT:
@ -111,7 +109,7 @@ export class AddonCompetencyPlanPage {
break;
default:
// We can use the current status name.
return status;
return String(status);
}
return this.translate.instant('addon.competency.planstatus' + statusTranslateName);

View File

@ -9,7 +9,7 @@
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
</ion-refresher>
<core-loading [hideUntil]="plansLoaded">
<core-empty-box *ngIf="plans.length == 0" icon="mapr" [message]="'addon.competency.noplanswerecreated' | translate">
<core-empty-box *ngIf="plans.length == 0" icon="map" [message]="'addon.competency.noplanswerecreated' | translate">
</core-empty-box>
<ion-list *ngIf="plans.length > 0" no-margin>
<a ion-item text-wrap *ngFor="let plan of plans" [title]="plan.name" (click)="openPlan(plan.id)" [class.core-split-item-selected]="plan.id == planId">
@ -19,4 +19,4 @@
</ion-list>
</core-loading>
</ion-content>
</core-split-view>
</core-split-view>

View File

@ -15,9 +15,8 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreComponentsModule } from '../../../../components/components.module';
import { CoreDirectivesModule } from '../../../../directives/directives.module';
import { CorePipesModule } from '../../../../pipes/pipes.module';
import { CoreComponentsModule } from '@components/components.module';
import { CorePipesModule } from '@pipes/pipes.module';
import { AddonCompetencyPlanListPage } from './planlist';
@NgModule({
@ -26,7 +25,6 @@ import { AddonCompetencyPlanListPage } from './planlist';
],
imports: [
CoreComponentsModule,
CoreDirectivesModule,
CorePipesModule,
IonicPageModule.forChild(AddonCompetencyPlanListPage),
TranslateModule.forChild()

View File

@ -15,8 +15,8 @@
import { Component, ViewChild } from '@angular/core';
import { IonicPage, NavParams } from 'ionic-angular';
import { TranslateService } from '@ngx-translate/core';
import { CoreDomUtilsProvider } from '../../../../providers/utils/dom';
import { CoreSplitViewComponent } from '../../../../components/split-view/split-view';
import { CoreDomUtilsProvider } from '@providers/utils/dom';
import { CoreSplitViewComponent } from '@components/split-view/split-view';
import { AddonCompetencyProvider } from '../../providers/competency';
/**
@ -68,13 +68,7 @@ export class AddonCompetencyPlanListPage {
return this.competencyProvider.getLearningPlans(this.userId).then((plans) => {
this.plans = plans;
}).catch((message) => {
if (message) {
this.domUtils.showErrorModal(message);
} else {
this.domUtils.showErrorModal('Error getting learning plans data.');
}
return Promise.reject(null);
this.domUtils.showErrorModalDefault(message, 'Error getting learning plans data.');
});
}

View File

@ -13,9 +13,8 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { CoreLoggerProvider } from '../../../providers/logger';
import { CoreSitesProvider } from '../../../providers/sites';
import { CoreUserProvider } from '../../../core/user/providers/user';
import { CoreLoggerProvider } from '@providers/logger';
import { CoreSitesProvider } from '@providers/sites';
/**
* Service to handle caompetency learning plans.
@ -103,24 +102,6 @@ export class AddonCompetencyProvider {
return this.ROOT_CACHE_KEY + 'coursecompetencies:' + courseId;
}
/**
* Check if competency learning plans WS is available.
*
* @param {string} [siteId] Site ID. If not defined, current site.
* @return {Promise<boolean>} True if competency learning plans WS is available, false otherwise.
*/
isPluginEnabled(siteId?: string): Promise<boolean> {
siteId = siteId || this.sitesProvider.getCurrentSiteId();
return this.sitesProvider.getSite(siteId).then((site) => {
if (site.wsAvailable('core_competency_list_course_competencies') && site.wsAvailable('tool_lp_data_for_plans_page')) {
return this.getLearningPlans(0, siteId);
}
return false;
});
}
/**
* Returns whether competencies are enabled.
*
@ -133,10 +114,6 @@ export class AddonCompetencyProvider {
return Promise.resolve(false);
}
if (!this.isPluginEnabled(siteId)) {
return Promise.resolve(false);
}
return this.getCourseCompetencies(courseId, 0, siteId).catch(() => {
return false;
});
@ -150,8 +127,6 @@ export class AddonCompetencyProvider {
* @return {Promise<any>} Promise to be resolved when the plans are retrieved.
*/
getLearningPlans(userId?: number, siteId?: string): Promise<any> {
siteId = siteId || this.sitesProvider.getCurrentSiteId();
return this.sitesProvider.getSite(siteId).then((site) => {
userId = userId || site.getUserId();
@ -182,8 +157,6 @@ export class AddonCompetencyProvider {
* @return {Promise<any>} Promise to be resolved when the plans are retrieved.
*/
getLearningPlan(planId: number, siteId?: string): Promise<any> {
siteId = siteId || this.sitesProvider.getCurrentSiteId();
return this.sitesProvider.getSite(siteId).then((site) => {
this.logger.debug('Get plan ' + planId);
@ -214,8 +187,6 @@ export class AddonCompetencyProvider {
* @return {Promise<any>} Promise to be resolved when the plans are retrieved.
*/
getCompetencyInPlan(planId: number, competencyId: number, siteId?: string): Promise<any> {
siteId = siteId || this.sitesProvider.getCurrentSiteId();
return this.sitesProvider.getSite(siteId).then((site) => {
this.logger.debug('Get competency ' + competencyId + ' in plan ' + planId);
@ -248,8 +219,6 @@ export class AddonCompetencyProvider {
* @return {Promise<any>} Promise to be resolved when the plans are retrieved.
*/
getCompetencyInCourse(courseId: number, competencyId: number, userId?: number, siteId?: string): Promise<any> {
siteId = siteId || this.sitesProvider.getCurrentSiteId();
return this.sitesProvider.getSite(siteId).then((site) => {
userId = userId || site.getUserId();
@ -283,8 +252,6 @@ export class AddonCompetencyProvider {
* @return {Promise<any>} Promise to be resolved when the plans are retrieved.
*/
getCompetencySummary(competencyId: number, userId?: number, siteId?: string): Promise<any> {
siteId = siteId || this.sitesProvider.getCurrentSiteId();
return this.sitesProvider.getSite(siteId).then((site) => {
userId = userId || site.getUserId();
@ -309,7 +276,7 @@ export class AddonCompetencyProvider {
}
/**
* Get an specific competency summary.
* Get all competencies in a course.
*
* @param {number} courseId ID of the course.
* @param {number} [userId] ID of the user.
@ -317,8 +284,6 @@ export class AddonCompetencyProvider {
* @return {Promise<any>} Promise to be resolved when the course competencies are retrieved.
*/
getCourseCompetencies(courseId: number, userId?: number, siteId?: string): Promise<any> {
siteId = siteId || this.sitesProvider.getCurrentSiteId();
return this.sitesProvider.getSite(siteId).then((site) => {
this.logger.debug('Get course competencies for course ' + courseId);
@ -366,8 +331,6 @@ export class AddonCompetencyProvider {
* @return {Promise<any>} Promise resolved when the data is invalidated.
*/
invalidateLearningPlans(userId?: number, siteId?: string): Promise<any> {
siteId = siteId || this.sitesProvider.getCurrentSiteId();
return this.sitesProvider.getSite(siteId).then((site) => {
userId = userId || site.getUserId();
@ -383,8 +346,6 @@ export class AddonCompetencyProvider {
* @return {Promise<any>} Promise resolved when the data is invalidated.
*/
invalidateLearningPlan(planId: number, siteId?: string): Promise<any> {
siteId = siteId || this.sitesProvider.getCurrentSiteId();
return this.sitesProvider.getSite(siteId).then((site) => {
return site.invalidateWsCacheForKey(this.getLearningPlanCacheKey(planId));
});
@ -399,8 +360,6 @@ export class AddonCompetencyProvider {
* @return {Promise<any>} Promise resolved when the data is invalidated.
*/
invalidateCompetencyInPlan(planId: number, competencyId: number, siteId?: string): Promise<any> {
siteId = siteId || this.sitesProvider.getCurrentSiteId();
return this.sitesProvider.getSite(siteId).then((site) => {
return site.invalidateWsCacheForKey(this.getCompetencyInPlanCacheKey(planId, competencyId));
});
@ -416,8 +375,6 @@ export class AddonCompetencyProvider {
* @return {Promise<any>} Promise resolved when the data is invalidated.
*/
invalidateCompetencyInCourse(courseId: number, competencyId: number, userId?: number, siteId?: string): Promise<any> {
siteId = siteId || this.sitesProvider.getCurrentSiteId();
return this.sitesProvider.getSite(siteId).then((site) => {
userId = userId || site.getUserId();
@ -434,8 +391,6 @@ export class AddonCompetencyProvider {
* @return {Promise<any>} Promise resolved when the data is invalidated.
*/
invalidateCompetencySummary(competencyId: number, userId?: number, siteId?: string): Promise<any> {
siteId = siteId || this.sitesProvider.getCurrentSiteId();
return this.sitesProvider.getSite(siteId).then((site) => {
userId = userId || site.getUserId();
@ -452,11 +407,9 @@ export class AddonCompetencyProvider {
* @return {Promise<any>} Promise resolved when the data is invalidated.
*/
invalidateCourseCompetencies(courseId: number, userId?: number, siteId?: string): Promise<any> {
siteId = siteId || this.sitesProvider.getCurrentSiteId();
return this.sitesProvider.getSite(siteId).then((site) => {
return site.invalidateWsCacheForKey(this.getCourseCompetenciesCacheKey(courseId));
}).then((response) => {
}).then(() => {
if (!userId || userId == this.sitesProvider.getCurrentSiteUserId()) {
return;
}
@ -487,8 +440,6 @@ export class AddonCompetencyProvider {
logCompetencyInPlanView(planId: number, competencyId: number, planStatus: number, userId?: number, siteId?: string)
: Promise<any> {
if (planId && competencyId) {
siteId = siteId || this.sitesProvider.getCurrentSiteId();
return this.sitesProvider.getSite(siteId).then((site) => {
userId = userId || site.getUserId();
@ -498,7 +449,7 @@ export class AddonCompetencyProvider {
userid: userId
},
preSets = {
typeExpected: 'boolean'
typeExpected: 'boolean'
};
if (planStatus == AddonCompetencyProvider.STATUS_COMPLETE) {
@ -523,8 +474,6 @@ export class AddonCompetencyProvider {
*/
logCompetencyInCourseView(courseId: number, competencyId: number, userId?: number, siteId?: string): Promise<any> {
if (courseId && competencyId) {
siteId = siteId || this.sitesProvider.getCurrentSiteId();
return this.sitesProvider.getSite(siteId).then((site) => {
userId = userId || site.getUserId();
@ -553,8 +502,6 @@ export class AddonCompetencyProvider {
*/
logCompetencyView(competencyId: number, siteId?: string): Promise<any> {
if (competencyId) {
siteId = siteId || this.sitesProvider.getCurrentSiteId();
return this.sitesProvider.getSite(siteId).then((site) => {
const params = {
id: competencyId,

View File

@ -12,10 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { Injectable } from '@angular/core';
import { NavController } from 'ionic-angular';
import { CoreCourseOptionsHandler, CoreCourseOptionsHandlerData } from '../../../core/course/providers/options-delegate';
import { CoreCourseProvider } from '../../../core/course/providers/course';
import { Injectable, Injector } from '@angular/core';
import { CoreCourseOptionsHandler, CoreCourseOptionsHandlerData } from '@core/course/providers/options-delegate';
import { CoreCourseProvider } from '@core/course/providers/course';
import { AddonCompetencyCourseComponent } from '../components/course/course';
import { AddonCompetencyProvider } from '../providers/competency';
@ -43,7 +42,7 @@ export class AddonCompetencyCourseOptionHandler implements CoreCourseOptionsHand
* @return {boolean|Promise<boolean>} Whether or not the handler is enabled on a site level.
*/
isEnabled(): boolean | Promise<boolean> {
return this.competencyProvider.isPluginEnabled();
return true;
}
/**
@ -79,10 +78,11 @@ export class AddonCompetencyCourseOptionHandler implements CoreCourseOptionsHand
/**
* Returns the data needed to render the handler.
*
* @param {Injector} injector Injector.
* @param {number} courseId The course ID.
* @return {CoreCourseOptionsHandlerData} Data.
* @return {CoreCourseOptionsHandlerData|Promise<CoreCourseOptionsHandlerData>} Data or promise resolved with the data.
*/
getDisplayData(courseId: number): CoreCourseOptionsHandlerData {
getDisplayData?(injector: Injector, courseId: number): CoreCourseOptionsHandlerData | Promise<CoreCourseOptionsHandlerData> {
return {
title: 'addon.competency.competencies',
class: 'addon-competency-course-handler',

View File

@ -13,11 +13,11 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { CoreSitesProvider } from '../../../providers/sites';
import { CoreUserProvider } from '../../../core/user/providers/user';
import { CoreSitesProvider } from '@providers/sites';
import { CoreUserProvider } from '@core/user/providers/user';
/**
* Service that provides some features regarding the user profile.
* Service that provides some features regarding learning plans.
*/
@Injectable()
export class AddonCompetencyHelperProvider {

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { AddonCompetencyProvider } from './competency';
import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '../../../core/mainmenu/providers/delegate';
import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '@core/mainmenu/providers/delegate';
/**
* Handler to inject an option into main menu.
@ -22,7 +22,7 @@ import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '../../../core/main
@Injectable()
export class AddonCompetencyMainMenuHandler implements CoreMainMenuHandler {
name = 'AddonCompetency';
priority = 900;
priority = 500;
constructor(private competencyProvider: AddonCompetencyProvider) { }
@ -32,15 +32,9 @@ export class AddonCompetencyMainMenuHandler implements CoreMainMenuHandler {
* @return {boolean} Whether or not the handler is enabled on a site level.
*/
isEnabled(): boolean | Promise<boolean> {
return this.competencyProvider.isPluginEnabled().then((enabled) => {
if (!enabled) {
return false;
}
// Check the user has at least one learn plan available.
return this.competencyProvider.getLearningPlans().then((plans) => {
return plans.length > 0;
});
// Check the user has at least one learn plan available.
return this.competencyProvider.getLearningPlans().then((plans) => {
return plans.length > 0;
});
}

View File

@ -13,9 +13,9 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { CoreUserDelegate, CoreUserProfileHandler, CoreUserProfileHandlerData } from '../../../core/user/providers/user-delegate';
import { CoreSitesProvider } from '../../../providers/sites';
import { CoreContentLinksHelperProvider } from '../../../core/contentlinks/providers/helper';
import { CoreUserDelegate, CoreUserProfileHandler, CoreUserProfileHandlerData } from '@core/user/providers/user-delegate';
import { CoreSitesProvider } from '@providers/sites';
import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper';
import { AddonCompetencyProvider } from './competency';
/**
@ -46,7 +46,7 @@ export class AddonCompetencyUserHandler implements CoreUserProfileHandler {
* @return {boolean|Promise<boolean>} Whether or not the handler is enabled on a site level.
*/
isEnabled(): boolean | Promise<boolean> {
return this.competencyProvider.isPluginEnabled();
return true;
}
/**
@ -104,7 +104,7 @@ export class AddonCompetencyUserHandler implements CoreUserProfileHandler {
icon: 'ribbon',
title: 'addon.competency.competencies',
class: 'addon-competency-handler',
action: ($event, navCtrl, user, courseId): void => {
action: (event, navCtrl, user, courseId): void => {
event.preventDefault();
event.stopPropagation();
// Always use redirect to make it the new history root (to avoid "loops" in history).
@ -116,7 +116,7 @@ export class AddonCompetencyUserHandler implements CoreUserProfileHandler {
icon: 'map',
title: 'addon.competency.learningplans',
class: 'addon-competency-handler',
action: ($event, navCtrl, user, courseId): void => {
action: (event, navCtrl, user, courseId): void => {
event.preventDefault();
event.stopPropagation();
// Always use redirect to make it the new history root (to avoid "loops" in history).