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", "lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build", "ionic:build": "ionic-app-scripts build",
"ionic:serve": "gulp watch | ionic-app-scripts serve", "ionic:serve": "gulp watch | ionic-app-scripts serve",
"ionic:build:before": "gulp" "ionic:build:before": "gulp",
"ionic:watch:before": "gulp"
}, },
"dependencies": { "dependencies": {
"@angular/animations": "^5.2.5", "@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 { AddonCompetencyMainMenuHandler } from './providers/mainmenu-handler';
import { AddonCompetencyUserHandler } from './providers/user-handler'; import { AddonCompetencyUserHandler } from './providers/user-handler';
import { AddonCompetencyComponentsModule } from './components/components.module'; import { AddonCompetencyComponentsModule } from './components/components.module';
import { CoreCourseProvider } from '../../core/course/providers/course'; import { CoreCourseOptionsDelegate } from '@core/course/providers/options-delegate';
import { CoreCourseOptionsDelegate } from '../../core/course/providers/options-delegate'; import { CoreMainMenuDelegate } from '@core/mainmenu/providers/delegate';
import { CoreMainMenuDelegate } from '../../core/mainmenu/providers/delegate'; import { CoreUserDelegate } from '@core/user/providers/user-delegate';
import { CoreUserDelegate } from '../../core/user/providers/user-delegate'; import { CoreUserProvider } from '@core/user/providers/user';
import { CoreUserProvider } from '../../core/user/providers/user'; import { CoreEventsProvider } from '@providers/events';
import { CoreEventsProvider } from '../../providers/events'; import { CoreSitesProvider } from '@providers/sites';
import { CoreSitesProvider } from '../../providers/sites'; import { CoreCoursesProvider } from '@core/courses/providers/courses';
import { CoreCoursesProvider } from '../../core/courses/providers/courses';
@NgModule({ @NgModule({
declarations: [ declarations: [

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -15,9 +15,9 @@
import { Component, Optional } from '@angular/core'; import { Component, Optional } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular'; import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { CoreAppProvider } from '../../../../providers/app'; import { CoreAppProvider } from '@providers/app';
import { CoreDomUtilsProvider } from '../../../../providers/utils/dom'; import { CoreDomUtilsProvider } from '@providers/utils/dom';
import { CoreSplitViewComponent } from '../../../../components/split-view/split-view'; import { CoreSplitViewComponent } from '@components/split-view/split-view';
import { AddonCompetencyProvider } from '../../providers/competency'; import { AddonCompetencyProvider } from '../../providers/competency';
import { AddonCompetencyHelperProvider } from '../../providers/helper'; import { AddonCompetencyHelperProvider } from '../../providers/helper';
@ -64,14 +64,8 @@ export class AddonCompetencyPlanPage {
this.user = user; this.user = user;
}); });
this.plan = plan; this.plan = plan;
}, (message) => { }).catch((message) => {
if (message) { this.domUtils.showErrorModalDefault(message, 'Error getting learning plan data.');
this.domUtils.showErrorModal(message);
} else {
this.domUtils.showErrorModal('Error getting learning plan data.');
}
return Promise.reject(null);
}); });
} }
@ -82,16 +76,20 @@ export class AddonCompetencyPlanPage {
*/ */
openCompetency(competencyId: number): void { openCompetency(competencyId: number): void {
const navCtrl = this.svComponent ? this.svComponent.getMasterNav() : this.navCtrl; 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. * Convenience function to get the status name translated.
* *
* @param {number} status * @param {number} status
* @return {any} * @return {string}
*/ */
protected getStatusName(status: number): any { protected getStatusName(status: number): string {
let statusTranslateName; let statusTranslateName;
switch (status) { switch (status) {
case AddonCompetencyProvider.STATUS_DRAFT: case AddonCompetencyProvider.STATUS_DRAFT:
@ -111,7 +109,7 @@ export class AddonCompetencyPlanPage {
break; break;
default: default:
// We can use the current status name. // We can use the current status name.
return status; return String(status);
} }
return this.translate.instant('addon.competency.planstatus' + statusTranslateName); 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-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
</ion-refresher> </ion-refresher>
<core-loading [hideUntil]="plansLoaded"> <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> </core-empty-box>
<ion-list *ngIf="plans.length > 0" no-margin> <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"> <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">

View File

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

View File

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

View File

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

View File

@ -12,10 +12,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { Injectable } from '@angular/core'; import { Injectable, Injector } from '@angular/core';
import { NavController } from 'ionic-angular'; import { CoreCourseOptionsHandler, CoreCourseOptionsHandlerData } from '@core/course/providers/options-delegate';
import { CoreCourseOptionsHandler, CoreCourseOptionsHandlerData } from '../../../core/course/providers/options-delegate'; import { CoreCourseProvider } from '@core/course/providers/course';
import { CoreCourseProvider } from '../../../core/course/providers/course';
import { AddonCompetencyCourseComponent } from '../components/course/course'; import { AddonCompetencyCourseComponent } from '../components/course/course';
import { AddonCompetencyProvider } from '../providers/competency'; 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. * @return {boolean|Promise<boolean>} Whether or not the handler is enabled on a site level.
*/ */
isEnabled(): boolean | Promise<boolean> { 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. * Returns the data needed to render the handler.
* *
* @param {Injector} injector Injector.
* @param {number} courseId The course ID. * @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 { return {
title: 'addon.competency.competencies', title: 'addon.competency.competencies',
class: 'addon-competency-course-handler', class: 'addon-competency-course-handler',

View File

@ -13,11 +13,11 @@
// limitations under the License. // limitations under the License.
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreSitesProvider } from '../../../providers/sites'; import { CoreSitesProvider } from '@providers/sites';
import { CoreUserProvider } from '../../../core/user/providers/user'; 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() @Injectable()
export class AddonCompetencyHelperProvider { export class AddonCompetencyHelperProvider {

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AddonCompetencyProvider } from './competency'; 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. * Handler to inject an option into main menu.
@ -22,7 +22,7 @@ import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '../../../core/main
@Injectable() @Injectable()
export class AddonCompetencyMainMenuHandler implements CoreMainMenuHandler { export class AddonCompetencyMainMenuHandler implements CoreMainMenuHandler {
name = 'AddonCompetency'; name = 'AddonCompetency';
priority = 900; priority = 500;
constructor(private competencyProvider: AddonCompetencyProvider) { } 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. * @return {boolean} Whether or not the handler is enabled on a site level.
*/ */
isEnabled(): boolean | Promise<boolean> { isEnabled(): boolean | Promise<boolean> {
return this.competencyProvider.isPluginEnabled().then((enabled) => { // Check the user has at least one learn plan available.
if (!enabled) { return this.competencyProvider.getLearningPlans().then((plans) => {
return false; 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. // limitations under the License.
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreUserDelegate, CoreUserProfileHandler, CoreUserProfileHandlerData } from '../../../core/user/providers/user-delegate'; import { CoreUserDelegate, CoreUserProfileHandler, CoreUserProfileHandlerData } from '@core/user/providers/user-delegate';
import { CoreSitesProvider } from '../../../providers/sites'; import { CoreSitesProvider } from '@providers/sites';
import { CoreContentLinksHelperProvider } from '../../../core/contentlinks/providers/helper'; import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper';
import { AddonCompetencyProvider } from './competency'; 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. * @return {boolean|Promise<boolean>} Whether or not the handler is enabled on a site level.
*/ */
isEnabled(): boolean | Promise<boolean> { isEnabled(): boolean | Promise<boolean> {
return this.competencyProvider.isPluginEnabled(); return true;
} }
/** /**
@ -104,7 +104,7 @@ export class AddonCompetencyUserHandler implements CoreUserProfileHandler {
icon: 'ribbon', icon: 'ribbon',
title: 'addon.competency.competencies', title: 'addon.competency.competencies',
class: 'addon-competency-handler', class: 'addon-competency-handler',
action: ($event, navCtrl, user, courseId): void => { action: (event, navCtrl, user, courseId): void => {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
// Always use redirect to make it the new history root (to avoid "loops" in history). // 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', icon: 'map',
title: 'addon.competency.learningplans', title: 'addon.competency.learningplans',
class: 'addon-competency-handler', class: 'addon-competency-handler',
action: ($event, navCtrl, user, courseId): void => { action: (event, navCtrl, user, courseId): void => {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
// Always use redirect to make it the new history root (to avoid "loops" in history). // Always use redirect to make it the new history root (to avoid "loops" in history).