MOBILE-2430 course: Go directly to course when enrolled
parent
327c12e733
commit
e03876b084
|
@ -11,6 +11,7 @@
|
|||
"contents": "Contents",
|
||||
"couldnotloadsectioncontent": "Could not load the section content. Please try again later.",
|
||||
"couldnotloadsections": "Could not load the sections. Please try again later.",
|
||||
"coursesummary": "Course summary",
|
||||
"downloadcourse": "Download course",
|
||||
"errordownloadingcourse": "Error downloading course.",
|
||||
"errordownloadingsection": "Error downloading section.",
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
<core-context-menu>
|
||||
<core-context-menu-item *ngIf="displayEnableDownload" [priority]="2000" [content]="'core.settings.enabledownloadsection' | translate" (action)="toggleDownload()" [iconAction]="downloadEnabledIcon"></core-context-menu-item>
|
||||
<core-context-menu-item [hidden]="!downloadCourseEnabled" [priority]="1900" [content]="prefetchCourseData.title | translate" (action)="prefetchCourse()" [iconAction]="prefetchCourseData.prefetchCourseIcon" [closeOnClick]="false"></core-context-menu-item>
|
||||
<core-context-menu-item [priority]="1800" [content]="'core.course.coursesummary' | translate" (action)="openCourseSummary()" iconAction="fa-graduation-cap"></core-context-menu-item>
|
||||
</core-context-menu>
|
||||
</core-navbar-buttons>
|
||||
<ion-content>
|
||||
|
|
|
@ -356,6 +356,13 @@ export class CoreCourseSectionPage implements OnDestroy {
|
|||
this.prefetchCourseData.title = statusData.title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the course summary
|
||||
*/
|
||||
openCourseSummary(): void {
|
||||
this.navCtrl.push('CoreCoursesCoursePreviewPage', {course: this.course, avoidOpenCourse: true});
|
||||
}
|
||||
|
||||
/**
|
||||
* Page destroyed.
|
||||
*/
|
||||
|
|
|
@ -16,6 +16,7 @@ import { Component, Input, OnInit, Optional } from '@angular/core';
|
|||
import { NavController } from 'ionic-angular';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { CoreCoursesProvider } from '../../providers/courses';
|
||||
import { CoreCourseFormatDelegate } from '@core/course/providers/format-delegate';
|
||||
|
||||
/**
|
||||
* This directive is meant to display an item for a list of courses.
|
||||
|
@ -32,7 +33,7 @@ export class CoreCoursesCourseListItemComponent implements OnInit {
|
|||
@Input() course: any; // The course to render.
|
||||
|
||||
constructor(@Optional() private navCtrl: NavController, private translate: TranslateService,
|
||||
private coursesProvider: CoreCoursesProvider) {
|
||||
private coursesProvider: CoreCoursesProvider, private courseFormatDelegate: CoreCourseFormatDelegate) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,6 +81,10 @@ export class CoreCoursesCourseListItemComponent implements OnInit {
|
|||
* @param {any} course The course to open.
|
||||
*/
|
||||
openCourse(course: any): void {
|
||||
this.navCtrl.push('CoreCoursesCoursePreviewPage', {course: course});
|
||||
if (course.isEnrolled) {
|
||||
this.courseFormatDelegate.openCourse(this.navCtrl, course);
|
||||
} else {
|
||||
this.navCtrl.push('CoreCoursesCoursePreviewPage', {course: course});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<div *ngIf="course.imageThumb" (click)="openCourse()" class="core-course-thumb">
|
||||
<img [src]="course.imageThumb" core-external-content alt=""/>
|
||||
</div>
|
||||
<a ion-item text-wrap (click)="openCourse()" [title]="course.fullname" [attr.detail-none]="!canAccessCourse">
|
||||
<a ion-item text-wrap (click)="openCourse()" [title]="course.fullname" [attr.detail-none]=" avoidOpenCourse || !canAccessCourse">
|
||||
<core-icon name="fa-graduation-cap" fixed-width item-start></core-icon>
|
||||
<h2><core-format-text [text]="course.fullname"></core-format-text></h2>
|
||||
<p *ngIf="course.categoryname"><core-format-text [text]="course.categoryname"></core-format-text></p>
|
||||
|
@ -26,7 +26,12 @@
|
|||
|
||||
<ng-container text-wrap *ngIf="course.contacts && course.contacts.length">
|
||||
<ion-item-divider color="light">{{ 'core.teachers' | translate }}</ion-item-divider>
|
||||
<a ion-item text-wrap *ngFor="let contact of course.contacts" core-user-link userId="{{contact.id}}" courseId="{{isEnrolled ? course.id : null}}" [attr.aria-label]="'core.viewprofile' | translate">{{contact.fullname}}</a>
|
||||
<a ion-item text-wrap *ngFor="let contact of course.contacts" core-user-link userId="{{contact.id}}" courseId="{{isEnrolled ? course.id : null}}" [attr.aria-label]="'core.viewprofile' | translate">
|
||||
<ion-avatar item-start>
|
||||
<img [src]="contact.userpictureurl" onError="this.src='assets/img/user-avatar.png'" core-external-content [alt]="'core.pictureof' | translate:{$a: contact.userfullname}" role="presentation">
|
||||
</ion-avatar>
|
||||
<h2>{{contact.fullname}}</h2>
|
||||
</a>
|
||||
<ion-item-divider color="light"></ion-item-divider>
|
||||
</ng-container>
|
||||
<core-file *ngFor="let file of course.overviewfiles" [file]="file" [component]="component" [componentId]="course.id"></core-file>
|
||||
|
@ -49,7 +54,7 @@
|
|||
<ion-spinner *ngIf="prefetchCourseData.prefetchCourseIcon == 'spinner'" item-start></ion-spinner>
|
||||
<h2>{{ 'core.course.downloadcourse' | translate }}</h2>
|
||||
</a>
|
||||
<a ion-item (click)="openCourse()" [title]="course.fullname" *ngIf="canAccessCourse">
|
||||
<a ion-item (click)="openCourse()" [title]="course.fullname" *ngIf="!avoidOpenCourse && canAccessCourse">
|
||||
<ion-icon name="briefcase" item-start></ion-icon>
|
||||
<h2>{{ 'core.course.contents' | translate }}</h2>
|
||||
</a>
|
||||
|
|
|
@ -24,6 +24,7 @@ import { CoreCoursesProvider } from '../../providers/courses';
|
|||
import { CoreCourseOptionsDelegate } from '@core/course/providers/options-delegate';
|
||||
import { CoreCourseProvider } from '@core/course/providers/course';
|
||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
||||
import { CoreCourseFormatDelegate } from '@core/course/providers/format-delegate';
|
||||
|
||||
/**
|
||||
* Page that allows "previewing" a course and enrolling in it if enabled and not enrolled.
|
||||
|
@ -41,6 +42,7 @@ export class CoreCoursesCoursePreviewPage implements OnDestroy {
|
|||
selfEnrolInstances: any[] = [];
|
||||
paypalEnabled: boolean;
|
||||
dataLoaded: boolean;
|
||||
avoidOpenCourse = false;
|
||||
prefetchCourseData = {
|
||||
prefetchCourseIcon: 'spinner',
|
||||
title: 'core.course.downloadcourse'
|
||||
|
@ -67,9 +69,10 @@ export class CoreCoursesCoursePreviewPage implements OnDestroy {
|
|||
private coursesProvider: CoreCoursesProvider, private platform: Platform, private modalCtrl: ModalController,
|
||||
private translate: TranslateService, private eventsProvider: CoreEventsProvider,
|
||||
private courseOptionsDelegate: CoreCourseOptionsDelegate, private courseHelper: CoreCourseHelperProvider,
|
||||
private courseProvider: CoreCourseProvider) {
|
||||
private courseProvider: CoreCourseProvider, private courseFormatDelegate: CoreCourseFormatDelegate) {
|
||||
|
||||
this.course = navParams.get('course');
|
||||
this.avoidOpenCourse = navParams.get('avoidOpenCourse');
|
||||
this.isMobile = appProvider.isMobile();
|
||||
this.isDesktop = appProvider.isDesktop();
|
||||
this.downloadCourseEnabled = !this.coursesProvider.isDownloadCourseDisabledInSite();
|
||||
|
@ -224,11 +227,7 @@ export class CoreCoursesCoursePreviewPage implements OnDestroy {
|
|||
}).catch(() => {
|
||||
// The user is not an admin/manager. Check if we can provide guest access to the course.
|
||||
return this.canAccessAsGuest().then((passwordRequired) => {
|
||||
if (!passwordRequired) {
|
||||
this.canAccessCourse = true;
|
||||
} else {
|
||||
this.canAccessCourse = false;
|
||||
}
|
||||
this.canAccessCourse = !passwordRequired;
|
||||
}).catch(() => {
|
||||
this.canAccessCourse = false;
|
||||
});
|
||||
|
@ -242,12 +241,12 @@ export class CoreCoursesCoursePreviewPage implements OnDestroy {
|
|||
* Open the course.
|
||||
*/
|
||||
openCourse(): void {
|
||||
if (!this.canAccessCourse) {
|
||||
// Course cannot be opened.
|
||||
if (!this.canAccessCourse || this.avoidOpenCourse) {
|
||||
// Course cannot be opened or we are avoiding opening because we accessed from inside a course.
|
||||
return;
|
||||
}
|
||||
|
||||
this.navCtrl.push('CoreCourseSectionPage', { course: this.course });
|
||||
this.courseFormatDelegate.openCourse(this.navCtrl, this.course);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue