MOBILE-2324 courses: Remove course options from course preview
parent
a0312278d8
commit
a856b5c90e
|
@ -122,11 +122,15 @@ export class CoreCourseSectionPage implements OnDestroy {
|
||||||
*/
|
*/
|
||||||
protected loadData(refresh?: boolean): Promise<any> {
|
protected loadData(refresh?: boolean): Promise<any> {
|
||||||
// First of all, get the course because the data might have changed.
|
// First of all, get the course because the data might have changed.
|
||||||
return this.coursesProvider.getUserCourse(this.course.id).then((course) => {
|
return this.coursesProvider.getUserCourse(this.course.id).catch(() => {
|
||||||
|
// Error getting the course, probably guest access.
|
||||||
|
}).then((course) => {
|
||||||
const promises = [];
|
const promises = [];
|
||||||
let promise;
|
let promise;
|
||||||
|
|
||||||
this.course = course;
|
if (course) {
|
||||||
|
this.course = course;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the completion status.
|
// Get the completion status.
|
||||||
if (this.course.enablecompletion === false) {
|
if (this.course.enablecompletion === false) {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<core-loading [hideUntil]="dataLoaded">
|
<core-loading [hideUntil]="dataLoaded">
|
||||||
|
|
||||||
<ion-list *ngIf="course">
|
<ion-list *ngIf="course">
|
||||||
<a ion-item text-wrap (click)="openCourse()" [title]="course.fullname" [attr.detail-none]="!handlersShouldBeShown">
|
<a ion-item text-wrap (click)="openCourse()" [title]="course.fullname" [attr.detail-none]="!canAccessCourse">
|
||||||
<ion-icon name="ionic" item-start></ion-icon>
|
<ion-icon name="ionic" item-start></ion-icon>
|
||||||
<h2><core-format-text [text]="course.fullname"></core-format-text></h2>
|
<h2><core-format-text [text]="course.fullname"></core-format-text></h2>
|
||||||
<p *ngIf="course.categoryname">{{course.categoryname}}</p>
|
<p *ngIf="course.categoryname">{{course.categoryname}}</p>
|
||||||
|
@ -41,24 +41,15 @@
|
||||||
<ion-item *ngIf="!isEnrolled && !selfEnrolInstances.length && !paypalEnabled">
|
<ion-item *ngIf="!isEnrolled && !selfEnrolInstances.length && !paypalEnabled">
|
||||||
<p>{{ 'core.courses.notenrollable' | translate }}</p>
|
<p>{{ 'core.courses.notenrollable' | translate }}</p>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
<a ion-item *ngIf="handlersShouldBeShown" (click)="prefetchCourse()" detail-none>
|
<a ion-item *ngIf="canAccessCourse" (click)="prefetchCourse()" detail-none>
|
||||||
<ion-icon *ngIf="prefetchCourseData.prefetchCourseIcon != 'spinner'" [name]="prefetchCourseData.prefetchCourseIcon" item-start></ion-icon>
|
<ion-icon *ngIf="prefetchCourseData.prefetchCourseIcon != 'spinner'" [name]="prefetchCourseData.prefetchCourseIcon" item-start></ion-icon>
|
||||||
<ion-spinner *ngIf="prefetchCourseData.prefetchCourseIcon == 'spinner'" item-start></ion-spinner>
|
<ion-spinner *ngIf="prefetchCourseData.prefetchCourseIcon == 'spinner'" item-start></ion-spinner>
|
||||||
<h2>{{ 'core.course.downloadcourse' | translate }}</h2>
|
<h2>{{ 'core.course.downloadcourse' | translate }}</h2>
|
||||||
</a>
|
</a>
|
||||||
<a ion-item (click)="openCourse()" [title]="course.fullname" *ngIf="handlersShouldBeShown">
|
<a ion-item (click)="openCourse()" [title]="course.fullname" *ngIf="canAccessCourse">
|
||||||
<ion-icon name="briefcase" item-start></ion-icon>
|
<ion-icon name="briefcase" item-start></ion-icon>
|
||||||
<h2>{{ 'core.course.contents' | translate }}</h2>
|
<h2>{{ 'core.course.contents' | translate }}</h2>
|
||||||
</a>
|
</a>
|
||||||
<ng-container *ngIf="handlersShouldBeShown && course._handlers && course._handlers.length">
|
|
||||||
<a ion-item text-wrap *ngFor="let handler of course._handlers" class="core-courses-handler {{handler.data.class}}" (click)="handler.data.action(course)" [title]="handler.data.title | translate">
|
|
||||||
<ion-icon [name]="handler.data.icon" item-start></ion-icon>
|
|
||||||
<h2>{{ handler.data.title | translate }}</h2>
|
|
||||||
</a>
|
|
||||||
</ng-container>
|
|
||||||
<ion-item class="core-loading-course-handlers" text-center *ngIf="handlersShouldBeShown && !handlersLoaded">
|
|
||||||
<ion-spinner></ion-spinner>
|
|
||||||
</ion-item>
|
|
||||||
</ion-list>
|
</ion-list>
|
||||||
</core-loading>
|
</core-loading>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|
|
@ -36,8 +36,7 @@ import { CoreCourseHelperProvider } from '../../../course/providers/helper';
|
||||||
export class CoreCoursesCoursePreviewPage implements OnDestroy {
|
export class CoreCoursesCoursePreviewPage implements OnDestroy {
|
||||||
course: any;
|
course: any;
|
||||||
isEnrolled: boolean;
|
isEnrolled: boolean;
|
||||||
handlersShouldBeShown = true;
|
canAccessCourse = true;
|
||||||
handlersLoaded: boolean;
|
|
||||||
component = 'CoreCoursesCoursePreview';
|
component = 'CoreCoursesCoursePreview';
|
||||||
selfEnrolInstances: any[] = [];
|
selfEnrolInstances: any[] = [];
|
||||||
paypalEnabled: boolean;
|
paypalEnabled: boolean;
|
||||||
|
@ -206,19 +205,17 @@ export class CoreCoursesCoursePreviewPage implements OnDestroy {
|
||||||
// Success retrieving the course, we can assume the user has permissions to view it.
|
// Success retrieving the course, we can assume the user has permissions to view it.
|
||||||
this.course.fullname = course.fullname || this.course.fullname;
|
this.course.fullname = course.fullname || this.course.fullname;
|
||||||
this.course.summary = course.summary || this.course.summary;
|
this.course.summary = course.summary || this.course.summary;
|
||||||
|
this.canAccessCourse = true;
|
||||||
return this.loadCourseHandlers(refresh, false);
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
// The user is not an admin/manager. Check if we can provide guest access to the course.
|
// The user is not an admin/manager. Check if we can provide guest access to the course.
|
||||||
return this.canAccessAsGuest().then((passwordRequired) => {
|
return this.canAccessAsGuest().then((passwordRequired) => {
|
||||||
if (!passwordRequired) {
|
if (!passwordRequired) {
|
||||||
return this.loadCourseHandlers(refresh, true);
|
this.canAccessCourse = true;
|
||||||
} else {
|
} else {
|
||||||
return Promise.reject(null);
|
this.canAccessCourse = false;
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.course._handlers = [];
|
this.canAccessCourse = false;
|
||||||
this.handlersShouldBeShown = false;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
|
@ -226,25 +223,11 @@ export class CoreCoursesCoursePreviewPage implements OnDestroy {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Load course nav handlers.
|
|
||||||
*
|
|
||||||
* @param {boolean} refresh Whether the user is refreshing the data.
|
|
||||||
* @param {boolean} guest Whether it's guest access.
|
|
||||||
*/
|
|
||||||
protected loadCourseHandlers(refresh: boolean, guest: boolean): Promise<any> {
|
|
||||||
return this.courseOptionsDelegate.getHandlersToDisplay(this.course, refresh, guest, true).then((handlers) => {
|
|
||||||
this.course._handlers = handlers;
|
|
||||||
this.handlersShouldBeShown = true;
|
|
||||||
this.handlersLoaded = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open the course.
|
* Open the course.
|
||||||
*/
|
*/
|
||||||
openCourse(): void {
|
openCourse(): void {
|
||||||
if (!this.handlersShouldBeShown) {
|
if (!this.canAccessCourse) {
|
||||||
// Course cannot be opened.
|
// Course cannot be opened.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -435,8 +418,7 @@ export class CoreCoursesCoursePreviewPage implements OnDestroy {
|
||||||
* Prefetch the course.
|
* Prefetch the course.
|
||||||
*/
|
*/
|
||||||
prefetchCourse(): void {
|
prefetchCourse(): void {
|
||||||
this.courseHelper.confirmAndPrefetchCourse(this.prefetchCourseData, this.course, undefined, this.course._handlers)
|
this.courseHelper.confirmAndPrefetchCourse(this.prefetchCourseData, this.course).catch((error) => {
|
||||||
.catch((error) => {
|
|
||||||
if (!this.pageDestroyed) {
|
if (!this.pageDestroyed) {
|
||||||
this.domUtils.showErrorModalDefault(error, 'core.course.errordownloadingcourse', true);
|
this.domUtils.showErrorModalDefault(error, 'core.course.errordownloadingcourse', true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue