MOBILE-3629 course: Add courseId param to course route
parent
70809d79ec
commit
cbdcb8bd8f
|
@ -19,8 +19,8 @@ import { conditionalRoutes } from '@/app/app-routing.module';
|
|||
import { CoreScreen } from '@services/screen';
|
||||
import { CoreSharedModule } from '@/core/shared.module';
|
||||
|
||||
import { AddonBadgesIssuedBadgePage } from './pages/issued-badge/issued-badge';
|
||||
import { AddonBadgesUserBadgesPage } from './pages/user-badges/user-badges';
|
||||
import { AddonBadgesIssuedBadgePage } from './pages/issued-badge/issued-badge.page';
|
||||
import { AddonBadgesUserBadgesPage } from './pages/user-badges/user-badges.page';
|
||||
|
||||
const mobileRoutes: Routes = [
|
||||
{
|
||||
|
|
|
@ -20,8 +20,9 @@ import { CoreDomUtils } from '@services/utils/dom';
|
|||
import { CoreSites } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CorePageItemsListManager } from '@classes/page-items-list-manager';
|
||||
import { ActivatedRoute, ActivatedRouteSnapshot, Params } from '@angular/router';
|
||||
import { ActivatedRouteSnapshot, Params } from '@angular/router';
|
||||
import { CoreSplitViewComponent } from '@components/split-view/split-view';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
|
||||
/**
|
||||
* Page that displays the list of calendar events.
|
||||
|
@ -37,9 +38,9 @@ export class AddonBadgesUserBadgesPage implements AfterViewInit, OnDestroy {
|
|||
|
||||
@ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent;
|
||||
|
||||
constructor(route: ActivatedRoute) {
|
||||
const courseId = parseInt(route.snapshot.queryParams.courseId ?? 0); // Use 0 for site badges.
|
||||
const userId = parseInt(route.snapshot.queryParams.userId ?? CoreSites.getCurrentSiteUserId());
|
||||
constructor() {
|
||||
const courseId = CoreNavigator.getRouteNumberParam('courseId') ?? 0; // Use 0 for site badges.
|
||||
const userId = CoreNavigator.getRouteNumberParam('userId') ?? CoreSites.getCurrentSiteUserId();
|
||||
|
||||
this.badges = new AddonBadgesUserBadgesManager(AddonBadgesUserBadgesPage, courseId, userId);
|
||||
}
|
|
@ -131,9 +131,8 @@ export class AddonBlockActivityModulesComponent extends CoreBlockBaseComponent i
|
|||
* @param entry Selected entry.
|
||||
*/
|
||||
gotoCoureListModType(entry: AddonBlockActivityModuleEntry): void {
|
||||
CoreNavigator.navigateToSitePath('course/list-mod-type', {
|
||||
CoreNavigator.navigateToSitePath('course/' + this.getCourseId() + '/list-mod-type', {
|
||||
params: {
|
||||
courseId: this.getCourseId(),
|
||||
modName: entry.modName,
|
||||
title: entry.name,
|
||||
},
|
||||
|
|
|
@ -61,9 +61,8 @@ export class CoreContentLinksModuleListHandler extends CoreContentLinksHandlerBa
|
|||
|
||||
return [{
|
||||
action: (siteId): void => {
|
||||
CoreNavigator.navigateToSitePath('course/list-mod-type', {
|
||||
CoreNavigator.navigateToSitePath('course/' + params.id + '/list-mod-type', {
|
||||
params: {
|
||||
courseId: params.id,
|
||||
modName: this.modName,
|
||||
title: this.title || Translate.instant('addon.mod_' + this.modName + '.modulenameplural'),
|
||||
},
|
||||
|
|
|
@ -22,18 +22,23 @@ const routes: Routes = [
|
|||
pathMatch: 'full',
|
||||
},
|
||||
{
|
||||
path: 'index',
|
||||
path: ':courseId',
|
||||
loadChildren: () => import('./pages/index/index.module').then( m => m.CoreCourseIndexPageModule),
|
||||
},
|
||||
{
|
||||
path: 'unsupported-module',
|
||||
path: ':courseId/unsupported-module',
|
||||
loadChildren: () => import('./pages/unsupported-module/unsupported-module.module')
|
||||
.then( m => m.CoreCourseUnsupportedModulePageModule),
|
||||
},
|
||||
{
|
||||
path: 'list-mod-type',
|
||||
path: ':courseId/list-mod-type',
|
||||
loadChildren: () => import('./pages/list-mod-type/list-mod-type.module').then(m => m.CoreCourseListModTypePageModule),
|
||||
},
|
||||
{
|
||||
path: ':courseId/preview',
|
||||
loadChildren: () =>
|
||||
import('./pages/preview/preview.module').then(m => m.CoreCoursePreviewPageModule),
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
|
|
@ -460,7 +460,10 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy {
|
|||
* Open the course summary
|
||||
*/
|
||||
openCourseSummary(): void {
|
||||
CoreNavigator.navigateToSitePath('/courses/preview', { params: { course: this.course, avoidOpenCourse: true } });
|
||||
CoreNavigator.navigateToSitePath(
|
||||
'/course/' + this.course.id + '/preview',
|
||||
{ params: { course: this.course, avoidOpenCourse: true } },
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,7 @@ import { RouterModule, ROUTES, Routes } from '@angular/router';
|
|||
|
||||
import { resolveModuleRoutes } from '@/app/app-routing.module';
|
||||
import { CoreSharedModule } from '@/core/shared.module';
|
||||
import { CoreCourseIndexPage } from './index';
|
||||
import { CoreCourseIndexPage } from './index.page';
|
||||
import { COURSE_INDEX_ROUTES } from './index-routing.module';
|
||||
|
||||
function buildRoutes(injector: Injector): Routes {
|
||||
|
|
|
@ -123,7 +123,6 @@ export class CoreCourseIndexPage implements OnInit, OnDestroy {
|
|||
handlers.forEach((handler, index) => {
|
||||
handler.data.page = CoreTextUtils.concatenatePaths(this.currentPagePath, handler.data.page);
|
||||
handler.data.pageParams = handler.data.pageParams || {};
|
||||
handler.data.pageParams.courseId = this.course!.id;
|
||||
|
||||
// Check if this handler should be the first selected tab.
|
||||
if (this.firstTabName && handler.name == this.firstTabName) {
|
|
@ -16,7 +16,7 @@ import { NgModule } from '@angular/core';
|
|||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
||||
import { CoreSharedModule } from '@/core/shared.module';
|
||||
import { CoreCourseListModTypePage } from './list-mod-type';
|
||||
import { CoreCourseListModTypePage } from './list-mod-type.page';
|
||||
import { CoreCourseComponentsModule } from '@features/course/components/components.module';
|
||||
|
||||
const routes: Routes = [
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
|
||||
</ion-refresher>
|
||||
<core-loading [hideUntil]="dataLoaded">
|
||||
<div class="core-course-thumb-parallax">
|
||||
<div *ngIf="courseImageUrl" (click)="openCourse()" class="core-course-thumb">
|
||||
<div *ngIf="courseImageUrl" class="core-course-thumb-parallax">
|
||||
<div (click)="openCourse()" class="core-course-thumb">
|
||||
<img [src]="courseImageUrl" core-external-content alt=""/>
|
||||
</div>
|
||||
</div>
|
|
@ -16,13 +16,12 @@ import { NgModule } from '@angular/core';
|
|||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
||||
import { CoreSharedModule } from '@/core/shared.module';
|
||||
import { CoreCoursesCoursePreviewPage } from './course-preview';
|
||||
import { CoreCoursesComponentsModule } from '../../components/components.module';
|
||||
import { CoreCoursePreviewPage } from './preview.page';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: CoreCoursesCoursePreviewPage,
|
||||
component: CoreCoursePreviewPage,
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -30,11 +29,10 @@ const routes: Routes = [
|
|||
imports: [
|
||||
RouterModule.forChild(routes),
|
||||
CoreSharedModule,
|
||||
CoreCoursesComponentsModule,
|
||||
],
|
||||
declarations: [
|
||||
CoreCoursesCoursePreviewPage,
|
||||
CoreCoursePreviewPage,
|
||||
],
|
||||
exports: [RouterModule],
|
||||
})
|
||||
export class CoreCoursesCoursePreviewPageModule { }
|
||||
export class CoreCoursePreviewPageModule { }
|
|
@ -15,7 +15,7 @@
|
|||
import { Component, OnDestroy, NgZone, OnInit } from '@angular/core';
|
||||
import { ModalController, IonRefresher } from '@ionic/angular';
|
||||
import { CoreApp } from '@services/app';
|
||||
import { CoreEventCourseStatusChanged, CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreTextUtils } from '@services/utils/text';
|
||||
|
@ -32,18 +32,18 @@ import { CoreCourse, CoreCourseProvider } from '@features/course/services/course
|
|||
import { CoreCourseHelper, CorePrefetchStatusInfo } from '@features/course/services/course-helper';
|
||||
import { Translate } from '@singletons';
|
||||
import { CoreConstants } from '@/core/constants';
|
||||
import { CoreCoursesSelfEnrolPasswordComponent } from '../../components/self-enrol-password/self-enrol-password';
|
||||
import { CoreCoursesSelfEnrolPasswordComponent } from '../../../courses/components/self-enrol-password/self-enrol-password';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
|
||||
/**
|
||||
* Page that allows "previewing" a course and enrolling in it if enabled and not enrolled.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'page-core-courses-course-preview',
|
||||
templateUrl: 'course-preview.html',
|
||||
styleUrls: ['course-preview.scss'],
|
||||
selector: 'page-core-course-preview',
|
||||
templateUrl: 'preview.html',
|
||||
styleUrls: ['preview.scss'],
|
||||
})
|
||||
export class CoreCoursesCoursePreviewPage implements OnInit, OnDestroy {
|
||||
export class CoreCoursePreviewPage implements OnInit, OnDestroy {
|
||||
|
||||
course?: CoreCourseSearchedData;
|
||||
isEnrolled = false;
|
||||
|
@ -84,7 +84,7 @@ export class CoreCoursesCoursePreviewPage implements OnInit, OnDestroy {
|
|||
|
||||
if (this.downloadCourseEnabled) {
|
||||
// Listen for status change in course.
|
||||
this.courseStatusObserver = CoreEvents.on(CoreEvents.COURSE_STATUS_CHANGED, (data: CoreEventCourseStatusChanged) => {
|
||||
this.courseStatusObserver = CoreEvents.on(CoreEvents.COURSE_STATUS_CHANGED, (data) => {
|
||||
if (data.courseId == this.course!.id || data.courseId == CoreCourseProvider.ALL_COURSES_CLEARED) {
|
||||
this.updateCourseStatus(data.status);
|
||||
}
|
|
@ -16,7 +16,7 @@ import { NgModule } from '@angular/core';
|
|||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
||||
import { CoreSharedModule } from '@/core/shared.module';
|
||||
import { CoreCourseUnsupportedModulePage } from './unsupported-module';
|
||||
import { CoreCourseUnsupportedModulePage } from './unsupported-module.page';
|
||||
import { CoreCourseComponentsModule } from '@features/course/components/components.module';
|
||||
|
||||
const routes: Routes = [
|
||||
|
|
|
@ -1848,7 +1848,7 @@ export class CoreCourseHelperProvider {
|
|||
params = params || {};
|
||||
Object.assign(params, { course: course });
|
||||
|
||||
await CoreNavigator.navigateToSitePath('course', { siteId, params });
|
||||
await CoreNavigator.navigateToSitePath('course/' + course.id, { siteId, params });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ export class CoreCourseFormatDefaultHandler implements CoreCourseFormatHandler {
|
|||
Object.assign(params, { course: course });
|
||||
|
||||
// Don't return the .push promise, we don't want to display a loading modal during the page transition.
|
||||
CoreNavigator.navigateToSitePath('course', { params });
|
||||
CoreNavigator.navigateToSitePath('course/' + course.id, { params });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -64,9 +64,9 @@ export class CoreCourseModuleDefaultHandler implements CoreCourseModuleHandler {
|
|||
event.stopPropagation();
|
||||
|
||||
options = options || {};
|
||||
options.params = { module, courseId };
|
||||
options.params = { module };
|
||||
|
||||
CoreNavigator.navigateToSitePath('course/unsupported-module', options);
|
||||
CoreNavigator.navigateToSitePath('course/' + courseId + '/unsupported-module', options);
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -94,7 +94,10 @@ export class CoreCoursesCourseListItemComponent implements OnInit {
|
|||
if (this.isEnrolled) {
|
||||
CoreCourseHelper.openCourse(this.course);
|
||||
} else {
|
||||
CoreNavigator.navigate('courses/preview', { params: { course: this.course } });
|
||||
CoreNavigator.navigate(
|
||||
'/course/' + this.course.id + '/preview',
|
||||
{ params: { course: this.course } },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,12 +50,6 @@ const routes: Routes = [
|
|||
import('./pages/my-courses/my-courses.module')
|
||||
.then(m => m.CoreCoursesMyCoursesPageModule),
|
||||
},
|
||||
{
|
||||
path: 'preview',
|
||||
loadChildren: () =>
|
||||
import('./pages/course-preview/course-preview.module')
|
||||
.then(m => m.CoreCoursesCoursePreviewPageModule),
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
|
|
@ -59,18 +59,14 @@ export class CoreCoursesEnrolPushClickHandlerService implements CorePushNotifica
|
|||
const params: Params = {
|
||||
course: result.course,
|
||||
};
|
||||
let page: string;
|
||||
let page = 'course/' + courseId;
|
||||
|
||||
if (notification.contexturl?.indexOf('user/index.php') != -1) {
|
||||
// Open the participants tab.
|
||||
page = 'course';
|
||||
params.selectedTab = 'user_participants'; // @todo: Set this when participants is done.
|
||||
} else if (result.enrolled) {
|
||||
// User is still enrolled, open the course.
|
||||
page = 'course';
|
||||
} else {
|
||||
params.selectedTab = 'participants'; // @todo: Set this when participants is done.
|
||||
} else if (!result.enrolled) {
|
||||
// User not enrolled anymore, open the preview page.
|
||||
page = 'courses/preview';;
|
||||
page += '/preview';
|
||||
}
|
||||
|
||||
await CoreNavigator.navigateToSitePath(page, { params, siteId: notification.site });
|
||||
|
|
|
@ -75,14 +75,11 @@ export class CoreCoursesRequestPushClickHandlerService implements CorePushNotifi
|
|||
const params: Params = {
|
||||
course: result.course,
|
||||
};
|
||||
let page: string;
|
||||
let page = 'course/' + courseId;
|
||||
|
||||
if (result.enrolled) {
|
||||
// User is still enrolled, open the course.
|
||||
page = 'course';
|
||||
} else {
|
||||
if (!result.enrolled) {
|
||||
// User not enrolled (shouldn't happen), open the preview page.
|
||||
page = 'courses/preview';
|
||||
page += '/preview';
|
||||
}
|
||||
|
||||
await CoreNavigator.navigateToSitePath(page, { params, siteId: notification.site });
|
||||
|
|
|
@ -21,8 +21,8 @@ import { CoreSharedModule } from '@/core/shared.module';
|
|||
|
||||
import { CoreGradesCoursePage } from './pages/course/course.page';
|
||||
import { CoreGradesCoursePageModule } from './pages/course/course.module';
|
||||
import { CoreGradesCoursesPage } from './pages/courses/courses';
|
||||
import { CoreGradesGradePage } from './pages/grade/grade';
|
||||
import { CoreGradesCoursesPage } from './pages/courses/courses.page';
|
||||
import { CoreGradesGradePage } from './pages/grade/grade.page';
|
||||
|
||||
const mobileRoutes: Routes = [
|
||||
{
|
||||
|
|
|
@ -16,10 +16,11 @@ import { AfterViewInit, Component, OnDestroy, ViewChild } from '@angular/core';
|
|||
import { ActivatedRouteSnapshot } from '@angular/router';
|
||||
import { CorePageItemsListManager } from '@classes/page-items-list-manager';
|
||||
|
||||
import { CoreSplitViewComponent } from '@components/split-view/split-view';
|
||||
import { CoreSplitViewComponent, CoreSplitViewMode } from '@components/split-view/split-view';
|
||||
import { CoreGrades } from '@features/grades/services/grades';
|
||||
import { CoreGradesGradeOverviewWithCourseData, CoreGradesHelper } from '@features/grades/services/grades-helper';
|
||||
import { IonRefresher } from '@ionic/angular';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
||||
|
@ -33,13 +34,27 @@ import { CoreUtils } from '@services/utils/utils';
|
|||
export class CoreGradesCoursesPage implements OnDestroy, AfterViewInit {
|
||||
|
||||
courses: CoreGradesCoursesManager = new CoreGradesCoursesManager(CoreGradesCoursesPage);
|
||||
splitViewMode?: CoreSplitViewMode;
|
||||
|
||||
@ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent;
|
||||
|
||||
constructor() {
|
||||
const userId = CoreNavigator.getRouteNumberParam('userId');
|
||||
const courseId = CoreNavigator.getRouteNumberParam('courseId');
|
||||
|
||||
// If courseId and userId is set, show only the content page.
|
||||
this.splitViewMode = courseId && userId ? undefined : CoreSplitViewMode.ContentOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
async ngAfterViewInit(): Promise<void> {
|
||||
if (this.splitViewMode) {
|
||||
// Won't be shown, do nothing.
|
||||
return;
|
||||
}
|
||||
|
||||
await this.fetchInitialCourses();
|
||||
|
||||
this.courses.start(this.splitView);
|
|
@ -11,7 +11,7 @@
|
|||
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
|
||||
</ion-refresher>
|
||||
<core-loading [hideUntil]="gradeLoaded">
|
||||
<core-empty-box *ngIf="!grade" icon="stats" [message]="'core.grades.nogradesreturned' | translate"></core-empty-box>
|
||||
<core-empty-box *ngIf="!grade" icon="fas-chart-bar" [message]="'core.grades.nogradesreturned' | translate"></core-empty-box>
|
||||
|
||||
<ion-list *ngIf="grade">
|
||||
<ion-item *ngIf="grade.itemname && grade.link" class="ion-text-wrap" detail="true" [href]="grade.link" core-link
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { IonRefresher } from '@ionic/angular';
|
||||
|
||||
|
@ -21,6 +20,7 @@ import { CoreGrades } from '@features/grades/services/grades';
|
|||
import { CoreGradesFormattedRow, CoreGradesHelper } from '@features/grades/services/grades-helper';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
|
||||
/**
|
||||
* Page that displays activity grade.
|
||||
|
@ -37,10 +37,10 @@ export class CoreGradesGradePage implements OnInit {
|
|||
grade?: CoreGradesFormattedRow | null;
|
||||
gradeLoaded = false;
|
||||
|
||||
constructor(route: ActivatedRoute) {
|
||||
this.courseId = parseInt(route.snapshot.params.courseId ?? route.snapshot.parent?.params.courseId);
|
||||
this.gradeId = parseInt(route.snapshot.params.gradeId);
|
||||
this.userId = parseInt(route.snapshot.queryParams.userId ?? CoreSites.getCurrentSiteUserId());
|
||||
constructor() {
|
||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
||||
this.gradeId = CoreNavigator.getRouteNumberParam('gradeId')!;
|
||||
this.userId = CoreNavigator.getRouteNumberParam('userId') ?? CoreSites.getCurrentSiteUserId();
|
||||
}
|
||||
|
||||
/**
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { ActivatedRoute, ActivatedRouteSnapshot } from '@angular/router';
|
||||
import { ActivatedRouteSnapshot } from '@angular/router';
|
||||
import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||
import { IonRefresher } from '@ionic/angular';
|
||||
|
||||
|
@ -43,8 +43,8 @@ export class CoreUserParticipantsPage implements OnInit, AfterViewInit, OnDestro
|
|||
|
||||
@ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent;
|
||||
|
||||
constructor(route: ActivatedRoute) {
|
||||
const courseId = parseInt(route.snapshot.queryParams.courseId);
|
||||
constructor() {
|
||||
const courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
||||
|
||||
this.participants = new CoreUserParticipantsManager(CoreUserParticipantsPage, courseId);
|
||||
}
|
|
@ -18,7 +18,7 @@ import { RouterModule, Routes } from '@angular/router';
|
|||
import { CoreSharedModule } from '@/core/shared.module';
|
||||
import { CoreSearchComponentsModule } from '@features/search/components/components.module';
|
||||
|
||||
import { CoreUserParticipantsPage } from './pages/participants/participants';
|
||||
import { CoreUserParticipantsPage } from './pages/participants/participants.page';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue