commit
b98146f83b
|
@ -68,8 +68,12 @@ export class AddonModAssignModuleHandler implements CoreCourseModuleHandler {
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_assign-handler',
|
class: 'addon-mod_assign-handler',
|
||||||
showDownloadButton: true,
|
showDownloadButton: true,
|
||||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||||
navCtrl.push('AddonModAssignIndexPage', {module: module, courseId: courseId}, options);
|
const pageParams = {module: module, courseId: courseId};
|
||||||
|
if (params) {
|
||||||
|
Object.assign(pageParams, params);
|
||||||
|
}
|
||||||
|
navCtrl.push('AddonModAssignIndexPage', pageParams, options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, Optional, Injector } from '@angular/core';
|
import { Component, Optional, Injector, Input } from '@angular/core';
|
||||||
import { Content, PopoverController } from 'ionic-angular';
|
import { Content, PopoverController } from 'ionic-angular';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
import { CoreAppProvider } from '@providers/app';
|
||||||
import { CoreCourseProvider } from '@core/course/providers/course';
|
import { CoreCourseProvider } from '@core/course/providers/course';
|
||||||
|
@ -29,6 +29,8 @@ import { AddonModBookTocPopoverComponent } from '../../components/toc-popover/to
|
||||||
templateUrl: 'addon-mod-book-index.html',
|
templateUrl: 'addon-mod-book-index.html',
|
||||||
})
|
})
|
||||||
export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComponent {
|
export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComponent {
|
||||||
|
@Input() initialChapterId: string; // The initial chapter ID to load.
|
||||||
|
|
||||||
component = AddonModBookProvider.COMPONENT;
|
component = AddonModBookProvider.COMPONENT;
|
||||||
chapterContent: string;
|
chapterContent: string;
|
||||||
previousChapter: string;
|
previousChapter: string;
|
||||||
|
@ -128,7 +130,19 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp
|
||||||
this.contentsMap = this.bookProvider.getContentsMap(this.module.contents);
|
this.contentsMap = this.bookProvider.getContentsMap(this.module.contents);
|
||||||
this.chapters = this.bookProvider.getTocList(this.module.contents);
|
this.chapters = this.bookProvider.getTocList(this.module.contents);
|
||||||
|
|
||||||
|
if (typeof this.currentChapter == 'undefined' && typeof this.initialChapterId != 'undefined' && this.chapters) {
|
||||||
|
// Initial chapter set. Validate that the chapter exists.
|
||||||
|
const chapter = this.chapters.find((chapter) => {
|
||||||
|
return chapter.id == this.initialChapterId;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (chapter) {
|
||||||
|
this.currentChapter = this.initialChapterId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof this.currentChapter == 'undefined') {
|
if (typeof this.currentChapter == 'undefined') {
|
||||||
|
// Load the first chapter.
|
||||||
this.currentChapter = this.bookProvider.getFirstChapter(this.chapters);
|
this.currentChapter = this.bookProvider.getFirstChapter(this.chapters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,5 +12,5 @@
|
||||||
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
|
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
|
||||||
</ion-refresher>
|
</ion-refresher>
|
||||||
|
|
||||||
<addon-mod-book-index [module]="module" [courseId]="courseId" (dataRetrieved)="updateData($event)"></addon-mod-book-index>
|
<addon-mod-book-index [module]="module" [courseId]="courseId" [initialChapterId]="chapterId" (dataRetrieved)="updateData($event)"></addon-mod-book-index>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|
|
@ -30,10 +30,12 @@ export class AddonModBookIndexPage {
|
||||||
title: string;
|
title: string;
|
||||||
module: any;
|
module: any;
|
||||||
courseId: number;
|
courseId: number;
|
||||||
|
chapterId: number;
|
||||||
|
|
||||||
constructor(navParams: NavParams) {
|
constructor(navParams: NavParams) {
|
||||||
this.module = navParams.get('module') || {};
|
this.module = navParams.get('module') || {};
|
||||||
this.courseId = navParams.get('courseId');
|
this.courseId = navParams.get('courseId');
|
||||||
|
this.chapterId = navParams.get('chapterId');
|
||||||
this.title = this.module.name;
|
this.title = this.module.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler';
|
import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler';
|
||||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
||||||
|
import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler to treat links to book.
|
* Handler to treat links to book.
|
||||||
|
@ -26,4 +27,27 @@ export class AddonModBookLinkHandler extends CoreContentLinksModuleIndexHandler
|
||||||
constructor(courseHelper: CoreCourseHelperProvider) {
|
constructor(courseHelper: CoreCourseHelperProvider) {
|
||||||
super(courseHelper, 'AddonModBook', 'book');
|
super(courseHelper, 'AddonModBook', 'book');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of actions for a link (url).
|
||||||
|
*
|
||||||
|
* @param {string[]} siteIds List of sites the URL belongs to.
|
||||||
|
* @param {string} url The URL to treat.
|
||||||
|
* @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||||
|
* @param {number} [courseId] Course ID related to the URL. Optional but recommended.
|
||||||
|
* @return {CoreContentLinksAction[]|Promise<CoreContentLinksAction[]>} List of (or promise resolved with list of) actions.
|
||||||
|
*/
|
||||||
|
getActions(siteIds: string[], url: string, params: any, courseId?: number):
|
||||||
|
CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
||||||
|
|
||||||
|
const modParams = params.chapterid ? {chapterId: params.chapterid} : undefined;
|
||||||
|
courseId = courseId || params.courseid || params.cid;
|
||||||
|
|
||||||
|
return [{
|
||||||
|
action: (siteId, navCtrl?): void => {
|
||||||
|
this.courseHelper.navigateToModule(parseInt(params.id, 10), siteId, courseId, undefined,
|
||||||
|
this.useModNameToGetModule ? this.modName : undefined, modParams);
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,12 @@ export class AddonModBookModuleHandler implements CoreCourseModuleHandler {
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_book-handler',
|
class: 'addon-mod_book-handler',
|
||||||
showDownloadButton: true,
|
showDownloadButton: true,
|
||||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||||
navCtrl.push('AddonModBookIndexPage', {module: module, courseId: courseId}, options);
|
const pageParams = {module: module, courseId: courseId};
|
||||||
|
if (params) {
|
||||||
|
Object.assign(pageParams, params);
|
||||||
|
}
|
||||||
|
navCtrl.push('AddonModBookIndexPage', pageParams, options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,8 +62,12 @@ export class AddonModChatModuleHandler implements CoreCourseModuleHandler {
|
||||||
icon: this.courseProvider.getModuleIconSrc(this.modName, module.modicon),
|
icon: this.courseProvider.getModuleIconSrc(this.modName, module.modicon),
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_chat-handler',
|
class: 'addon-mod_chat-handler',
|
||||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||||
navCtrl.push('AddonModChatIndexPage', {module: module, courseId: courseId}, options);
|
const pageParams = {module: module, courseId: courseId};
|
||||||
|
if (params) {
|
||||||
|
Object.assign(pageParams, params);
|
||||||
|
}
|
||||||
|
navCtrl.push('AddonModChatIndexPage', pageParams, options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,8 +64,12 @@ export class AddonModChoiceModuleHandler implements CoreCourseModuleHandler {
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_choice-handler',
|
class: 'addon-mod_choice-handler',
|
||||||
showDownloadButton: true,
|
showDownloadButton: true,
|
||||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||||
navCtrl.push('AddonModChoiceIndexPage', {module: module, courseId: courseId}, options);
|
const pageParams = {module: module, courseId: courseId};
|
||||||
|
if (params) {
|
||||||
|
Object.assign(pageParams, params);
|
||||||
|
}
|
||||||
|
navCtrl.push('AddonModChoiceIndexPage', pageParams, options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,8 +67,12 @@ export class AddonModDataModuleHandler implements CoreCourseModuleHandler {
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_data-handler',
|
class: 'addon-mod_data-handler',
|
||||||
showDownloadButton: true,
|
showDownloadButton: true,
|
||||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||||
navCtrl.push('AddonModDataIndexPage', {module: module, courseId: courseId}, options);
|
const pageParams = {module: module, courseId: courseId};
|
||||||
|
if (params) {
|
||||||
|
Object.assign(pageParams, params);
|
||||||
|
}
|
||||||
|
navCtrl.push('AddonModDataIndexPage', pageParams, options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,12 @@ export class AddonModFeedbackModuleHandler implements CoreCourseModuleHandler {
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_feedback-handler',
|
class: 'addon-mod_feedback-handler',
|
||||||
showDownloadButton: true,
|
showDownloadButton: true,
|
||||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||||
navCtrl.push('AddonModFeedbackIndexPage', {module: module, courseId: courseId}, options);
|
const pageParams = {module: module, courseId: courseId};
|
||||||
|
if (params) {
|
||||||
|
Object.assign(pageParams, params);
|
||||||
|
}
|
||||||
|
navCtrl.push('AddonModFeedbackIndexPage', pageParams, options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,8 +64,12 @@ export class AddonModFolderModuleHandler implements CoreCourseModuleHandler {
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_folder-handler',
|
class: 'addon-mod_folder-handler',
|
||||||
showDownloadButton: true,
|
showDownloadButton: true,
|
||||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||||
navCtrl.push('AddonModFolderIndexPage', {module: module, courseId: courseId}, options);
|
const pageParams = {module: module, courseId: courseId};
|
||||||
|
if (params) {
|
||||||
|
Object.assign(pageParams, params);
|
||||||
|
}
|
||||||
|
navCtrl.push('AddonModFolderIndexPage', pageParams, options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,8 +72,12 @@ export class AddonModForumModuleHandler implements CoreCourseModuleHandler {
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_forum-handler',
|
class: 'addon-mod_forum-handler',
|
||||||
showDownloadButton: true,
|
showDownloadButton: true,
|
||||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||||
navCtrl.push('AddonModForumIndexPage', {module: module, courseId: courseId}, options);
|
const pageParams = {module: module, courseId: courseId};
|
||||||
|
if (params) {
|
||||||
|
Object.assign(pageParams, params);
|
||||||
|
}
|
||||||
|
navCtrl.push('AddonModForumIndexPage', pageParams, options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -66,8 +66,12 @@ export class AddonModGlossaryModuleHandler implements CoreCourseModuleHandler {
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_glossary-handler',
|
class: 'addon-mod_glossary-handler',
|
||||||
showDownloadButton: true,
|
showDownloadButton: true,
|
||||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||||
navCtrl.push('AddonModGlossaryIndexPage', {module: module, courseId: courseId}, options);
|
const pageParams = {module: module, courseId: courseId};
|
||||||
|
if (params) {
|
||||||
|
Object.assign(pageParams, params);
|
||||||
|
}
|
||||||
|
navCtrl.push('AddonModGlossaryIndexPage', pageParams, options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,12 @@ export class AddonModImscpModuleHandler implements CoreCourseModuleHandler {
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_imscp-handler',
|
class: 'addon-mod_imscp-handler',
|
||||||
showDownloadButton: true,
|
showDownloadButton: true,
|
||||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||||
navCtrl.push('AddonModImscpIndexPage', {module: module, courseId: courseId}, options);
|
const pageParams = {module: module, courseId: courseId};
|
||||||
|
if (params) {
|
||||||
|
Object.assign(pageParams, params);
|
||||||
|
}
|
||||||
|
navCtrl.push('AddonModImscpIndexPage', pageParams, options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,12 @@ export class AddonModLessonModuleHandler implements CoreCourseModuleHandler {
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_lesson-handler',
|
class: 'addon-mod_lesson-handler',
|
||||||
showDownloadButton: true,
|
showDownloadButton: true,
|
||||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||||
navCtrl.push('AddonModLessonIndexPage', {module: module, courseId: courseId}, options);
|
const pageParams = {module: module, courseId: courseId};
|
||||||
|
if (params) {
|
||||||
|
Object.assign(pageParams, params);
|
||||||
|
}
|
||||||
|
navCtrl.push('AddonModLessonIndexPage', pageParams, options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,8 +74,12 @@ export class AddonModLtiModuleHandler implements CoreCourseModuleHandler {
|
||||||
icon: this.courseProvider.getModuleIconSrc(this.modName, module.modicon),
|
icon: this.courseProvider.getModuleIconSrc(this.modName, module.modicon),
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_lti-handler',
|
class: 'addon-mod_lti-handler',
|
||||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||||
navCtrl.push('AddonModLtiIndexPage', {module: module, courseId: courseId}, options);
|
const pageParams = {module: module, courseId: courseId};
|
||||||
|
if (params) {
|
||||||
|
Object.assign(pageParams, params);
|
||||||
|
}
|
||||||
|
navCtrl.push('AddonModLtiIndexPage', pageParams, options);
|
||||||
},
|
},
|
||||||
buttons: [{
|
buttons: [{
|
||||||
icon: 'link',
|
icon: 'link',
|
||||||
|
|
|
@ -65,8 +65,12 @@ export class AddonModPageModuleHandler implements CoreCourseModuleHandler {
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_page-handler',
|
class: 'addon-mod_page-handler',
|
||||||
showDownloadButton: true,
|
showDownloadButton: true,
|
||||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||||
navCtrl.push('AddonModPageIndexPage', {module: module, courseId: courseId}, options);
|
const pageParams = {module: module, courseId: courseId};
|
||||||
|
if (params) {
|
||||||
|
Object.assign(pageParams, params);
|
||||||
|
}
|
||||||
|
navCtrl.push('AddonModPageIndexPage', pageParams, options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,8 +66,12 @@ export class AddonModQuizModuleHandler implements CoreCourseModuleHandler {
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_quiz-handler',
|
class: 'addon-mod_quiz-handler',
|
||||||
showDownloadButton: true,
|
showDownloadButton: true,
|
||||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||||
navCtrl.push('AddonModQuizIndexPage', {module: module, courseId: courseId}, options);
|
const pageParams = {module: module, courseId: courseId};
|
||||||
|
if (params) {
|
||||||
|
Object.assign(pageParams, params);
|
||||||
|
}
|
||||||
|
navCtrl.push('AddonModQuizIndexPage', pageParams, options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,8 +82,12 @@ export class AddonModResourceModuleHandler implements CoreCourseModuleHandler {
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_resource-handler',
|
class: 'addon-mod_resource-handler',
|
||||||
showDownloadButton: true,
|
showDownloadButton: true,
|
||||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||||
navCtrl.push('AddonModResourceIndexPage', {module: module, courseId: courseId}, options);
|
const pageParams = {module: module, courseId: courseId};
|
||||||
|
if (params) {
|
||||||
|
Object.assign(pageParams, params);
|
||||||
|
}
|
||||||
|
navCtrl.push('AddonModResourceIndexPage', pageParams, options);
|
||||||
},
|
},
|
||||||
updateStatus: updateStatus.bind(this),
|
updateStatus: updateStatus.bind(this),
|
||||||
buttons: [ {
|
buttons: [ {
|
||||||
|
|
|
@ -64,8 +64,12 @@ export class AddonModScormModuleHandler implements CoreCourseModuleHandler {
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_scorm-handler',
|
class: 'addon-mod_scorm-handler',
|
||||||
showDownloadButton: true,
|
showDownloadButton: true,
|
||||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||||
navCtrl.push('AddonModScormIndexPage', {module: module, courseId: courseId}, options);
|
const pageParams = {module: module, courseId: courseId};
|
||||||
|
if (params) {
|
||||||
|
Object.assign(pageParams, params);
|
||||||
|
}
|
||||||
|
navCtrl.push('AddonModScormIndexPage', pageParams, options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,8 +64,12 @@ export class AddonModSurveyModuleHandler implements CoreCourseModuleHandler {
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_survey-handler',
|
class: 'addon-mod_survey-handler',
|
||||||
showDownloadButton: true,
|
showDownloadButton: true,
|
||||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||||
navCtrl.push('AddonModSurveyIndexPage', {module: module, courseId: courseId}, options);
|
const pageParams = {module: module, courseId: courseId};
|
||||||
|
if (params) {
|
||||||
|
Object.assign(pageParams, params);
|
||||||
|
}
|
||||||
|
navCtrl.push('AddonModSurveyIndexPage', pageParams, options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ export class AddonModUrlModuleHandler implements CoreCourseModuleHandler {
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_url-handler',
|
class: 'addon-mod_url-handler',
|
||||||
showDownloadButton: false,
|
showDownloadButton: false,
|
||||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||||
const modal = handler.domUtils.showModalLoading();
|
const modal = handler.domUtils.showModalLoading();
|
||||||
|
|
||||||
// First of all, check if the URL can be handled by the app. If so, always open it directly.
|
// First of all, check if the URL can be handled by the app. If so, always open it directly.
|
||||||
|
@ -100,7 +100,11 @@ export class AddonModUrlModuleHandler implements CoreCourseModuleHandler {
|
||||||
if (shouldOpen) {
|
if (shouldOpen) {
|
||||||
handler.openUrl(module, courseId);
|
handler.openUrl(module, courseId);
|
||||||
} else {
|
} else {
|
||||||
navCtrl.push('AddonModUrlIndexPage', {module: module, courseId: courseId}, options);
|
const pageParams = {module: module, courseId: courseId};
|
||||||
|
if (params) {
|
||||||
|
Object.assign(pageParams, params);
|
||||||
|
}
|
||||||
|
navCtrl.push('AddonModUrlIndexPage', pageParams, options);
|
||||||
}
|
}
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
modal.dismiss();
|
modal.dismiss();
|
||||||
|
|
|
@ -65,8 +65,12 @@ export class AddonModWikiModuleHandler implements CoreCourseModuleHandler {
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_wiki-handler',
|
class: 'addon-mod_wiki-handler',
|
||||||
showDownloadButton: true,
|
showDownloadButton: true,
|
||||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||||
navCtrl.push('AddonModWikiIndexPage', {module: module, courseId: courseId}, options);
|
const pageParams = {module: module, courseId: courseId};
|
||||||
|
if (params) {
|
||||||
|
Object.assign(pageParams, params);
|
||||||
|
}
|
||||||
|
navCtrl.push('AddonModWikiIndexPage', pageParams, options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,8 +64,12 @@ export class AddonModWorkshopModuleHandler implements CoreCourseModuleHandler {
|
||||||
title: module.name,
|
title: module.name,
|
||||||
class: 'addon-mod_workshop-handler',
|
class: 'addon-mod_workshop-handler',
|
||||||
showDownloadButton: true,
|
showDownloadButton: true,
|
||||||
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions): void {
|
action(event: Event, navCtrl: NavController, module: any, courseId: number, options: NavOptions, params?: any): void {
|
||||||
navCtrl.push('AddonModWorkshopIndexPage', {module: module, courseId: courseId}, options);
|
const pageParams = {module: module, courseId: courseId};
|
||||||
|
if (params) {
|
||||||
|
Object.assign(pageParams, params);
|
||||||
|
}
|
||||||
|
navCtrl.push('AddonModWorkshopIndexPage', pageParams, options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@ export class CoreCourseSectionPage implements OnDestroy {
|
||||||
displayRefresher: boolean;
|
displayRefresher: boolean;
|
||||||
|
|
||||||
protected module: any;
|
protected module: any;
|
||||||
|
protected modParams: any;
|
||||||
protected completionObserver;
|
protected completionObserver;
|
||||||
protected courseStatusObserver;
|
protected courseStatusObserver;
|
||||||
protected syncObserver;
|
protected syncObserver;
|
||||||
|
@ -80,6 +81,7 @@ export class CoreCourseSectionPage implements OnDestroy {
|
||||||
this.sectionNumber = navParams.get('sectionNumber');
|
this.sectionNumber = navParams.get('sectionNumber');
|
||||||
this.module = navParams.get('module');
|
this.module = navParams.get('module');
|
||||||
this.firstTabName = navParams.get('selectedTab');
|
this.firstTabName = navParams.get('selectedTab');
|
||||||
|
this.modParams = navParams.get('modParams');
|
||||||
|
|
||||||
// Get the title to display. We dont't have sections yet.
|
// Get the title to display. We dont't have sections yet.
|
||||||
this.title = courseFormatDelegate.getCourseTitle(this.course);
|
this.title = courseFormatDelegate.getCourseTitle(this.course);
|
||||||
|
@ -124,7 +126,7 @@ export class CoreCourseSectionPage implements OnDestroy {
|
||||||
|
|
||||||
if (this.module) {
|
if (this.module) {
|
||||||
this.moduleId = this.module.id;
|
this.moduleId = this.module.id;
|
||||||
this.courseHelper.openModule(this.navCtrl, this.module, this.course.id, this.sectionId);
|
this.courseHelper.openModule(this.navCtrl, this.module, this.course.id, this.sectionId, this.modParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loadData(false, true).finally(() => {
|
this.loadData(false, true).finally(() => {
|
||||||
|
|
|
@ -1007,9 +1007,11 @@ export class CoreCourseHelperProvider {
|
||||||
* @param {number} [sectionId] Section the module belongs to. If not defined we'll try to retrieve it from the site.
|
* @param {number} [sectionId] Section the module belongs to. If not defined we'll try to retrieve it from the site.
|
||||||
* @param {string} [modName] If set, the app will retrieve all modules of this type with a single WS call. This reduces the
|
* @param {string} [modName] If set, the app will retrieve all modules of this type with a single WS call. This reduces the
|
||||||
* number of WS calls, but it isn't recommended for modules that can return a lot of contents.
|
* number of WS calls, but it isn't recommended for modules that can return a lot of contents.
|
||||||
|
* @param {any} [modParams] Params to pass to the module
|
||||||
* @return {Promise<void>} Promise resolved when done.
|
* @return {Promise<void>} Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
navigateToModule(moduleId: number, siteId?: string, courseId?: number, sectionId?: number, modName?: string): Promise<void> {
|
navigateToModule(moduleId: number, siteId?: string, courseId?: number, sectionId?: number, modName?: string, modParams?: any)
|
||||||
|
: Promise<void> {
|
||||||
siteId = siteId || this.sitesProvider.getCurrentSiteId();
|
siteId = siteId || this.sitesProvider.getCurrentSiteId();
|
||||||
|
|
||||||
const modal = this.domUtils.showModalLoading();
|
const modal = this.domUtils.showModalLoading();
|
||||||
|
@ -1048,7 +1050,8 @@ export class CoreCourseHelperProvider {
|
||||||
const params = {
|
const params = {
|
||||||
course: { id: courseId },
|
course: { id: courseId },
|
||||||
module: module,
|
module: module,
|
||||||
sectionId: sectionId
|
sectionId: sectionId,
|
||||||
|
modParams: modParams
|
||||||
};
|
};
|
||||||
|
|
||||||
module.handlerData = this.moduleDelegate.getModuleDataFor(module.modname, module, courseId, sectionId);
|
module.handlerData = this.moduleDelegate.getModuleDataFor(module.modname, module, courseId, sectionId);
|
||||||
|
@ -1075,15 +1078,16 @@ export class CoreCourseHelperProvider {
|
||||||
* @param {any} module The module to open.
|
* @param {any} module The module to open.
|
||||||
* @param {number} courseId The course ID of the module.
|
* @param {number} courseId The course ID of the module.
|
||||||
* @param {number} [sectionId] The section ID of the module.
|
* @param {number} [sectionId] The section ID of the module.
|
||||||
|
* @param {any} [modParams] Params to pass to the module
|
||||||
* @param {boolean} True if module can be opened, false otherwise.
|
* @param {boolean} True if module can be opened, false otherwise.
|
||||||
*/
|
*/
|
||||||
openModule(navCtrl: NavController, module: any, courseId: number, sectionId?: number): boolean {
|
openModule(navCtrl: NavController, module: any, courseId: number, sectionId?: number, modParams?: any): boolean {
|
||||||
if (!module.handlerData) {
|
if (!module.handlerData) {
|
||||||
module.handlerData = this.moduleDelegate.getModuleDataFor(module.modname, module, courseId, sectionId);
|
module.handlerData = this.moduleDelegate.getModuleDataFor(module.modname, module, courseId, sectionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (module.handlerData && module.handlerData.action) {
|
if (module.handlerData && module.handlerData.action) {
|
||||||
module.handlerData.action(new Event('click'), navCtrl, module, courseId, { animate: false });
|
module.handlerData.action(new Event('click'), navCtrl, module, courseId, { animate: false }, modParams);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,8 +156,9 @@ export interface CoreCourseModuleHandlerData {
|
||||||
* @param {any} module The module object.
|
* @param {any} module The module object.
|
||||||
* @param {number} courseId The course ID.
|
* @param {number} courseId The course ID.
|
||||||
* @param {NavOptions} [options] Options for the navigation.
|
* @param {NavOptions} [options] Options for the navigation.
|
||||||
|
* @param {any} [params] Params for the new page.
|
||||||
*/
|
*/
|
||||||
action?(event: Event, navCtrl: NavController, module: any, courseId: number, options?: NavOptions): void;
|
action?(event: Event, navCtrl: NavController, module: any, courseId: number, options?: NavOptions, params?: any): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the status of the module.
|
* Updates the status of the module.
|
||||||
|
|
|
@ -31,9 +31,11 @@ export class CoreSiteHomeIndexPage {
|
||||||
|
|
||||||
constructor(navParams: NavParams, navCtrl: NavController, courseHelper: CoreCourseHelperProvider,
|
constructor(navParams: NavParams, navCtrl: NavController, courseHelper: CoreCourseHelperProvider,
|
||||||
sitesProvider: CoreSitesProvider) {
|
sitesProvider: CoreSitesProvider) {
|
||||||
const module = navParams.get('module');
|
const module = navParams.get('module'),
|
||||||
|
modParams = navParams.get('modParams');
|
||||||
|
|
||||||
if (module) {
|
if (module) {
|
||||||
courseHelper.openModule(navCtrl, module, sitesProvider.getCurrentSite().getSiteHomeId());
|
courseHelper.openModule(navCtrl, module, sitesProvider.getCurrentSite().getSiteHomeId(), undefined, modParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue