forked from CIT/Vmeda.Online
		
	MOBILE-3578 competency: Fix multiple requests when view user profile
This commit is contained in:
		
							parent
							
								
									e8830eedaf
								
							
						
					
					
						commit
						8689ae76f6
					
				@ -18,11 +18,11 @@ import { RouterModule, Routes } from '@angular/router';
 | 
			
		||||
import { conditionalRoutes } from '@/app/app-routing.module';
 | 
			
		||||
import { CoreScreen } from '@services/screen';
 | 
			
		||||
import { CoreSharedModule } from '@/core/shared.module';
 | 
			
		||||
import { AddonCompetencyPlanPage } from './pages/plan/plan.page';
 | 
			
		||||
import { AddonCompetencyPlanListPage } from './pages/planlist/planlist.page';
 | 
			
		||||
import { AddonCompetencyCompetenciesPage } from './pages/competencies/competencies.page';
 | 
			
		||||
import { AddonCompetencyCompetencyPage } from './pages/competency/competency.page';
 | 
			
		||||
import { AddonCompetencyCompetencySummaryPage } from './pages/competencysummary/competencysummary.page';
 | 
			
		||||
import { AddonCompetencyPlanPage } from './pages/plan/plan';
 | 
			
		||||
import { AddonCompetencyPlanListPage } from './pages/planlist/planlist';
 | 
			
		||||
import { AddonCompetencyCompetenciesPage } from './pages/competencies/competencies';
 | 
			
		||||
import { AddonCompetencyCompetencyPage } from './pages/competency/competency';
 | 
			
		||||
import { AddonCompetencyCompetencySummaryPage } from './pages/competencysummary/competencysummary';
 | 
			
		||||
import { AddonCompetencyCourseCompetenciesPage } from './pages/coursecompetencies/coursecompetencies.page';
 | 
			
		||||
import { AddonCompetencyCourseCompetenciesPageModule } from './pages/coursecompetencies/coursecompetencies.module';
 | 
			
		||||
 | 
			
		||||
