2021-02-16 11:18:12 +01:00
|
|
|
// (C) Copyright 2015 Moodle Pty Ltd.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
|
import { CoreNavigator } from '@services/navigator';
|
2021-03-04 10:34:06 +01:00
|
|
|
import { CoreCourseAnyModuleData } from '../services/course';
|
|
|
|
import { CoreCourseModuleMainResourceComponent } from './main-resource-component';
|
2021-02-16 11:18:12 +01:00
|
|
|
|
2021-03-04 10:34:06 +01:00
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Template class to easily create CoreCourseModuleMainComponent of resources (or activities without syncing).
|
|
|
|
*/
|
2021-02-16 11:18:12 +01:00
|
|
|
@Component({
|
2021-03-04 10:34:06 +01:00
|
|
|
template: '',
|
2021-02-16 11:18:12 +01:00
|
|
|
})
|
2021-03-04 10:34:06 +01:00
|
|
|
export class CoreCourseModuleMainActivityPage<ActivityType extends CoreCourseModuleMainResourceComponent> implements OnInit {
|
|
|
|
|
|
|
|
activityComponent?: ActivityType;
|
2021-02-16 11:18:12 +01:00
|
|
|
|
|
|
|
title!: string;
|
|
|
|
module!: CoreCourseAnyModuleData;
|
|
|
|
courseId!: number;
|
|
|
|
|
|
|
|
/**
|
2021-03-04 10:34:06 +01:00
|
|
|
* Component being initialized.
|
2021-02-16 11:18:12 +01:00
|
|
|
*/
|
|
|
|
ngOnInit(): void {
|
2021-03-02 11:41:04 +01:00
|
|
|
this.module = CoreNavigator.getRouteParam<CoreCourseAnyModuleData>('module')!;
|
|
|
|
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
2021-02-16 11:18:12 +01:00
|
|
|
this.title = this.module?.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-03-04 10:34:06 +01:00
|
|
|
* Update some data based on the activity instance.
|
2021-02-16 11:18:12 +01:00
|
|
|
*
|
2021-03-04 10:34:06 +01:00
|
|
|
* @param activity Activity instance.
|
|
|
|
*/
|
|
|
|
updateData(activity: { name: string}): void {
|
|
|
|
this.title = activity.name || this.title;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* User entered the page.
|
|
|
|
*/
|
|
|
|
ionViewDidEnter(): void {
|
|
|
|
this.activityComponent?.ionViewDidEnter();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* User left the page.
|
2021-02-16 11:18:12 +01:00
|
|
|
*/
|
2021-03-04 10:34:06 +01:00
|
|
|
ionViewDidLeave(): void {
|
|
|
|
this.activityComponent?.ionViewDidLeave();
|
2021-02-16 11:18:12 +01:00
|
|
|
}
|
|
|
|
|
2021-06-16 12:09:05 +02:00
|
|
|
/**
|
|
|
|
* User will enter the page.
|
|
|
|
*/
|
|
|
|
ionViewWillEnter(): void {
|
|
|
|
this.activityComponent?.ionViewWillEnter();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* User will leave the page.
|
|
|
|
*/
|
|
|
|
ionViewWillLeave(): void {
|
|
|
|
this.activityComponent?.ionViewWillLeave();
|
|
|
|
}
|
|
|
|
|
2021-02-16 11:18:12 +01:00
|
|
|
}
|