Skip to content

Commit

Permalink
Merge pull request #3796 from dpalou/MOBILE-3599
Browse files Browse the repository at this point in the history
MOBILE-3599 competency: Format competency and plan names
  • Loading branch information
crazyserver authored Sep 28, 2023
2 parents 64be18b + 024b962 commit 335a380
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 24 deletions.
11 changes: 9 additions & 2 deletions src/addons/competency/pages/competencies/competencies.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
<ion-back-button [text]="'core.back' | translate"></ion-back-button>
</ion-buttons>
<ion-title>
<h1>{{ title }}</h1>
<h1>
<core-format-text [text]="title" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId">
</core-format-text>
</h1>
</ion-title>
</ion-toolbar>
</ion-header>
Expand All @@ -19,7 +22,11 @@ <h1>{{ title }}</h1>
[attr.aria-label]="competency.competency.shortname" (click)="competencies.select(competency)"
[attr.aria-current]="competencies.getItemAriaCurrent(competency)" button detail="true">
<ion-label>
<p class="item-heading">{{ competency.competency.shortname }} <em>{{competency.competency.idnumber}}</em></p>
<p class="item-heading">
<core-format-text [text]="competency.competency.shortname" [contextLevel]="contextLevel"
[contextInstanceId]="contextInstanceId">
</core-format-text> <em>{{competency.competency.idnumber}}</em>
</p>
</ion-label>
<ion-badge slot="end" *ngIf="competency.usercompetency"
[color]="competency.usercompetency.proficiency ? 'success' : 'danger'">
Expand Down
7 changes: 7 additions & 0 deletions src/addons/competency/pages/competencies/competencies.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { CoreSites } from '@services/sites';
import { CoreTime } from '@singletons/time';
import { ContextLevel } from '@/core/constants';