@ -33,7 +33,7 @@ const mobileRoutes: Routes = [
 | 
			
		||||
        component: AddonCompetencyPlanListPage,
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        path: 'competencies/',
 | 
			
		||||
        path: 'competencies',
 | 
			
		||||
        component: AddonCompetencyCompetenciesPage,
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
@ -91,8 +91,8 @@ export class AddonCompetencyCompetenciesPage implements AfterViewInit, OnDestroy
 | 
			
		||||
            } else {
 | 
			
		||||
                throw null;
 | 
			
		||||
            }
 | 
			
		||||
        } catch (message) {
 | 
			
		||||
            CoreDomUtils.showErrorModalDefault(message, 'Error getting competencies data.');
 | 
			
		||||
        } catch (error) {
 | 
			
		||||
            CoreDomUtils.showErrorModalDefault(error, 'Error getting competencies data.');
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -4,7 +4,7 @@
 | 
			
		||||
            <ion-back-button [attr.aria-label]="'core.back' | translate"></ion-back-button>
 | 
			
		||||
        </ion-buttons>
 | 
			
		||||
        <ion-title *ngIf="competency">
 | 
			
		||||
            {{ competency!.competency.competency.shortname }} <small>{{ competency.competency.competency.idnumber }}</small>
 | 
			
		||||
            {{ competency.competency.competency.shortname }} <small>{{ competency.competency.competency.idnumber }}</small>
 | 
			
		||||
        </ion-title>
 | 
			
		||||
    </ion-toolbar>
 | 
			
		||||
</ion-header>
 | 
			
		||||
@ -16,14 +16,14 @@
 | 
			
		||||
        <ion-card *ngIf="user">
 | 
			
		||||
            <ion-item class="ion-text-wrap">
 | 
			
		||||
                <core-user-avatar [user]="user" slot="start"></core-user-avatar>
 | 
			
		||||
                <ion-label><h2>{{ user!.fullname }}</h2></ion-label>
 | 
			
		||||
                <ion-label><h2>{{ user.fullname }}</h2></ion-label>
 | 
			
		||||
            </ion-item>
 | 
			
		||||
        </ion-card>
 | 
			
		||||
 | 
			
		||||
        <ion-card *ngIf="competency">
 | 
			
		||||
            <ion-item class="ion-text-wrap" *ngIf="competency!.competency.competency.description">
 | 
			
		||||
            <ion-item class="ion-text-wrap" *ngIf="competency.competency.competency.description">
 | 
			
		||||
                <ion-label>
 | 
			
		||||
                    <core-format-text [text]="competency!.competency.competency.description" [contextLevel]="contextLevel"
 | 
			
		||||
                    <core-format-text [text]="competency.competency.competency.description" [contextLevel]="contextLevel"
 | 
			
		||||
                        [contextInstanceId]="contextInstanceId">
 | 
			
		||||
                    </core-format-text>
 | 
			
		||||
                </ion-label>
 | 
			
		||||
@ -31,23 +31,23 @@
 | 
			
		||||
            <ion-item class="ion-text-wrap">
 | 
			
		||||
                <ion-label>
 | 
			
		||||
                    <strong>{{ 'addon.competency.path' | translate }}</strong>
 | 
			
		||||
                    <a *ngIf="competency!.competency.comppath.showlinks"
 | 
			
		||||
                        [href]="competency!.competency.comppath.pluginbaseurl + '/competencies.php?competencyframeworkid=' +
 | 
			
		||||
                        competency!.competency.comppath.framework.id + '&pagecontextid=' +
 | 
			
		||||
                        competency!.competency.comppath.pagecontextid"
 | 
			
		||||
                        core-link [title]="competency!.competency.comppath.framework.name">
 | 
			
		||||
                        {{ competency!.competency.comppath.framework.name }}
 | 
			
		||||
                    <a *ngIf="competency.competency.comppath.showlinks"
 | 
			
		||||
                        [href]="competency.competency.comppath.pluginbaseurl + '/competencies.php?competencyframeworkid=' +
 | 
			
		||||
                        competency.competency.comppath.framework.id + '&pagecontextid=' +
 | 
			
		||||
                        competency.competency.comppath.pagecontextid"
 | 
			
		||||
                        core-link [title]="competency.competency.comppath.framework.name">
 | 
			
		||||
                        {{ competency.competency.comppath.framework.name }}
 | 
			
		||||
                    </a>
 | 
			
		||||
                    <ng-container *ngIf="!competency!.competency.comppath.showlinks">
 | 
			
		||||
                        {{ competency!.competency.comppath.framework.name }}
 | 
			
		||||
                    <ng-container *ngIf="!competency.competency.comppath.showlinks">
 | 
			
		||||
                        {{ competency.competency.comppath.framework.name }}
 | 
			
		||||
                    </ng-container>
 | 
			
		||||
                     / 
 | 
			
		||||
                    <span *ngFor="let ancestor of competency!.competency.comppath.ancestors">
 | 
			
		||||
                        <a *ngIf="competency!.competency.comppath.showlinks" (click)="openCompetencySummary(ancestor.id)"
 | 
			
		||||
                    <span *ngFor="let ancestor of competency.competency.comppath.ancestors">
 | 
			
		||||
                        <a *ngIf="competency.competency.comppath.showlinks" (click)="openCompetencySummary(ancestor.id)"
 | 
			
		||||
                            class="core-clickable">
 | 
			
		||||
                            {{ ancestor.name }}
 | 
			
		||||
                        </a>
 | 
			
		||||
                        <ng-container *ngIf="!competency!.competency.comppath.showlinks">{{ ancestor.name }}</ng-container>
 | 
			
		||||
                        <ng-container *ngIf="!competency.competency.comppath.showlinks">{{ ancestor.name }}</ng-container>
 | 
			
		||||
                        <ng-container *ngIf="!ancestor.last"> / </ng-container>
 | 
			
		||||
                    </span>
 | 
			
		||||
                </ion-label>
 | 
			
		||||
@ -55,11 +55,11 @@
 | 
			
		||||
            <ion-item class="ion-text-wrap">
 | 
			
		||||
                <ion-label>
 | 
			
		||||
                    <strong>{{ 'addon.competency.crossreferencedcompetencies' | translate }}</strong>:
 | 
			
		||||
                    <div *ngIf="!competency!.competency.hasrelatedcompetencies">
 | 
			
		||||
                    <div *ngIf="!competency.competency.hasrelatedcompetencies">
 | 
			
		||||
                        {{ 'addon.competency.nocrossreferencedcompetencies' | translate }}
 | 
			
		||||
                    </div>
 | 
			
		||||
                    <div *ngIf="competency!.competency.hasrelatedcompetencies">
 | 
			
		||||
                        <p *ngFor="let relatedcomp of competency!.competency.relatedcompetencies">
 | 
			
		||||
                    <div *ngIf="competency.competency.hasrelatedcompetencies">
 | 
			
		||||
                        <p *ngFor="let relatedcomp of competency.competency.relatedcompetencies">
 | 
			
		||||
                            <a (click)="openCompetencySummary(relatedcomp.id)" class="core-clickable">
 | 
			
		||||
                                {{ relatedcomp.shortname }} - {{ relatedcomp.idnumber }}
 | 
			
		||||
                            </a>
 | 
			
		||||
@ -70,7 +70,7 @@
 | 
			
		||||
            <ion-item class="ion-text-wrap" *ngIf="coursemodules">
 | 
			
		||||
                <ion-label>
 | 
			
		||||
                    <strong>{{ 'addon.competency.activities' | translate }}</strong>
 | 
			
		||||
                    <p *ngIf="coursemodules!.length == 0">
 | 
			
		||||
                    <p *ngIf="coursemodules.length == 0">
 | 
			
		||||
                        {{ 'addon.competency.noactivities' | translate }}
 | 
			
		||||
                    </p>
 | 
			
		||||
                    <ion-item class="ion-text-wrap" *ngFor="let activity of coursemodules" [href]="activity.url" [title]="activity.name"
 | 
			
		||||
@ -86,20 +86,20 @@
 | 
			
		||||
                </ion-label>
 | 
			
		||||
            </ion-item>
 | 
			
		||||
            <ng-container *ngIf="userCompetency">
 | 
			
		||||
                <ion-item class="ion-text-wrap" *ngIf="competency!.usercompetency && competency!.usercompetency!.status">
 | 
			
		||||
                <ion-item class="ion-text-wrap" *ngIf="competency.usercompetency && competency.usercompetency!.status">
 | 
			
		||||
                    <ion-label>
 | 
			
		||||
                        <strong>{{ 'addon.competency.reviewstatus' | translate }}</strong>
 | 
			
		||||
                        {{ competency!.usercompetency!.statusname }}
 | 
			
		||||
                        {{ competency.usercompetency!.statusname }}
 | 
			
		||||
                    </ion-label>
 | 
			
		||||
                </ion-item>
 | 
			
		||||
                <ion-item class="ion-text-wrap">
 | 
			
		||||
                    <ion-label>
 | 
			
		||||
                        <strong>{{ 'addon.competency.proficient' | translate }}</strong>
 | 
			
		||||
                    </ion-label>
 | 
			
		||||
                    <ion-badge slot="end" color="success" *ngIf="userCompetency!.proficiency">
 | 
			
		||||
                    <ion-badge slot="end" color="success" *ngIf="userCompetency.proficiency">
 | 
			
		||||
                        {{ 'core.yes' | translate }}
 | 
			
		||||
                    </ion-badge>
 | 
			
		||||
                    <ion-badge  slot="end" color="danger" *ngIf="!userCompetency!.proficiency">
 | 
			
		||||
                    <ion-badge  slot="end" color="danger" *ngIf="!userCompetency.proficiency">
 | 
			
		||||
                        {{ 'core.no' | translate }}
 | 
			
		||||
                    </ion-badge>
 | 
			
		||||
                </ion-item>
 | 
			
		||||
@ -107,22 +107,22 @@
 | 
			
		||||
                    <ion-label>
 | 
			
		||||
                        <strong>{{ 'addon.competency.rating' | translate }}</strong>
 | 
			
		||||
                    </ion-label>
 | 
			
		||||
                    <ion-badge color="dark" slot="end">{{ userCompetency!.gradename }}</ion-badge>
 | 
			
		||||
                    <ion-badge color="dark" slot="end">{{ userCompetency.gradename }}</ion-badge>
 | 
			
		||||
                </ion-item>
 | 
			
		||||
            </ng-container>
 | 
			
		||||
        </ion-card>
 | 
			
		||||
 | 
			
		||||
        <div *ngIf="competency">
 | 
			
		||||
            <h3  class="ion-margin-horizontal">{{ 'addon.competency.evidence' | translate }}</h3>
 | 
			
		||||
            <p  class="ion-margin-horizontal" *ngIf="competency!.evidence.length == 0">
 | 
			
		||||
            <p  class="ion-margin-horizontal" *ngIf="competency.evidence.length == 0">
 | 
			
		||||
                {{ 'addon.competency.noevidence' | translate }}
 | 
			
		||||
            </p>
 | 
			
		||||
            <ion-card *ngFor="let evidence of competency!.evidence">
 | 
			
		||||
                <ion-item class="ion-text-wrap" *ngIf="evidence.actionuser" core-user-link [userId]="evidence.actionuser!.id"
 | 
			
		||||
            <ion-card *ngFor="let evidence of competency.evidence">
 | 
			
		||||
                <ion-item class="ion-text-wrap" *ngIf="evidence.actionuser" core-user-link [userId]="evidence.actionuser.id"
 | 
			
		||||
                    [courseId]="courseId">
 | 
			
		||||
                    <core-user-avatar [user]="evidence.actionuser" slot="start"></core-user-avatar>
 | 
			
		||||
                    <ion-label>
 | 
			
		||||
                        <h2>{{ evidence.actionuser!.fullname }}</h2>
 | 
			
		||||
                        <h2>{{ evidence.actionuser.fullname }}</h2>
 | 
			
		||||
                        <p>{{ evidence.timemodified * 1000 | coreFormatDate }}</p>
 | 
			
		||||
                    </ion-label>
 | 
			
		||||
                </ion-item>
 | 
			
		||||
 | 
			
		||||
@ -35,7 +35,7 @@ import { CoreUtils } from '@services/utils/utils';
 | 
			
		||||
import { AddonCompetencyMainMenuHandlerService } from '@addons/competency/services/handlers/mainmenu';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Page that displays a learning plan.
 | 
			
		||||
 * Page that displays the competency information.
 | 
			
		||||
 */
 | 
			
		||||
@Component({
 | 
			
		||||
    selector: 'page-addon-competency-competency',
 | 
			
		||||
@ -4,7 +4,7 @@
 | 
			
		||||
            <ion-back-button [attr.aria-label]="'core.back' | translate"></ion-back-button>
 | 
			
		||||
        </ion-buttons>
 | 
			
		||||
        <ion-title *ngIf="competency">
 | 
			
		||||
            {{ competency!.competency.shortname }} <small>{{ competency!.competency.idnumber }}</small>
 | 
			
		||||
            {{ competency.competency.shortname }} <small>{{ competency.competency.idnumber }}</small>
 | 
			
		||||
        </ion-title>
 | 
			
		||||
    </ion-toolbar>
 | 
			
		||||
</ion-header>
 | 
			
		||||
@ -14,9 +14,9 @@
 | 
			
		||||
    </ion-refresher>
 | 
			
		||||
    <core-loading [hideUntil]="competencyLoaded">
 | 
			
		||||
        <ion-card *ngIf="competency">
 | 
			
		||||
            <ion-item class="ion-text-wrap" *ngIf="competency!.competency.description">
 | 
			
		||||
            <ion-item class="ion-text-wrap" *ngIf="competency.competency.description">
 | 
			
		||||
                <ion-label>
 | 
			
		||||
                    <core-format-text [text]="competency!.competency.description" [contextLevel]="contextLevel"
 | 
			
		||||
                    <core-format-text [text]="competency.competency.description" [contextLevel]="contextLevel"
 | 
			
		||||
                        [contextInstanceId]="contextInstanceId">
 | 
			
		||||
                    </core-format-text>
 | 
			
		||||
                </ion-label>
 | 
			
		||||
@ -24,8 +24,8 @@
 | 
			
		||||
            <ion-item class="ion-text-wrap">
 | 
			
		||||
                <ion-label>
 | 
			
		||||
                    <strong>{{ 'addon.competency.path' | translate }}</strong>
 | 
			
		||||
                    {{ competency!.comppath.framework.name }}
 | 
			
		||||
                    <span *ngFor="let ancestor of competency!.comppath.ancestors">
 | 
			
		||||
                    {{ competency.comppath.framework.name }}
 | 
			
		||||
                    <span *ngFor="let ancestor of competency.comppath.ancestors">
 | 
			
		||||
                         / <a (click)="openCompetencySummary(ancestor.id)">{{ ancestor.name }}</a>
 | 
			
		||||
                    </span>
 | 
			
		||||
                </ion-label>
 | 
			
		||||
 | 
			
		||||
@ -22,7 +22,7 @@ import { CoreUtils } from '@services/utils/utils';
 | 
			
		||||
import { AddonCompetencyMainMenuHandlerService } from '@addons/competency/services/handlers/mainmenu';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Page that displays a learning plan.
 | 
			
		||||
 * Page that displays the competency summary.
 | 
			
		||||
 */
 | 
			
		||||
@Component({
 | 
			
		||||
    selector: 'page-addon-competency-competency-summary',
 | 
			
		||||
@ -11,27 +11,27 @@
 | 
			
		||||
        <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
 | 
			
		||||
    </ion-refresher>
 | 
			
		||||
    <core-loading [hideUntil]="competenciesLoaded">
 | 
			
		||||
        <ion-card *ngIf="!user && competencies && competencies!.statistics.competencycount > 0">
 | 
			
		||||
            <ng-container *ngIf="competencies!.cangradecompetencies">
 | 
			
		||||
                <ion-item class="ion-text-wrap" *ngIf="competencies!.settings.pushratingstouserplans">
 | 
			
		||||
        <ion-card *ngIf="!user && competencies && competencies.statistics.competencycount > 0">
 | 
			
		||||
            <ng-container *ngIf="competencies.cangradecompetencies">
 | 
			
		||||
                <ion-item class="ion-text-wrap" *ngIf="competencies.settings.pushratingstouserplans">
 | 
			
		||||
                    <ion-label>{{ 'addon.competency.coursecompetencyratingsarepushedtouserplans' | translate }}</ion-label>
 | 
			
		||||
                </ion-item>
 | 
			
		||||
                <ion-item class="ion-text-wrap" *ngIf="!competencies!.settings.pushratingstouserplans" color="danger">
 | 
			
		||||
                <ion-item class="ion-text-wrap" *ngIf="!competencies.settings.pushratingstouserplans" color="danger">
 | 
			
		||||
                    <ion-label>{{ 'addon.competency.coursecompetencyratingsarenotpushedtouserplans' | translate }}</ion-label>
 | 
			
		||||
                </ion-item>
 | 
			
		||||
            </ng-container>
 | 
			
		||||
            <ion-item class="ion-text-wrap" *ngIf="competencies!.statistics.canbegradedincourse">
 | 
			
		||||
            <ion-item class="ion-text-wrap" *ngIf="competencies.statistics.canbegradedincourse">
 | 
			
		||||
                <ion-label>
 | 
			
		||||
                    {{ 'addon.competency.xcompetenciesproficientoutofyincourse' | translate: {$a:
 | 
			
		||||
                        {x: competencies!.statistics.proficientcompetencycount, y: competencies!.statistics.competencycount} } }}
 | 
			
		||||
                    <core-progress-bar [progress]="competencies!.statistics.proficientcompetencypercentage"></core-progress-bar>
 | 
			
		||||
                        {x: competencies.statistics.proficientcompetencycount, y: competencies.statistics.competencycount} } }}
 | 
			
		||||
                    <core-progress-bar [progress]="competencies.statistics.proficientcompetencypercentage"></core-progress-bar>
 | 
			
		||||
                </ion-label>
 | 
			
		||||
            </ion-item>
 | 
			
		||||
            <ion-item class="ion-text-wrap"
 | 
			
		||||
                *ngIf="competencies!.statistics.canmanagecoursecompetencies && competencies!.statistics.leastproficientcount > 0">
 | 
			
		||||
                *ngIf="competencies.statistics.canmanagecoursecompetencies && competencies.statistics.leastproficientcount > 0">
 | 
			
		||||
                <ion-label>
 | 
			
		||||
                    <strong>{{ 'addon.competency.competenciesmostoftennotproficientincourse' | translate }}</strong>:
 | 
			
		||||
                    <p *ngFor="let comp of competencies!.statistics.leastproficient">
 | 
			
		||||
                    <p *ngFor="let comp of competencies.statistics.leastproficient">
 | 
			
		||||
                        <a (click)="openCompetencySummary(comp.id)">
 | 
			
		||||
                            {{ comp.shortname }} - {{ comp.idnumber }}
 | 
			
		||||
                        </a>
 | 
			
		||||
@ -40,29 +40,29 @@
 | 
			
		||||
            </ion-item>
 | 
			
		||||
        </ion-card>
 | 
			
		||||
 | 
			
		||||
        <h3  class="ion-margin-horizontal" *ngIf="competencies && competencies!.statistics.competencycount > 0">
 | 
			
		||||
        <h3  class="ion-margin-horizontal" *ngIf="competencies && competencies.statistics.competencycount > 0">
 | 
			
		||||
            {{ 'addon.competency.coursecompetencies' | translate }}
 | 
			
		||||
        </h3>
 | 
			
		||||
        <ion-card *ngIf="user">
 | 
			
		||||
             <ion-item class="ion-text-wrap">
 | 
			
		||||
                <core-user-avatar [user]="user" slot="start"></core-user-avatar>
 | 
			
		||||
               <ion-label><h2>{{ user!.fullname }}</h2></ion-label>
 | 
			
		||||
               <ion-label><h2>{{ user.fullname }}</h2></ion-label>
 | 
			
		||||
            </ion-item>
 | 
			
		||||
        </ion-card>
 | 
			
		||||
        <core-empty-box *ngIf="competencies && competencies!.statistics.competencycount == 0"
 | 
			
		||||
        <core-empty-box *ngIf="competencies && competencies.statistics.competencycount == 0"
 | 
			
		||||
            icon="fas-award" message="{{ 'addon.competency.nocompetenciesincourse' | translate }}">
 | 
			
		||||
        </core-empty-box>
 | 
			
		||||
 | 
			
		||||
        <div *ngIf="competencies">
 | 
			
		||||
            <ion-card *ngFor="let competency of competencies!.competencies">
 | 
			
		||||
            <ion-card *ngFor="let competency of competencies.competencies">
 | 
			
		||||
                <ion-item class="ion-text-wrap" (click)="openCompetency(competency.competency.id)"
 | 
			
		||||
                    [title]="competency.competency.shortname" detail="true">
 | 
			
		||||
                    <ion-label>
 | 
			
		||||
                        <h2><strong>{{competency.competency.shortname}} <em>{{competency.competency.idnumber}}</em></strong></h2>
 | 
			
		||||
                    </ion-label>
 | 
			
		||||
                    <ion-badge slot="end" *ngIf="competency.usercompetencycourse && competency.usercompetencycourse!.gradename"
 | 
			
		||||
                        [color]="competency.usercompetencycourse!.proficiency ? 'success' : 'danger'">
 | 
			
		||||
                        {{ competency.usercompetencycourse!.gradename }}
 | 
			
		||||
                    <ion-badge slot="end" *ngIf="competency.usercompetencycourse && competency.usercompetencycourse.gradename"
 | 
			
		||||
                        [color]="competency.usercompetencycourse.proficiency ? 'success' : 'danger'">
 | 
			
		||||
                        {{ competency.usercompetencycourse.gradename }}
 | 
			
		||||
                    </ion-badge>
 | 
			
		||||
                </ion-item>
 | 
			
		||||
                <ion-item class="ion-text-wrap">
 | 
			
		||||
@ -92,7 +92,7 @@
 | 
			
		||||
                                <ng-container *ngIf="!ancestor.last"> / </ng-container>
 | 
			
		||||
                            </span>
 | 
			
		||||
                        </div>
 | 
			
		||||
                        <div *ngIf="competencies!.statistics.canmanagecoursecompetencies">
 | 
			
		||||
                        <div *ngIf="competencies.statistics.canmanagecoursecompetencies">
 | 
			
		||||
                            <strong>{{ 'addon.competency.uponcoursecompletion' | translate }}</strong>
 | 
			
		||||
                             <ng-container *ngFor="let ruleoutcome of competency.ruleoutcomeoptions">
 | 
			
		||||
                                <span *ngIf="ruleoutcome.selected">{{ ruleoutcome.text }}</span>
 | 
			
		||||
 | 
			
		||||
@ -3,7 +3,7 @@
 | 
			
		||||
        <ion-buttons slot="start">
 | 
			
		||||
            <ion-back-button [attr.aria-label]="'core.back' | translate"></ion-back-button>
 | 
			
		||||
        </ion-buttons>
 | 
			
		||||
        <ion-title *ngIf="plan">{{plan!.plan.name}}</ion-title>
 | 
			
		||||
        <ion-title *ngIf="plan">{{plan.plan.name}}</ion-title>
 | 
			
		||||
    </ion-toolbar>
 | 
			
		||||
</ion-header>
 | 
			
		||||
<ion-content>
 | 
			
		||||
@ -15,27 +15,27 @@
 | 
			
		||||
            <ion-item class="ion-text-wrap">
 | 
			
		||||
                <ion-label>
 | 
			
		||||
                    <core-user-avatar [user]="user" slot="start"></core-user-avatar>
 | 
			
		||||
                    <h2>{{ user!.fullname }}</h2>
 | 
			
		||||
                    <h2>{{ user.fullname }}</h2>
 | 
			
		||||
                </ion-label>
 | 
			
		||||
            </ion-item>
 | 
			
		||||
       </ion-card>
 | 
			
		||||
        <ion-card *ngIf="plan">
 | 
			
		||||
            <ion-list>
 | 
			
		||||
                <ion-item class="ion-text-wrap" *ngIf="plan!.plan.description" lines="none">
 | 
			
		||||
                <ion-item class="ion-text-wrap" *ngIf="plan.plan.description" lines="none">
 | 
			
		||||
                    <ion-label>
 | 
			
		||||
                        <core-format-text [text]="plan!.plan.description" contextLevel="user"
 | 
			
		||||
                            [contextInstanceId]="plan!.plan.userid">
 | 
			
		||||
                        <core-format-text [text]="plan.plan.description" contextLevel="user"
 | 
			
		||||
                            [contextInstanceId]="plan.plan.userid">
 | 
			
		||||
                        </core-format-text>
 | 
			
		||||
                    </ion-label>
 | 
			
		||||
                </ion-item>
 | 
			
		||||
                <ion-item class="ion-text-wrap" lines="none">
 | 
			
		||||
                    <ion-label>
 | 
			
		||||
                        <p>
 | 
			
		||||
                            <strong>{{ 'addon.competency.status' | translate }}</strong>: {{ plan!.plan.statusname }}
 | 
			
		||||
                            <strong>{{ 'addon.competency.status' | translate }}</strong>: {{ plan.plan.statusname }}
 | 
			
		||||
                        </p>
 | 
			
		||||
                    </ion-label>
 | 
			
		||||
                </ion-item>
 | 
			
		||||
                <ion-item class="ion-text-wrap" *ngIf="plan!.plan.duedate > 0" lines="none">
 | 
			
		||||
                <ion-item class="ion-text-wrap" *ngIf="plan.plan.duedate > 0" lines="none">
 | 
			
		||||
                    <ion-label>
 | 
			
		||||
                        <p>
 | 
			
		||||
                            <strong>{{ 'addon.competency.duedate' | translate }}</strong>:
 | 
			
		||||
@ -43,10 +43,10 @@
 | 
			
		||||
                        </p>
 | 
			
		||||
                    </ion-label>
 | 
			
		||||
                </ion-item>
 | 
			
		||||
                <ion-item class="ion-text-wrap" *ngIf="plan!.plan.template" lines="none">
 | 
			
		||||
                <ion-item class="ion-text-wrap" *ngIf="plan.plan.template" lines="none">
 | 
			
		||||
                    <ion-label>
 | 
			
		||||
                        <p>
 | 
			
		||||
                            <strong>{{ 'addon.competency.template' | translate }}</strong>: {{ plan!.plan.template!.shortname }}
 | 
			
		||||
                            <strong>{{ 'addon.competency.template' | translate }}</strong>: {{ plan.plan.template.shortname }}
 | 
			
		||||
                        </p>
 | 
			
		||||
                    </ion-label>
 | 
			
		||||
                </ion-item>
 | 
			
		||||
 | 
			
		||||
@ -56,6 +56,41 @@ export class AddonCompetencyProvider {
 | 
			
		||||
            site.isFeatureDisabled('CoreUserDelegate_AddonCompetency');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns whether current user can see another user competencies in a course.
 | 
			
		||||
     *
 | 
			
		||||
     * @param courseId Course ID.
 | 
			
		||||
     * @param userId User ID.
 | 
			
		||||
     * @param siteId Site ID. If not defined, current site.
 | 
			
		||||
     * @return Promise resolved with boolean: whether the user can view the competencies.
 | 
			
		||||
     */
 | 
			
		||||
    async canViewUserCompetenciesInCourse(courseId: number, userId?: number, siteId?: string): Promise<boolean> {
 | 
			
		||||
        if (!CoreSites.isLoggedIn()) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            const response = await this.getCourseCompetenciesPage(courseId, siteId);
 | 
			
		||||
 | 
			
		||||
            if (!response.competencies.length) {
 | 
			
		||||
                // No competencies.
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (!userId || userId == CoreSites.getCurrentSiteUserId()) {
 | 
			
		||||
                // Current user.
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Check if current user can view any competency of the user.
 | 
			
		||||
            await this.getCompetencyInCourse(courseId, response.competencies[0].competency.id, userId, siteId);
 | 
			
		||||
 | 
			
		||||
            return true;
 | 
			
		||||
        } catch {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get cache key for user learning plans data WS calls.
 | 
			
		||||
     *
 | 
			
		||||
@ -290,7 +325,7 @@ export class AddonCompetencyProvider {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get all competencies in a course.
 | 
			
		||||
     * Get all competencies in a course for a certain user.
 | 
			
		||||
     *
 | 
			
		||||
     * @param courseId ID of the course.
 | 
			
		||||
     * @param userId ID of the user.
 | 
			
		||||
@ -304,6 +339,38 @@ export class AddonCompetencyProvider {
 | 
			
		||||
        siteId?: string,
 | 
			
		||||
        ignoreCache = false,
 | 
			
		||||
    ): Promise<AddonCompetencyDataForCourseCompetenciesPageWSResponse> {
 | 
			
		||||
 | 
			
		||||
        const courseCompetencies = await this.getCourseCompetenciesPage(courseId, siteId, ignoreCache);
 | 
			
		||||
 | 
			
		||||
        if (!userId || userId == CoreSites.getCurrentSiteUserId()) {
 | 
			
		||||
            return courseCompetencies;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const userCompetenciesSumaries: AddonCompetencyDataForUserCompetencySummaryInCourseWSResponse[] =
 | 
			
		||||
            await Promise.all(courseCompetencies.competencies.map((competency) =>
 | 
			
		||||
                this.getCompetencyInCourse(courseId, competency.competency.id, userId, siteId)));
 | 
			
		||||
 | 
			
		||||
        userCompetenciesSumaries.forEach((userCompetenciesSumary, index) => {
 | 
			
		||||
            courseCompetencies.competencies[index].usercompetencycourse =
 | 
			
		||||
                userCompetenciesSumary.usercompetencysummary.usercompetencycourse;
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        return courseCompetencies;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get all competencies in a course.
 | 
			
		||||
     *
 | 
			
		||||
     * @param courseId ID of the course.
 | 
			
		||||
     * @param siteId Site ID. If not defined, current site.
 | 
			
		||||
     * @param ignoreCache True if it should ignore cached data (it will always fail in offline or server down).
 | 
			
		||||
     * @return Promise to be resolved when the course competencies are retrieved.
 | 
			
		||||
     */
 | 
			
		||||
    async getCourseCompetenciesPage(
 | 
			
		||||
        courseId: number,
 | 
			
		||||
        siteId?: string,
 | 
			
		||||
        ignoreCache = false,
 | 
			
		||||
    ): Promise<AddonCompetencyDataForCourseCompetenciesPageWSResponse> {
 | 
			
		||||
        const site = await CoreSites.getSite(siteId);
 | 
			
		||||
 | 
			
		||||
        const params: AddonCompetencyDataForCourseCompetenciesPageWSParams = {
 | 
			
		||||
@ -320,26 +387,11 @@ export class AddonCompetencyProvider {
 | 
			
		||||
            preSets.emergencyCache = false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const courseCompetencies = await site.read<AddonCompetencyDataForCourseCompetenciesPageWSResponse>(
 | 
			
		||||
        return site.read<AddonCompetencyDataForCourseCompetenciesPageWSResponse>(
 | 
			
		||||
            'tool_lp_data_for_course_competencies_page',
 | 
			
		||||
            params,
 | 
			
		||||
            preSets,
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        if (!userId || userId == CoreSites.getCurrentSiteUserId()) {
 | 
			
		||||
            return courseCompetencies;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const userCompetenciesSumaries: AddonCompetencyDataForUserCompetencySummaryInCourseWSResponse[] =
 | 
			
		||||
            await Promise.all(courseCompetencies.competencies.map((competency) =>
 | 
			
		||||
                this.getCompetencyInCourse(courseId, competency.competency.id, userId, siteId)));
 | 
			
		||||
 | 
			
		||||
        userCompetenciesSumaries.forEach((userCompetenciesSumary, index) => {
 | 
			
		||||
            courseCompetencies.competencies[index].usercompetencycourse =
 | 
			
		||||
                userCompetenciesSumary.usercompetencysummary.usercompetencycourse;
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        return courseCompetencies;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 | 
			
		||||
@ -98,39 +98,41 @@ export class AddonCompetencyCourseOptionHandlerService implements CoreCourseOpti
 | 
			
		||||
        // Get the competencies in the course.
 | 
			
		||||
        const competencies = await AddonCompetency.getCourseCompetencies(course.id, undefined, undefined, true);
 | 
			
		||||
 | 
			
		||||
        if (!competencies || !competencies.competencies) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const promises: Promise<unknown>[] = [];
 | 
			
		||||
 | 
			
		||||
        // Prefetch all the competencies.
 | 
			
		||||
        if (competencies && competencies.competencies) {
 | 
			
		||||
            competencies.competencies.forEach((competency) => {
 | 
			
		||||
                promises.push(AddonCompetency.getCompetencyInCourse(
 | 
			
		||||
                    course.id,
 | 
			
		||||
                    competency.competency.id,
 | 
			
		||||
                    undefined,
 | 
			
		||||
                    undefined,
 | 
			
		||||
                    true,
 | 
			
		||||
                ));
 | 
			
		||||
        competencies.competencies.forEach((competency) => {
 | 
			
		||||
            promises.push(AddonCompetency.getCompetencyInCourse(
 | 
			
		||||
                course.id,
 | 
			
		||||
                competency.competency.id,
 | 
			
		||||
                undefined,
 | 
			
		||||
                undefined,
 | 
			
		||||
                true,
 | 
			
		||||
            ));
 | 
			
		||||
 | 
			
		||||
                promises.push(AddonCompetency.getCompetencySummary(
 | 
			
		||||
                    competency.competency.id,
 | 
			
		||||
                    undefined,
 | 
			
		||||
                    undefined,
 | 
			
		||||
                    true,
 | 
			
		||||
                ));
 | 
			
		||||
            promises.push(AddonCompetency.getCompetencySummary(
 | 
			
		||||
                competency.competency.id,
 | 
			
		||||
                undefined,
 | 
			
		||||
                undefined,
 | 
			
		||||
                true,
 | 
			
		||||
            ));
 | 
			
		||||
 | 
			
		||||
                if (competency.coursemodules) {
 | 
			
		||||
                    competency.coursemodules.forEach((module) => {
 | 
			
		||||
                        promises.push(CoreFilterHelper.getFilters(ContextLevel.MODULE, module.id, { courseId: course.id }));
 | 
			
		||||
                    });
 | 
			
		||||
                }
 | 
			
		||||
            if (competency.coursemodules) {
 | 
			
		||||
                competency.coursemodules.forEach((module) => {
 | 
			
		||||
                    promises.push(CoreFilterHelper.getFilters(ContextLevel.MODULE, module.id, { courseId: course.id }));
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
                if (competency.plans) {
 | 
			
		||||
                    competency.plans.forEach((plan) => {
 | 
			
		||||
                        promises.push(CoreFilterHelper.getFilters(ContextLevel.USER, plan.userid));
 | 
			
		||||
                    });
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
            if (competency.plans) {
 | 
			
		||||
                competency.plans.forEach((plan) => {
 | 
			
		||||
                    promises.push(CoreFilterHelper.getFilters(ContextLevel.USER, plan.userid));
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        await Promise.all(promises);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -54,7 +54,7 @@ export class AddonCompetencyPushClickHandlerService implements CorePushNotificat
 | 
			
		||||
            // Open the learning plan.
 | 
			
		||||
            const planId = Number(contextUrlParams.id);
 | 
			
		||||
 | 
			
		||||
            await  CoreUtils.ignoreErrors(AddonCompetency.invalidateLearningPlan(planId, notification.site));
 | 
			
		||||
            await CoreUtils.ignoreErrors(AddonCompetency.invalidateLearningPlan(planId, notification.site));
 | 
			
		||||
 | 
			
		||||
            await CoreNavigator.navigateToSitePath('/' + AddonCompetencyMainMenuHandlerService.PAGE_NAME + '/' + planId, {
 | 
			
		||||
                siteId: notification.site,
 | 
			
		||||
 | 
			
		||||
@ -44,9 +44,7 @@ export class AddonCompetencyUserHandlerService implements CoreUserProfileHandler
 | 
			
		||||
    async isEnabledForUser(user: CoreUserProfile, courseId?: number): Promise<boolean> {
 | 
			
		||||
        try {
 | 
			
		||||
            if (courseId) {
 | 
			
		||||
                const response = await AddonCompetency.getCourseCompetencies(courseId, user.id);
 | 
			
		||||
 | 
			
		||||
                return response.competencies.length > 0;
 | 
			
		||||
                return AddonCompetency.canViewUserCompetenciesInCourse(courseId, user.id);
 | 
			
		||||
            } else {
 | 
			
		||||
                const plans = await AddonCompetency.getLearningPlans(user.id);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user