MOBILE-2915 completion: Display warning for teachers viewing own

main
Dani Palou 2019-03-20 14:31:33 +01:00
parent 2659835d2b
commit 92d6d09b8f
5 changed files with 20 additions and 5 deletions

View File

@ -145,6 +145,7 @@
"addon.coursecompletion.criteriarequiredany": "completion", "addon.coursecompletion.criteriarequiredany": "completion",
"addon.coursecompletion.inprogress": "completion", "addon.coursecompletion.inprogress": "completion",
"addon.coursecompletion.manualselfcompletion": "completion", "addon.coursecompletion.manualselfcompletion": "completion",
"addon.coursecompletion.nottracked": "completion",
"addon.coursecompletion.notyetstarted": "completion", "addon.coursecompletion.notyetstarted": "completion",
"addon.coursecompletion.pending": "completion", "addon.coursecompletion.pending": "completion",
"addon.coursecompletion.required": "moodle", "addon.coursecompletion.required": "moodle",

View File

@ -3,7 +3,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]="completionLoaded"> <core-loading [hideUntil]="completionLoaded">
<ion-card *ngIf="completion"> <ion-card *ngIf="completion && tracked">
<ion-item text-wrap> <ion-item text-wrap>
<h2>{{ 'addon.coursecompletion.status' | translate }}</h2> <h2>{{ 'addon.coursecompletion.status' | translate }}</h2>
<p>{{ completion.statusText | translate }}</p> <p>{{ completion.statusText | translate }}</p>
@ -14,7 +14,7 @@
<p *ngIf="completion.aggregation === 2">{{ 'addon.coursecompletion.criteriarequiredany' | translate }}</p> <p *ngIf="completion.aggregation === 2">{{ 'addon.coursecompletion.criteriarequiredany' | translate }}</p>
</ion-item> </ion-item>
</ion-card> </ion-card>
<ion-card *ngIf="completion"> <ion-card *ngIf="completion && tracked">
<ion-item-divider>{{ 'addon.coursecompletion.requiredcriteria' | translate }}</ion-item-divider> <ion-item-divider>{{ 'addon.coursecompletion.requiredcriteria' | translate }}</ion-item-divider>
<ion-item class="hidden-tablet" text-wrap *ngFor="let criteria of completion.completions"> <ion-item class="hidden-tablet" text-wrap *ngFor="let criteria of completion.completions">
<h2><core-format-text clean="true" [text]="criteria.details.criteria"></core-format-text></h2> <h2><core-format-text clean="true" [text]="criteria.details.criteria"></core-format-text></h2>
@ -41,11 +41,16 @@
</ion-row> </ion-row>
</ion-item> </ion-item>
</ion-card> </ion-card>
<ion-card *ngIf="showSelfComplete"> <ion-card *ngIf="showSelfComplete && tracked">
<ion-item-divider>{{ 'addon.coursecompletion.manualselfcompletion' | translate }}</ion-item-divider> <ion-item-divider>{{ 'addon.coursecompletion.manualselfcompletion' | translate }}</ion-item-divider>
<ion-item> <ion-item>
<button ion-button block (click)="completeCourse()">{{ 'addon.coursecompletion.completecourse' | translate }}</button> <button ion-button block (click)="completeCourse()">{{ 'addon.coursecompletion.completecourse' | translate }}</button>
</ion-item> </ion-item>
</ion-card> </ion-card>
<div *ngIf="!tracked" class="core-warning-card" icon-start>
<ion-icon name="warning"></ion-icon>
{{ 'addon.coursecompletion.nottracked' | translate }}
</div>
</core-loading> </core-loading>
</ion-content> </ion-content>

View File

@ -31,6 +31,7 @@ export class AddonCourseCompletionReportComponent implements OnInit {
completionLoaded = false; completionLoaded = false;
completion: any; completion: any;
showSelfComplete: boolean; showSelfComplete: boolean;
tracked = true; // Whether completion is tracked.
constructor( constructor(
private sitesProvider: CoreSitesProvider, private sitesProvider: CoreSitesProvider,
@ -62,8 +63,14 @@ export class AddonCourseCompletionReportComponent implements OnInit {
this.completion = completion; this.completion = completion;
this.showSelfComplete = this.courseCompletionProvider.canMarkSelfCompleted(this.userId, completion); this.showSelfComplete = this.courseCompletionProvider.canMarkSelfCompleted(this.userId, completion);
}).catch((message) => { this.tracked = true;
this.domUtils.showErrorModalDefault(message, 'addon.coursecompletion.couldnotloadreport', true); }).catch((error) => {
if (error && error.errorcode == 'notenroled') {
// Not enrolled error, probably a teacher.
this.tracked = false;
} else {
this.domUtils.showErrorModalDefault(error, 'addon.coursecompletion.couldnotloadreport', true);
}
}); });
} }

View File

@ -12,6 +12,7 @@
"criteriarequiredany": "Any criteria below are required", "criteriarequiredany": "Any criteria below are required",
"inprogress": "In progress", "inprogress": "In progress",
"manualselfcompletion": "Manual self completion", "manualselfcompletion": "Manual self completion",
"nottracked": "You are currently not being tracked by completion in this course",
"notyetstarted": "Not yet started", "notyetstarted": "Not yet started",
"pending": "Pending", "pending": "Pending",
"required": "Required", "required": "Required",

View File

@ -145,6 +145,7 @@
"addon.coursecompletion.criteriarequiredany": "Any criteria below are required", "addon.coursecompletion.criteriarequiredany": "Any criteria below are required",
"addon.coursecompletion.inprogress": "In progress", "addon.coursecompletion.inprogress": "In progress",
"addon.coursecompletion.manualselfcompletion": "Manual self completion", "addon.coursecompletion.manualselfcompletion": "Manual self completion",
"addon.coursecompletion.nottracked": "You are currently not being tracked by completion in this course",
"addon.coursecompletion.notyetstarted": "Not yet started", "addon.coursecompletion.notyetstarted": "Not yet started",
"addon.coursecompletion.pending": "Pending", "addon.coursecompletion.pending": "Pending",
"addon.coursecompletion.required": "Required", "addon.coursecompletion.required": "Required",