/**
* Page that displays the list of competencies of a learning plan.
Expand All @@ -48,6 +49,8 @@ export class AddonCompetencyCompetenciesPage implements AfterViewInit, OnDestroy
>;

title = '';
contextLevel?: string;
contextInstanceId?: number;

protected logView: () => void;

Expand Down Expand Up @@ -99,8 +102,12 @@ export class AddonCompetencyCompetenciesPage implements AfterViewInit, OnDestroy
}

this.title = source.plan.plan.name;
this.contextLevel = ContextLevel.USER;
this.contextInstanceId = source.user?.id || source.plan.plan.userid;
} else {
this.title = Translate.instant('addon.competency.coursecompetencies');
this.contextLevel = ContextLevel.COURSE;
this.contextInstanceId = source.COURSE_ID;
}

this.logView();
Expand Down
26 changes: 20 additions & 6 deletions src/addons/competency/pages/competency/competency.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
</ion-buttons>
<ion-title>
<h1 *ngIf="competency">
{{ competency.competency.competency.shortname }} <small>{{ competency.competency.competency.idnumber }}</small>
<core-format-text [text]="competency.competency.competency.shortname" [contextLevel]="contextLevel"
[contextInstanceId]="contextInstanceId">
</core-format-text> <small>{{ competency.competency.competency.idnumber }}</small>
</h1>
</ion-title>
</ion-toolbar>
Expand Down Expand Up @@ -37,18 +39,28 @@ <h1 *ngIf="competency">
<p class="item-heading">{{ 'addon.competency.path' | translate }}</p>
<p>
<a *ngIf="competency.competency.comppath.showlinks" [href]="competencyFrameworkUrl" core-link>
{{ competency.competency.comppath.framework.name }}
<core-format-text [text]="competency.competency.comppath.framework.name" [contextLevel]="contextLevel"
[contextInstanceId]="contextInstanceId">
</core-format-text>
</a>
<ng-container *ngIf="!competency.competency.comppath.showlinks">
{{ competency.competency.comppath.framework.name }}
<core-format-text [text]="competency.competency.comppath.framework.name" [contextLevel]="contextLevel"
[contextInstanceId]="contextInstanceId">
</core-format-text>
</ng-container>
&nbsp;/&nbsp;
<ng-container *ngFor="let ancestor of competency.competency.comppath.ancestors">
<button *ngIf="competency.competency.comppath.showlinks" (click)="openCompetencySummary(ancestor.id)"
class="as-link">
{{ ancestor.name }}
<core-format-text [text]="ancestor.name" [contextLevel]="contextLevel"
[contextInstanceId]="contextInstanceId">
</core-format-text>
</button>
<ng-container *ngIf="!competency.competency.comppath.showlinks">{{ ancestor.name }}</ng-container>
<ng-container *ngIf="!competency.competency.comppath.showlinks">
<core-format-text [text]="ancestor.name" [contextLevel]="contextLevel"
[contextInstanceId]="contextInstanceId">
</core-format-text>
</ng-container>
<ng-container *ngIf="!ancestor.last">&nbsp;/&nbsp;</ng-container>
</ng-container>
</p>
Expand All @@ -63,7 +75,9 @@ <h1 *ngIf="competency">
<ng-container *ngIf="competency.competency.hasrelatedcompetencies">
<p *ngFor="let relatedcomp of competency.competency.relatedcompetencies">
<button (click)="openCompetencySummary(relatedcomp.id)" class="as-link">
{{ relatedcomp.shortname }} - {{ relatedcomp.idnumber }}
<core-format-text [text]="relatedcomp.shortname" [contextLevel]="contextLevel"
[contextInstanceId]="contextInstanceId">
</core-format-text> - {{ relatedcomp.idnumber }}
</button>
</p>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
</ion-buttons>
<ion-title>
<h1 *ngIf="competency">
{{ competency.competency.shortname }} <small>{{ competency.competency.idnumber }}</small>
<core-format-text [text]="competency.competency.shortname" [contextLevel]="contextLevel"
[contextInstanceId]="contextInstanceId">
</core-format-text> <small>{{ competency.competency.idnumber }}</small>
</h1>
</ion-title>
</ion-toolbar>
Expand All @@ -26,11 +28,16 @@ <h1 *ngIf="competency">
<ion-item class="ion-text-wrap">
<ion-label>
<p class="item-heading">{{ 'addon.competency.path' | translate }}</p>
<p>{{ competency.comppath.framework.name }}
<p>
<core-format-text [text]="competency.comppath.framework.name" [contextLevel]="contextLevel"
[contextInstanceId]="contextInstanceId">
</core-format-text>
<ng-container *ngFor="let ancestor of competency.comppath.ancestors">
&nbsp;/&nbsp;
<button class="as-link" (click)="openCompetencySummary(ancestor.id)">
{{ ancestor.name }}
<core-format-text [text]="ancestor.name" [contextLevel]="contextLevel"
[contextInstanceId]="contextInstanceId">
</core-format-text>
</button>
</ng-container>
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ <h1>{{ 'addon.competency.coursecompetencies' | translate }}</h1>
<p class="item-heading">{{ 'addon.competency.competenciesmostoftennotproficientincourse' | translate }}</p>
<p *ngFor="let comp of courseCompetencies.statistics.leastproficient">
<button class="as-link" (click)="openCompetencySummary(comp.id)">
{{ comp.shortname }} - {{ comp.idnumber }}
<core-format-text [text]="comp.shortname" contextLevel="course" [contextInstanceId]="courseId">
</core-format-text> - {{ comp.idnumber }}
</button>
</p>
</ion-label>
Expand Down Expand Up @@ -67,7 +68,8 @@ <h2 class="ion-margin-horizontal" *ngIf="courseCompetencies && courseCompetencie
[attr.aria-label]="competency.competency.shortname" detail="true" button>
<ion-label>
<p class="item-heading">
{{competency.competency.shortname}} <em>{{competency.competency.idnumber}}</em>
<core-format-text [text]="competency.competency.shortname" contextLevel="course" [contextInstanceId]="courseId">
</core-format-text> <em>{{competency.competency.idnumber}}</em>
</p>
</ion-label>
<ion-badge slot="end" *ngIf="competency.usercompetencycourse && competency.usercompetencycourse.gradename"
Expand All @@ -87,18 +89,26 @@ <h2 class="ion-margin-horizontal" *ngIf="courseCompetencies && courseCompetencie
<p>
<a *ngIf="competency.comppath.showlinks" [href]="getCompetencyFrameworkUrl(competency)" core-link
[title]="competency.comppath.framework.name">
{{ competency.comppath.framework.name }}
<core-format-text [text]="competency.comppath.framework.name" contextLevel="course"
[contextInstanceId]="courseId">
</core-format-text>
</a>
<ng-container *ngIf="!competency.comppath.showlinks">
{{ competency.comppath.framework.name }}
<core-format-text [text]="competency.comppath.framework.name" contextLevel="course"
[contextInstanceId]="courseId">
</core-format-text>
</ng-container>
&nbsp;/&nbsp;
<ng-container *ngFor="let ancestor of competency.comppath.ancestors">
<button class="as-link" *ngIf="competency.comppath.showlinks"
(click)="openCompetencySummary(ancestor.id)">
{{ ancestor.name }}
<core-format-text [text]="ancestor.name" contextLevel="course" [contextInstanceId]="courseId">
</core-format-text>
</button>
<ng-container *ngIf="!competency.comppath.showlinks">{{ ancestor.name }}</ng-container>
<ng-container *ngIf="!competency.comppath.showlinks">
<core-format-text [text]="ancestor.name" contextLevel="course" [contextInstanceId]="courseId">
</core-format-text>
</ng-container>
<ng-container *ngIf="!ancestor.last">&nbsp;/&nbsp;</ng-container>
</ng-container>
</p>
Expand Down
16 changes: 13 additions & 3 deletions src/addons/competency/pages/plan/plan.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
<ion-back-button [text]="'core.back' | translate"></ion-back-button>
</ion-buttons>
<ion-title>
<h1 *ngIf="plan">{{plan.plan.name}}</h1>
<h1 *ngIf="plan">
<core-format-text [text]="plan.plan.name" contextLevel="user" [contextInstanceId]="plan.plan.userid">
</core-format-text>
</h1>
</ion-title>
</ion-toolbar>
</ion-header>
Expand Down Expand Up @@ -46,7 +49,10 @@ <h1 *ngIf="plan">{{plan.plan.name}}</h1>
<ion-item class="ion-text-wrap" *ngIf="plan.plan.template">
<ion-label>
<p class="item-heading">{{ 'addon.competency.template' | translate }}</p>
<p>{{ plan.plan.template.shortname }}</p>
<p>
<core-format-text [text]="plan.plan.template.shortname" contextLevel="system" [contextInstanceId]="0">
</core-format-text>
</p>
</ion-label>
</ion-item>
<ion-item class="ion-text-wrap">
Expand Down Expand Up @@ -77,7 +83,11 @@ <h1 *ngIf="plan">{{plan.plan.name}}</h1>
<ion-item class="ion-text-wrap" *ngFor="let competency of competencies.items" (click)="competencies.select(competency)"
[attr.aria-label]="competency.competency.shortname" detail="true" button>
<ion-label>
<p class="item-heading">{{competency.competency.shortname}} <em>{{competency.competency.idnumber}}</em></p>
<p class="item-heading">
<core-format-text [text]="competency.competency.shortname" contextLevel="user"
[contextInstanceId]="plan.plan.userid">
</core-format-text> <em>{{competency.competency.idnumber}}</em>
</p>
</ion-label>
<ion-badge *ngIf="competency.usercompetencyplan" slot="end"
[color]="competency.usercompetencyplan.proficiency ? 'success' : 'danger'">
Expand Down
5 changes: 4 additions & 1 deletion src/addons/competency/pages/planlist/planlist.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ <h1>{{ 'addon.competency.userplans' | translate }}</h1>
<ion-item class="ion-text-wrap" *ngFor="let plan of plans.items" [attr.aria-label]="plan.name" (click)="plans.select(plan)"
[attr.aria-current]="plans.getItemAriaCurrent(plan)" button detail="true">
<ion-label>
<p class="item-heading">{{ plan.name }}</p>
<p class="item-heading">
<core-format-text [text]="plan.name" contextLevel="user" [contextInstanceId]="plan.userid">
</core-format-text>
</p>
<p *ngIf="plan.duedate > 0">
{{ 'addon.competency.duedate' | translate }}:&nbsp;
{{ plan.duedate * 1000 | coreFormatDate :'strftimedatetimeshort' }}
Expand Down
4 changes: 1 addition & 3 deletions src/addons/competency/pages/planlist/planlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@ export class AddonCompetencyPlanListPage implements AfterViewInit, OnDestroy {
protected logView: () => void;

constructor() {
const userId = CoreNavigator.getRouteNumberParam('userId');
const userId = CoreNavigator.getRouteNumberParam('userId') ?? CoreSites.getCurrentSiteUserId();
const source = CoreRoutedItemsManagerSourcesTracker.getOrCreateSource(AddonCompetencyPlansSource, [userId]);

this.plans = new CoreListItemsManager(source, AddonCompetencyPlanListPage);

this.logView = CoreTime.once(async () => {
const userId = source.USER_ID ?? CoreSites.getCurrentSiteId();

CoreAnalytics.logEvent({
type: CoreAnalyticsEventType.VIEW_ITEM_LIST,
ws: 'tool_lp_data_for_plans_page',
Expand Down

0 comments on commit 335a380

Please sign in to comment.