forked from EVOgeek/Vmeda.Online
		
	MOBILE-3649 mod: Make module and courseId required in index components
This commit is contained in:
		
							parent
							
								
									3dc1834a6b
								
							
						
					
					
						commit
						2a077f4e62
					
				| @ -35,7 +35,7 @@ | |||||||
|         <ion-item class="ion-text-wrap"> |         <ion-item class="ion-text-wrap"> | ||||||
|             <ion-label> |             <ion-label> | ||||||
|                 <core-format-text [text]="description" [component]="component" [componentId]="componentId" maxHeight="120" |                 <core-format-text [text]="description" [component]="component" [componentId]="componentId" maxHeight="120" | ||||||
|                     contextLevel="module" [contextInstanceId]="module!.id" [courseId]="courseId" (click)="expandDescription($event)"> |                     contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId" (click)="expandDescription($event)"> | ||||||
|                 </core-format-text> |                 </core-format-text> | ||||||
|             </ion-label> |             </ion-label> | ||||||
|         </ion-item> |         </ion-item> | ||||||
| @ -136,7 +136,7 @@ | |||||||
| 
 | 
 | ||||||
|     <!-- If it's a student, display his submission. --> |     <!-- If it's a student, display his submission. --> | ||||||
|     <addon-mod-assign-submission *ngIf="loaded && !canViewAllSubmissions && canViewOwnSubmission" [courseId]="courseId" |     <addon-mod-assign-submission *ngIf="loaded && !canViewAllSubmissions && canViewOwnSubmission" [courseId]="courseId" | ||||||
|         [moduleId]="module!.id"> |         [moduleId]="module.id"> | ||||||
|     </addon-mod-assign-submission> |     </addon-mod-assign-submission> | ||||||
| 
 | 
 | ||||||
| </core-loading> | </core-loading> | ||||||
|  | |||||||
| @ -120,7 +120,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo | |||||||
|             (data) => { |             (data) => { | ||||||
|                 if (this.assign && data.assignmentId == this.assign.id && data.userId == this.currentUserId) { |                 if (this.assign && data.assignmentId == this.assign.id && data.userId == this.currentUserId) { | ||||||
|                 // Assignment submitted, check completion.
 |                 // Assignment submitted, check completion.
 | ||||||
|                     CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata); |                     CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata); | ||||||
| 
 | 
 | ||||||
|                     // Reload data since it can have offline data now.
 |                     // Reload data since it can have offline data now.
 | ||||||
|                     this.showLoadingAndRefresh(true, false); |                     this.showLoadingAndRefresh(true, false); | ||||||
| @ -140,7 +140,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo | |||||||
| 
 | 
 | ||||||
|         try { |         try { | ||||||
|             await AddonModAssign.logView(this.assign!.id, this.assign!.name); |             await AddonModAssign.logView(this.assign!.id, this.assign!.name); | ||||||
|             CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata); |             CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata); | ||||||
|         } catch { |         } catch { | ||||||
|             // Ignore errors. Just don't check Module completion.
 |             // Ignore errors. Just don't check Module completion.
 | ||||||
|         } |         } | ||||||
| @ -164,11 +164,11 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo | |||||||
|         if (this.assign && (this.description || this.assign.introattachments)) { |         if (this.assign && (this.description || this.assign.introattachments)) { | ||||||
|             CoreTextUtils.viewText(Translate.instant('core.description'), this.description || '', { |             CoreTextUtils.viewText(Translate.instant('core.description'), this.description || '', { | ||||||
|                 component: this.component, |                 component: this.component, | ||||||
|                 componentId: this.module!.id, |                 componentId: this.module.id, | ||||||
|                 files: this.assign.introattachments, |                 files: this.assign.introattachments, | ||||||
|                 filter: true, |                 filter: true, | ||||||
|                 contextLevel: 'module', |                 contextLevel: 'module', | ||||||
|                 instanceId: this.module!.id, |                 instanceId: this.module.id, | ||||||
|                 courseId: this.courseId, |                 courseId: this.courseId, | ||||||
|             }); |             }); | ||||||
|         } |         } | ||||||
| @ -186,7 +186,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo | |||||||
| 
 | 
 | ||||||
|         // Get assignment data.
 |         // Get assignment data.
 | ||||||
|         try { |         try { | ||||||
|             this.assign = await AddonModAssign.getAssignment(this.courseId!, this.module!.id); |             this.assign = await AddonModAssign.getAssignment(this.courseId, this.module.id); | ||||||
| 
 | 
 | ||||||
|             this.dataRetrieved.emit(this.assign); |             this.dataRetrieved.emit(this.assign); | ||||||
|             this.description = this.assign.intro; |             this.description = this.assign.intro; | ||||||
| @ -200,7 +200,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo | |||||||
|             this.hasOffline = await AddonModAssignOffline.hasAssignOfflineData(this.assign.id); |             this.hasOffline = await AddonModAssignOffline.hasAssignOfflineData(this.assign.id); | ||||||
| 
 | 
 | ||||||
|             // Get assignment submissions.
 |             // Get assignment submissions.
 | ||||||
|             const submissions = await AddonModAssign.getSubmissions(this.assign.id, { cmId: this.module!.id }); |             const submissions = await AddonModAssign.getSubmissions(this.assign.id, { cmId: this.module.id }); | ||||||
|             const time = CoreTimeUtils.timestamp(); |             const time = CoreTimeUtils.timestamp(); | ||||||
| 
 | 
 | ||||||
|             this.canViewAllSubmissions = submissions.canviewsubmissions; |             this.canViewAllSubmissions = submissions.canviewsubmissions; | ||||||
| @ -244,7 +244,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo | |||||||
| 
 | 
 | ||||||
|             try { |             try { | ||||||
|                 // Check if the user can view their own submission.
 |                 // Check if the user can view their own submission.
 | ||||||
|                 await AddonModAssign.getSubmissionStatus(this.assign.id, { cmId: this.module!.id }); |                 await AddonModAssign.getSubmissionStatus(this.assign.id, { cmId: this.module.id }); | ||||||
|                 this.canViewOwnSubmission = true; |                 this.canViewOwnSubmission = true; | ||||||
|             } catch (error) { |             } catch (error) { | ||||||
|                 this.canViewOwnSubmission = false; |                 this.canViewOwnSubmission = false; | ||||||
| @ -269,7 +269,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo | |||||||
| 
 | 
 | ||||||
|         const submissionStatus = await AddonModAssign.getSubmissionStatus(this.assign!.id, { |         const submissionStatus = await AddonModAssign.getSubmissionStatus(this.assign!.id, { | ||||||
|             groupId: this.group, |             groupId: this.group, | ||||||
|             cmId: this.module!.id, |             cmId: this.module.id, | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         this.summary = submissionStatus.gradingsummary; |         this.summary = submissionStatus.gradingsummary; | ||||||
| @ -345,7 +345,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo | |||||||
|     protected async invalidateContent(): Promise<void> { |     protected async invalidateContent(): Promise<void> { | ||||||
|         const promises: Promise<void>[] = []; |         const promises: Promise<void>[] = []; | ||||||
| 
 | 
 | ||||||
|         promises.push(AddonModAssign.invalidateAssignmentData(this.courseId!)); |         promises.push(AddonModAssign.invalidateAssignmentData(this.courseId)); | ||||||
| 
 | 
 | ||||||
|         if (this.assign) { |         if (this.assign) { | ||||||
|             promises.push(AddonModAssign.invalidateAllSubmissionData(this.assign.id)); |             promises.push(AddonModAssign.invalidateAllSubmissionData(this.assign.id)); | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ | |||||||
| <core-loading [hideUntil]="loaded" class="core-loading-center"> | <core-loading [hideUntil]="loaded" class="core-loading-center"> | ||||||
| 
 | 
 | ||||||
|     <core-course-module-description [description]="description" [component]="component" [componentId]="componentId" |     <core-course-module-description [description]="description" [component]="component" [componentId]="componentId" | ||||||
|         contextLevel="module" [contextInstanceId]="module?.id" [courseId]="courseId"></core-course-module-description> |         contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId"></core-course-module-description> | ||||||
| 
 | 
 | ||||||
|     <ion-card class="core-warning-card" *ngIf="warning"> |     <ion-card class="core-warning-card" *ngIf="warning"> | ||||||
|         <ion-icon name="fas-exclamation-triangle" slot="start"></ion-icon> |         <ion-icon name="fas-exclamation-triangle" slot="start"></ion-icon> | ||||||
| @ -38,7 +38,7 @@ | |||||||
|         </core-navigation-bar> |         </core-navigation-bar> | ||||||
| 
 | 
 | ||||||
|         <core-format-text [component]="component" [componentId]="componentId" [text]="chapterContent" contextLevel="module" |         <core-format-text [component]="component" [componentId]="componentId" [text]="chapterContent" contextLevel="module" | ||||||
|             [contextInstanceId]="module?.id" [courseId]="courseId"></core-format-text> |             [contextInstanceId]="module.id" [courseId]="courseId"></core-format-text> | ||||||
|         <div class="ion-margin-top" *ngIf="tagsEnabled && tags?.length > 0"> |         <div class="ion-margin-top" *ngIf="tagsEnabled && tags?.length > 0"> | ||||||
|             <strong>{{ 'core.tag.tags' | translate }}: </strong> |             <strong>{{ 'core.tag.tags' | translate }}: </strong> | ||||||
|             <core-tag-list [tags]="tags"></core-tag-list> |             <core-tag-list [tags]="tags"></core-tag-list> | ||||||
|  | |||||||
| @ -87,7 +87,7 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp | |||||||
|         const modal = await ModalController.create({ |         const modal = await ModalController.create({ | ||||||
|             component: AddonModBookTocComponent, |             component: AddonModBookTocComponent, | ||||||
|             componentProps: { |             componentProps: { | ||||||
|                 moduleId: this.module!.id, |                 moduleId: this.module.id, | ||||||
|                 chapters: this.chapters, |                 chapters: this.chapters, | ||||||
|                 selected: this.currentChapter, |                 selected: this.currentChapter, | ||||||
|                 courseId: this.courseId, |                 courseId: this.courseId, | ||||||
| @ -129,7 +129,7 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp | |||||||
|      * @return Resolved when done. |      * @return Resolved when done. | ||||||
|      */ |      */ | ||||||
|     protected invalidateContent(): Promise<void> { |     protected invalidateContent(): Promise<void> { | ||||||
|         return AddonModBook.invalidateContent(this.module!.id, this.courseId!); |         return AddonModBook.invalidateContent(this.module.id, this.courseId); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -143,7 +143,7 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp | |||||||
|         let downloadResult: CoreCourseResourceDownloadResult | undefined; |         let downloadResult: CoreCourseResourceDownloadResult | undefined; | ||||||
| 
 | 
 | ||||||
|         // Try to get the book data. Ignore errors since this WS isn't available in some Moodle versions.
 |         // Try to get the book data. Ignore errors since this WS isn't available in some Moodle versions.
 | ||||||
|         promises.push(CoreUtils.ignoreErrors(AddonModBook.getBook(this.courseId!, this.module!.id)) |         promises.push(CoreUtils.ignoreErrors(AddonModBook.getBook(this.courseId, this.module.id)) | ||||||
|             .then((book) => { |             .then((book) => { | ||||||
|                 if (!book) { |                 if (!book) { | ||||||
|                     return; |                     return; | ||||||
| @ -169,8 +169,8 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp | |||||||
|         try { |         try { | ||||||
|             await Promise.all(promises); |             await Promise.all(promises); | ||||||
| 
 | 
 | ||||||
|             this.contentsMap = AddonModBook.getContentsMap(this.module!.contents); |             this.contentsMap = AddonModBook.getContentsMap(this.module.contents); | ||||||
|             this.chapters = AddonModBook.getTocList(this.module!.contents); |             this.chapters = AddonModBook.getTocList(this.module.contents); | ||||||
| 
 | 
 | ||||||
|             if (typeof this.currentChapter == 'undefined' && typeof this.initialChapterId != 'undefined' && this.chapters) { |             if (typeof this.currentChapter == 'undefined' && typeof this.initialChapterId != 'undefined' && this.chapters) { | ||||||
|                 // Initial chapter set. Validate that the chapter exists.
 |                 // Initial chapter set. Validate that the chapter exists.
 | ||||||
| @ -211,7 +211,7 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp | |||||||
|         this.content?.scrollToTop(); |         this.content?.scrollToTop(); | ||||||
| 
 | 
 | ||||||
|         try { |         try { | ||||||
|             const content = await AddonModBook.getChapterContent(this.contentsMap, chapterId, this.module!.id); |             const content = await AddonModBook.getChapterContent(this.contentsMap, chapterId, this.module.id); | ||||||
| 
 | 
 | ||||||
|             this.tags = this.tagsEnabled ? this.contentsMap[this.currentChapter].tags : []; |             this.tags = this.tagsEnabled ? this.contentsMap[this.currentChapter].tags : []; | ||||||
| 
 | 
 | ||||||
| @ -228,14 +228,14 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp | |||||||
| 
 | 
 | ||||||
|             // Chapter loaded, log view. We don't return the promise because we don't want to block the user for this.
 |             // Chapter loaded, log view. We don't return the promise because we don't want to block the user for this.
 | ||||||
|             await CoreUtils.ignoreErrors(AddonModBook.logView( |             await CoreUtils.ignoreErrors(AddonModBook.logView( | ||||||
|                 this.module!.instance!, |                 this.module.instance!, | ||||||
|                 logChapterId ? chapterId : undefined, |                 logChapterId ? chapterId : undefined, | ||||||
|                 this.module!.name, |                 this.module.name, | ||||||
|             )); |             )); | ||||||
| 
 | 
 | ||||||
|             // Module is completed when last chapter is viewed, so we only check completion if the last is reached.
 |             // Module is completed when last chapter is viewed, so we only check completion if the last is reached.
 | ||||||
|             if (!this.nextChapter) { |             if (!this.nextChapter) { | ||||||
|                 CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata); |                 CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata); | ||||||
|             } |             } | ||||||
|         } catch (error) { |         } catch (error) { | ||||||
|             CoreDomUtils.showErrorModalDefault(error, 'addon.mod_book.errorchapter', true); |             CoreDomUtils.showErrorModalDefault(error, 'addon.mod_book.errorchapter', true); | ||||||
|  | |||||||
| @ -26,7 +26,7 @@ | |||||||
| <core-loading [hideUntil]="loaded" class="core-loading-center"> | <core-loading [hideUntil]="loaded" class="core-loading-center"> | ||||||
| 
 | 
 | ||||||
|     <core-course-module-description [description]="description" [component]="component" [componentId]="componentId" |     <core-course-module-description [description]="description" [component]="component" [componentId]="componentId" | ||||||
|         contextLevel="module" [contextInstanceId]="module?.id" [courseId]="courseId"> |         contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId"> | ||||||
|     </core-course-module-description> |     </core-course-module-description> | ||||||
| 
 | 
 | ||||||
|     <ion-list *ngIf="subfolder && (subfolder!.files.length + subfolder!.folders.length > 0)"> |     <ion-list *ngIf="subfolder && (subfolder!.files.length + subfolder!.folders.length > 0)"> | ||||||
|  | |||||||
| @ -55,7 +55,7 @@ export class AddonModFolderIndexComponent extends CoreCourseModuleMainResourceCo | |||||||
|         this.canGetFolder = AddonModFolder.isGetFolderWSAvailable(); |         this.canGetFolder = AddonModFolder.isGetFolderWSAvailable(); | ||||||
| 
 | 
 | ||||||
|         if (this.subfolder) { |         if (this.subfolder) { | ||||||
|             this.description = this.folderInstance ? this.folderInstance.intro : this.module!.description; |             this.description = this.folderInstance ? this.folderInstance.intro : this.module.description; | ||||||
| 
 | 
 | ||||||
|             this.loaded = true; |             this.loaded = true; | ||||||
|             this.refreshIcon = CoreConstants.ICON_REFRESH; |             this.refreshIcon = CoreConstants.ICON_REFRESH; | ||||||
| @ -67,8 +67,8 @@ export class AddonModFolderIndexComponent extends CoreCourseModuleMainResourceCo | |||||||
|             await this.loadContent(); |             await this.loadContent(); | ||||||
| 
 | 
 | ||||||
|             try { |             try { | ||||||
|                 await AddonModFolder.logView(this.module!.instance!, this.module!.name); |                 await AddonModFolder.logView(this.module.instance!, this.module.name); | ||||||
|                 CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata); |                 CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata); | ||||||
|             } catch { |             } catch { | ||||||
|                 // Ignore errors.
 |                 // Ignore errors.
 | ||||||
|             } |             } | ||||||
| @ -84,7 +84,7 @@ export class AddonModFolderIndexComponent extends CoreCourseModuleMainResourceCo | |||||||
|      * @return Resolved when done. |      * @return Resolved when done. | ||||||
|      */ |      */ | ||||||
|     protected async invalidateContent(): Promise<void> { |     protected async invalidateContent(): Promise<void> { | ||||||
|         await AddonModFolder.invalidateContent(this.module!.id, this.courseId!); |         await AddonModFolder.invalidateContent(this.module.id, this.courseId); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -96,22 +96,22 @@ export class AddonModFolderIndexComponent extends CoreCourseModuleMainResourceCo | |||||||
|     protected async fetchContent(refresh = false): Promise<void> { |     protected async fetchContent(refresh = false): Promise<void> { | ||||||
|         try { |         try { | ||||||
|             if (this.canGetFolder) { |             if (this.canGetFolder) { | ||||||
|                 this.folderInstance = await AddonModFolder.getFolder(this.courseId!, this.module!.id); |                 this.folderInstance = await AddonModFolder.getFolder(this.courseId, this.module.id); | ||||||
|                 await CoreCourse.loadModuleContents(this.module!, this.courseId, undefined, false, refresh); |                 await CoreCourse.loadModuleContents(this.module, this.courseId, undefined, false, refresh); | ||||||
|             } else { |             } else { | ||||||
|                 const module = await CoreCourse.getModule(this.module!.id, this.courseId); |                 const module = await CoreCourse.getModule(this.module.id, this.courseId); | ||||||
| 
 | 
 | ||||||
|                 if (!module.contents.length && this.module!.contents.length && !CoreApp.isOnline()) { |                 if (!module.contents.length && this.module.contents.length && !CoreApp.isOnline()) { | ||||||
|                     // The contents might be empty due to a cached data. Use the old ones.
 |                     // The contents might be empty due to a cached data. Use the old ones.
 | ||||||
|                     module.contents = this.module!.contents; |                     module.contents = this.module.contents; | ||||||
|                 } |                 } | ||||||
|                 this.module = module; |                 this.module = module; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             this.dataRetrieved.emit(this.folderInstance || this.module); |             this.dataRetrieved.emit(this.folderInstance || this.module); | ||||||
| 
 | 
 | ||||||
|             this.description = this.folderInstance ? this.folderInstance.intro : this.module!.description; |             this.description = this.folderInstance ? this.folderInstance.intro : this.module.description; | ||||||
|             this.subfolder = AddonModFolderHelper.formatContents(this.module!.contents); |             this.subfolder = AddonModFolderHelper.formatContents(this.module.contents); | ||||||
|         } finally { |         } finally { | ||||||
|             this.fillContextMenu(refresh); |             this.fillContextMenu(refresh); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -135,7 +135,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom | |||||||
|             this.eventReceived.bind(this, false), |             this.eventReceived.bind(this, false), | ||||||
|         ); |         ); | ||||||
|         this.changeDiscObserver = CoreEvents.on(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data => { |         this.changeDiscObserver = CoreEvents.on(AddonModForumProvider.CHANGE_DISCUSSION_EVENT, data => { | ||||||
|             if ((this.forum && this.forum.id === data.forumId) || data.cmId === this.module!.id) { |             if ((this.forum && this.forum.id === data.forumId) || data.cmId === this.module.id) { | ||||||
|                 AddonModForum.invalidateDiscussionsList(this.forum!.id).finally(() => { |                 AddonModForum.invalidateDiscussionsList(this.forum!.id).finally(() => { | ||||||
|                     if (data.discussionId) { |                     if (data.discussionId) { | ||||||
|                         // Discussion changed, search it in the list of discussions.
 |                         // Discussion changed, search it in the list of discussions.
 | ||||||
| @ -198,7 +198,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom | |||||||
|             AddonModForum.instance |             AddonModForum.instance | ||||||
|                 .logView(this.forum.id, this.forum.name) |                 .logView(this.forum.id, this.forum.name) | ||||||
|                 .then(async () => { |                 .then(async () => { | ||||||
|                     CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata); |                     CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata); | ||||||
| 
 | 
 | ||||||
|                     return; |                     return; | ||||||
|                 }), |                 }), | ||||||
| @ -324,7 +324,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom | |||||||
| 
 | 
 | ||||||
|         promises.push( |         promises.push( | ||||||
|             AddonModForum.instance |             AddonModForum.instance | ||||||
|                 .getAccessInformation(this.forum.id, { cmId: this.module!.id }) |                 .getAccessInformation(this.forum.id, { cmId: this.module.id }) | ||||||
|                 .then(async accessInfo => { |                 .then(async accessInfo => { | ||||||
|                     // Disallow adding discussions if cut-off date is reached and the user has not the
 |                     // Disallow adding discussions if cut-off date is reached and the user has not the
 | ||||||
|                     // capability to override it.
 |                     // capability to override it.
 | ||||||
| @ -341,7 +341,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom | |||||||
|             // Use the canAddDiscussion WS to check if the user can pin discussions.
 |             // Use the canAddDiscussion WS to check if the user can pin discussions.
 | ||||||
|             promises.push( |             promises.push( | ||||||
|                 AddonModForum.instance |                 AddonModForum.instance | ||||||
|                     .canAddDiscussionToAll(this.forum.id, { cmId: this.module!.id }) |                     .canAddDiscussionToAll(this.forum.id, { cmId: this.module.id }) | ||||||
|                     .then(async response => { |                     .then(async response => { | ||||||
|                         this.canPin = !!response.canpindiscussions; |                         this.canPin = !!response.canpindiscussions; | ||||||
| 
 | 
 | ||||||
| @ -525,7 +525,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom | |||||||
|     protected async invalidateContent(): Promise<void> { |     protected async invalidateContent(): Promise<void> { | ||||||
|         const promises: Promise<void>[] = []; |         const promises: Promise<void>[] = []; | ||||||
| 
 | 
 | ||||||
|         promises.push(AddonModForum.invalidateForumData(this.courseId!)); |         promises.push(AddonModForum.invalidateForumData(this.courseId)); | ||||||
| 
 | 
 | ||||||
|         if (this.forum) { |         if (this.forum) { | ||||||
|             promises.push(AddonModForum.invalidateDiscussionsList(this.forum.id)); |             promises.push(AddonModForum.invalidateDiscussionsList(this.forum.id)); | ||||||
| @ -546,7 +546,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom | |||||||
|      * @return Promise resolved when done. |      * @return Promise resolved when done. | ||||||
|      */ |      */ | ||||||
|     protected sync(): Promise<AddonModForumSyncResult> { |     protected sync(): Promise<AddonModForumSyncResult> { | ||||||
|         return AddonModForumPrefetchHandler.sync(this.module!, this.courseId!); |         return AddonModForumPrefetchHandler.sync(this.module, this.courseId); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -582,7 +582,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom | |||||||
|         isNewDiscussion: boolean, |         isNewDiscussion: boolean, | ||||||
|         data: AddonModForumNewDiscussionData | AddonModForumReplyDiscussionData, |         data: AddonModForumNewDiscussionData | AddonModForumReplyDiscussionData, | ||||||
|     ): void { |     ): void { | ||||||
|         if ((this.forum && this.forum.id === data.forumId) || data.cmId === this.module?.id) { |         if ((this.forum && this.forum.id === data.forumId) || data.cmId === this.module.id) { | ||||||
|             this.showLoadingAndRefresh(false).finally(() => { |             this.showLoadingAndRefresh(false).finally(() => { | ||||||
|                 // If it's a new discussion in tablet mode, try to open it.
 |                 // If it's a new discussion in tablet mode, try to open it.
 | ||||||
|                 if (isNewDiscussion && CoreScreen.isTablet) { |                 if (isNewDiscussion && CoreScreen.isTablet) { | ||||||
| @ -606,7 +606,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom | |||||||
|             }); |             }); | ||||||
| 
 | 
 | ||||||
|             // Check completion since it could be configured to complete once the user adds a new discussion or replies.
 |             // Check completion since it could be configured to complete once the user adds a new discussion or replies.
 | ||||||
|             CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata); |             CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -668,7 +668,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom | |||||||
|             componentProps: { |             componentProps: { | ||||||
|                 discussion, |                 discussion, | ||||||
|                 forumId: this.forum!.id, |                 forumId: this.forum!.id, | ||||||
|                 cmId: this.module!.id, |                 cmId: this.module.id, | ||||||
|             }, |             }, | ||||||
|             event, |             event, | ||||||
|         }); |         }); | ||||||
| @ -733,7 +733,7 @@ class AddonModForumDiscussionsManager extends CorePageItemsListManager<Discussio | |||||||
|     getItemQueryParams(discussion: DiscussionItem): Params { |     getItemQueryParams(discussion: DiscussionItem): Params { | ||||||
|         return { |         return { | ||||||
|             courseId: this.component.courseId, |             courseId: this.component.courseId, | ||||||
|             cmId: this.component.module!.id, |             cmId: this.component.module.id, | ||||||
|             forumId: this.component.forum!.id, |             forumId: this.component.forum!.id, | ||||||
|             ...(this.isOnlineDiscussion(discussion) ? { discussion, trackPosts: this.component.trackPosts } : {}), |             ...(this.isOnlineDiscussion(discussion) ? { discussion, trackPosts: this.component.trackPosts } : {}), | ||||||
|         }; |         }; | ||||||
|  | |||||||
| @ -36,7 +36,7 @@ | |||||||
|     <div class="addon-mod-imscp-container"> |     <div class="addon-mod-imscp-container"> | ||||||
|         <core-navigation-bar [previous]="previousItem" [next]="nextItem" (action)="loadItem($event)" [info]="description" |         <core-navigation-bar [previous]="previousItem" [next]="nextItem" (action)="loadItem($event)" [info]="description" | ||||||
|             [title]="'core.description' | translate" [component]="component" [componentId]="componentId" contextLevel="module" |             [title]="'core.description' | translate" [component]="component" [componentId]="componentId" contextLevel="module" | ||||||
|             [contextInstanceId]="module?.id" [courseId]="courseId"> |             [contextInstanceId]="module.id" [courseId]="courseId"> | ||||||
|         </core-navigation-bar> |         </core-navigation-bar> | ||||||
|         <core-iframe [src]="src"></core-iframe> |         <core-iframe [src]="src"></core-iframe> | ||||||
|     </div> |     </div> | ||||||
|  | |||||||
| @ -59,8 +59,8 @@ export class AddonModImscpIndexComponent extends CoreCourseModuleMainResourceCom | |||||||
|         await this.loadContent(); |         await this.loadContent(); | ||||||
| 
 | 
 | ||||||
|         try { |         try { | ||||||
|             await AddonModImscp.logView(this.module!.instance!, this.module!.name); |             await AddonModImscp.logView(this.module.instance!, this.module.name); | ||||||
|             CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata); |             CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata); | ||||||
|         } catch { |         } catch { | ||||||
|             // Ignore errors.
 |             // Ignore errors.
 | ||||||
|         } |         } | ||||||
| @ -72,7 +72,7 @@ export class AddonModImscpIndexComponent extends CoreCourseModuleMainResourceCom | |||||||
|      * @return Resolved when done. |      * @return Resolved when done. | ||||||
|      */ |      */ | ||||||
|     protected async invalidateContent(): Promise<void> { |     protected async invalidateContent(): Promise<void> { | ||||||
|         await AddonModImscp.invalidateContent(this.module!.id, this.courseId!); |         await AddonModImscp.invalidateContent(this.module.id, this.courseId); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -85,7 +85,7 @@ export class AddonModImscpIndexComponent extends CoreCourseModuleMainResourceCom | |||||||
|         let downloadResult: CoreCourseResourceDownloadResult; |         let downloadResult: CoreCourseResourceDownloadResult; | ||||||
|         const promises: Promise<void>[] = []; |         const promises: Promise<void>[] = []; | ||||||
| 
 | 
 | ||||||
|         promises.push(AddonModImscp.getImscp(this.courseId!, this.module!.id).then((imscp) => { |         promises.push(AddonModImscp.getImscp(this.courseId, this.module.id).then((imscp) => { | ||||||
|             this.description = imscp.intro; |             this.description = imscp.intro; | ||||||
|             this.dataRetrieved.emit(imscp); |             this.dataRetrieved.emit(imscp); | ||||||
| 
 | 
 | ||||||
| @ -101,7 +101,7 @@ export class AddonModImscpIndexComponent extends CoreCourseModuleMainResourceCom | |||||||
|         try { |         try { | ||||||
|             await Promise.all(promises); |             await Promise.all(promises); | ||||||
| 
 | 
 | ||||||
|             this.items = AddonModImscp.createItemList(this.module!.contents); |             this.items = AddonModImscp.createItemList(this.module.contents); | ||||||
| 
 | 
 | ||||||
|             if (this.items.length && typeof this.currentItem == 'undefined') { |             if (this.items.length && typeof this.currentItem == 'undefined') { | ||||||
|                 this.currentItem = this.items[0].href; |                 this.currentItem = this.items[0].href; | ||||||
| @ -129,7 +129,7 @@ export class AddonModImscpIndexComponent extends CoreCourseModuleMainResourceCom | |||||||
|      * @return Promise resolved when done. |      * @return Promise resolved when done. | ||||||
|      */ |      */ | ||||||
|     async loadItem(itemId?: string): Promise<void> { |     async loadItem(itemId?: string): Promise<void> { | ||||||
|         const src = await AddonModImscp.getIframeSrc(this.module!, itemId); |         const src = await AddonModImscp.getIframeSrc(this.module, itemId); | ||||||
|         this.currentItem = itemId; |         this.currentItem = itemId; | ||||||
|         this.previousItem = itemId ? AddonModImscp.getPreviousItem(this.items, itemId) : ''; |         this.previousItem = itemId ? AddonModImscp.getPreviousItem(this.items, itemId) : ''; | ||||||
|         this.nextItem = itemId ? AddonModImscp.getNextItem(this.items, itemId) : ''; |         this.nextItem = itemId ? AddonModImscp.getNextItem(this.items, itemId) : ''; | ||||||
|  | |||||||
| @ -32,7 +32,7 @@ | |||||||
|         <core-tab [title]="'addon.mod_lesson.preview' | translate" (ionSelect)="indexSelected()"> |         <core-tab [title]="'addon.mod_lesson.preview' | translate" (ionSelect)="indexSelected()"> | ||||||
|             <ng-template> |             <ng-template> | ||||||
|                 <core-course-module-description [description]="description" [component]="component" [componentId]="componentId" |                 <core-course-module-description [description]="description" [component]="component" [componentId]="componentId" | ||||||
|                     contextLevel="module" [contextInstanceId]="module?.id" [courseId]="courseId"> |                     contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId"> | ||||||
|                 </core-course-module-description> |                 </core-course-module-description> | ||||||
| 
 | 
 | ||||||
|                 <!-- Prevent access messages. Only show the first one. --> |                 <!-- Prevent access messages. Only show the first one. --> | ||||||
|  | |||||||
| @ -146,7 +146,7 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo | |||||||
|             let lessonReady = true; |             let lessonReady = true; | ||||||
|             this.askPassword = false; |             this.askPassword = false; | ||||||
| 
 | 
 | ||||||
|             this.lesson = await AddonModLesson.getLesson(this.courseId!, this.module!.id); |             this.lesson = await AddonModLesson.getLesson(this.courseId, this.module.id); | ||||||
| 
 | 
 | ||||||
|             this.dataRetrieved.emit(this.lesson); |             this.dataRetrieved.emit(this.lesson); | ||||||
|             this.description = this.lesson.intro; // Show description only if intro is present.
 |             this.description = this.lesson.intro; // Show description only if intro is present.
 | ||||||
| @ -156,7 +156,7 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo | |||||||
|                 await this.syncActivity(showErrors); |                 await this.syncActivity(showErrors); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             this.accessInfo = await AddonModLesson.getAccessInformation(this.lesson.id, { cmId: this.module!.id }); |             this.accessInfo = await AddonModLesson.getAccessInformation(this.lesson.id, { cmId: this.module.id }); | ||||||
|             this.canManage = this.accessInfo.canmanage; |             this.canManage = this.accessInfo.canmanage; | ||||||
|             this.canViewReports = this.accessInfo.canviewreports; |             this.canViewReports = this.accessInfo.canviewreports; | ||||||
|             this.preventReasons = []; |             this.preventReasons = []; | ||||||
| @ -227,7 +227,7 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         const promises: Promise<unknown>[] = []; |         const promises: Promise<unknown>[] = []; | ||||||
|         const options = { cmId: this.module!.id }; |         const options = { cmId: this.module.id }; | ||||||
| 
 | 
 | ||||||
|         // Check if there is offline data.
 |         // Check if there is offline data.
 | ||||||
|         promises.push(AddonModLessonSync.hasDataToSync(this.lesson.id, this.accessInfo.attemptscount).then((hasData) => { |         promises.push(AddonModLessonSync.hasDataToSync(this.lesson.id, this.accessInfo.attemptscount).then((hasData) => { | ||||||
| @ -293,7 +293,7 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo | |||||||
|     protected hasSyncSucceed(result: AddonModLessonSyncResult): boolean { |     protected hasSyncSucceed(result: AddonModLessonSyncResult): boolean { | ||||||
|         if (result.updated || this.dataSent) { |         if (result.updated || this.dataSent) { | ||||||
|             // Check completion status if something was sent.
 |             // Check completion status if something was sent.
 | ||||||
|             CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata); |             CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         this.dataSent = false; |         this.dataSent = false; | ||||||
| @ -339,7 +339,7 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo | |||||||
|     protected async invalidateContent(): Promise<void> { |     protected async invalidateContent(): Promise<void> { | ||||||
|         const promises: Promise<unknown>[] = []; |         const promises: Promise<unknown>[] = []; | ||||||
| 
 | 
 | ||||||
|         promises.push(AddonModLesson.invalidateLessonData(this.courseId!)); |         promises.push(AddonModLesson.invalidateLessonData(this.courseId)); | ||||||
| 
 | 
 | ||||||
|         if (this.lesson) { |         if (this.lesson) { | ||||||
|             promises.push(AddonModLesson.invalidateAccessInformation(this.lesson.id)); |             promises.push(AddonModLesson.invalidateAccessInformation(this.lesson.id)); | ||||||
| @ -394,7 +394,7 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo | |||||||
|             AddonModLesson.logViewLesson(this.lesson.id, this.password, this.lesson.name), |             AddonModLesson.logViewLesson(this.lesson.id, this.password, this.lesson.name), | ||||||
|         ); |         ); | ||||||
| 
 | 
 | ||||||
|         CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata); |         CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -414,7 +414,7 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo | |||||||
|         if (this.hasOffline) { |         if (this.hasOffline) { | ||||||
|             if (continueLast) { |             if (continueLast) { | ||||||
|                 pageId = await AddonModLesson.getLastPageSeen(this.lesson.id, this.accessInfo.attemptscount, { |                 pageId = await AddonModLesson.getLastPageSeen(this.lesson.id, this.accessInfo.attemptscount, { | ||||||
|                     cmId: this.module!.id, |                     cmId: this.module.id, | ||||||
|                 }); |                 }); | ||||||
|             } else { |             } else { | ||||||
|                 pageId = this.accessInfo.firstpageid; |                 pageId = this.accessInfo.firstpageid; | ||||||
| @ -589,7 +589,7 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo | |||||||
|         this.showSpinner = true; |         this.showSpinner = true; | ||||||
| 
 | 
 | ||||||
|         try { |         try { | ||||||
|             await AddonModLessonPrefetchHandler.prefetch(this.module!, this.courseId, true); |             await AddonModLessonPrefetchHandler.prefetch(this.module, this.courseId, true); | ||||||
| 
 | 
 | ||||||
|             // Success downloading, open lesson.
 |             // Success downloading, open lesson.
 | ||||||
|             this.playLesson(continueLast); |             this.playLesson(continueLast); | ||||||
| @ -661,8 +661,8 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo | |||||||
|             // The user sent data to server, but not in the sync process. Check if we need to fetch data.
 |             // The user sent data to server, but not in the sync process. Check if we need to fetch data.
 | ||||||
|             await CoreUtils.ignoreErrors(AddonModLessonSync.prefetchAfterUpdate( |             await CoreUtils.ignoreErrors(AddonModLessonSync.prefetchAfterUpdate( | ||||||
|                 AddonModLessonPrefetchHandler.instance, |                 AddonModLessonPrefetchHandler.instance, | ||||||
|                 this.module!, |                 this.module, | ||||||
|                 this.courseId!, |                 this.courseId, | ||||||
|             )); |             )); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -677,7 +677,7 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo | |||||||
|      */ |      */ | ||||||
|     protected async validatePassword(password: string): Promise<void> { |     protected async validatePassword(password: string): Promise<void> { | ||||||
|         try { |         try { | ||||||
|             this.lesson = await AddonModLesson.getLessonWithPassword(this.lesson!.id, { password, cmId: this.module!.id }); |             this.lesson = await AddonModLesson.getLessonWithPassword(this.lesson!.id, { password, cmId: this.module.id }); | ||||||
| 
 | 
 | ||||||
|             this.password = password; |             this.password = password; | ||||||
|         } catch (error) { |         } catch (error) { | ||||||
|  | |||||||
| @ -13,7 +13,7 @@ | |||||||
|     </ion-toolbar> |     </ion-toolbar> | ||||||
| </ion-header> | </ion-header> | ||||||
| <ion-content> | <ion-content> | ||||||
|     <ion-refresher slot="fixed" [disabled]="!activityComponent?.loaded" (ionRefresh)="activityComponent?.doRefresh($event)"> |     <ion-refresher slot="fixed" [disabled]="!activityComponent?.loaded" (ionRefresh)="activityComponent?.doRefresh($event.target)"> | ||||||
|         <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content> |         <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content> | ||||||
|     </ion-refresher> |     </ion-refresher> | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -26,7 +26,7 @@ | |||||||
| <core-loading [hideUntil]="loaded" class="core-loading-center safe-area-page"> | <core-loading [hideUntil]="loaded" class="core-loading-center safe-area-page"> | ||||||
| 
 | 
 | ||||||
|     <core-course-module-description *ngIf="displayDescription" [description]="description" [component]="component" |     <core-course-module-description *ngIf="displayDescription" [description]="description" [component]="component" | ||||||
|         [componentId]="componentId" contextLevel="module" [contextInstanceId]="module?.id" [courseId]="courseId"> |         [componentId]="componentId" contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId"> | ||||||
|     </core-course-module-description> |     </core-course-module-description> | ||||||
| 
 | 
 | ||||||
|     <ion-card class="core-warning-card" *ngIf="warning"> |     <ion-card class="core-warning-card" *ngIf="warning"> | ||||||
| @ -36,7 +36,7 @@ | |||||||
| 
 | 
 | ||||||
|     <div class="ion-padding"> |     <div class="ion-padding"> | ||||||
|         <core-format-text [component]="component" [componentId]="componentId" [text]="contents" contextLevel="module" |         <core-format-text [component]="component" [componentId]="componentId" [text]="contents" contextLevel="module" | ||||||
|             [contextInstanceId]="module?.id" [courseId]="courseId"> |             [contextInstanceId]="module.id" [courseId]="courseId"> | ||||||
|         </core-format-text> |         </core-format-text> | ||||||
| 
 | 
 | ||||||
|         <p class="ion-padding-bottom addon-mod_page-timemodified" *ngIf="displayTimemodified && timemodified"> |         <p class="ion-padding-bottom addon-mod_page-timemodified" *ngIf="displayTimemodified && timemodified"> | ||||||
|  | |||||||
| @ -59,8 +59,8 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp | |||||||
|         await this.loadContent(); |         await this.loadContent(); | ||||||
| 
 | 
 | ||||||
|         try { |         try { | ||||||
|             await AddonModPage.logView(this.module!.instance!, this.module!.name); |             await AddonModPage.logView(this.module.instance!, this.module.name); | ||||||
|             CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata); |             CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata); | ||||||
|         } catch { |         } catch { | ||||||
|             // Ignore errors.
 |             // Ignore errors.
 | ||||||
|         } |         } | ||||||
| @ -72,7 +72,7 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp | |||||||
|      * @return Resolved when done. |      * @return Resolved when done. | ||||||
|      */ |      */ | ||||||
|     protected async invalidateContent(): Promise<void> { |     protected async invalidateContent(): Promise<void> { | ||||||
|         await AddonModPage.invalidateContent(this.module!.id, this.courseId!); |         await AddonModPage.invalidateContent(this.module.id, this.courseId); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -92,9 +92,9 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp | |||||||
| 
 | 
 | ||||||
|             // Get the module to get the latest title and description. Data should've been updated in download.
 |             // Get the module to get the latest title and description. Data should've been updated in download.
 | ||||||
|             if (this.canGetPage) { |             if (this.canGetPage) { | ||||||
|                 getPagePromise = AddonModPage.getPageData(this.courseId!, this.module!.id); |                 getPagePromise = AddonModPage.getPageData(this.courseId, this.module.id); | ||||||
|             } else { |             } else { | ||||||
|                 getPagePromise = CoreCourse.getModule(this.module!.id, this.courseId!); |                 getPagePromise = CoreCourse.getModule(this.module.id, this.courseId); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             promises.push(getPagePromise.then((page) => { |             promises.push(getPagePromise.then((page) => { | ||||||
| @ -133,7 +133,7 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp | |||||||
|             })); |             })); | ||||||
| 
 | 
 | ||||||
|             // Get the page HTML.
 |             // Get the page HTML.
 | ||||||
|             promises.push(AddonModPageHelper.getPageHtml(this.module!.contents, this.module!.id).then((content) => { |             promises.push(AddonModPageHelper.getPageHtml(this.module.contents, this.module.id).then((content) => { | ||||||
| 
 | 
 | ||||||
|                 this.contents = content; |                 this.contents = content; | ||||||
|                 this.warning = downloadResult?.failed ? this.getErrorDownloadingSomeFilesMessage(downloadResult.error!) : ''; |                 this.warning = downloadResult?.failed ? this.getErrorDownloadingSomeFilesMessage(downloadResult.error!) : ''; | ||||||
|  | |||||||
| @ -28,7 +28,7 @@ | |||||||
| <!-- Content. --> | <!-- Content. --> | ||||||
| <core-loading [hideUntil]="loaded" class="core-loading-center"> | <core-loading [hideUntil]="loaded" class="core-loading-center"> | ||||||
|     <core-course-module-description [description]="description" [component]="component" [componentId]="componentId" |     <core-course-module-description [description]="description" [component]="component" [componentId]="componentId" | ||||||
|         contextLevel="module" [contextInstanceId]="module?.id" [courseId]="courseId"> |         contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId"> | ||||||
|     </core-course-module-description> |     </core-course-module-description> | ||||||
| 
 | 
 | ||||||
|     <!-- Access rules description messages. --> |     <!-- Access rules description messages. --> | ||||||
| @ -117,7 +117,7 @@ | |||||||
|                 <ion-label> |                 <ion-label> | ||||||
|                     <h3 class="item-heading">{{ 'addon.mod_quiz.comment' | translate }}</h3> |                     <h3 class="item-heading">{{ 'addon.mod_quiz.comment' | translate }}</h3> | ||||||
|                     <p><core-format-text [component]="component" [componentId]="componentId" [text]="gradebookFeedback" |                     <p><core-format-text [component]="component" [componentId]="componentId" [text]="gradebookFeedback" | ||||||
|                         contextLevel="module" [contextInstanceId]="module?.id" [courseId]="courseId"> |                         contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId"> | ||||||
|                     </core-format-text></p> |                     </core-format-text></p> | ||||||
|                 </ion-label> |                 </ion-label> | ||||||
|             </ion-item> |             </ion-item> | ||||||
| @ -125,7 +125,7 @@ | |||||||
|                 <ion-label> |                 <ion-label> | ||||||
|                     <h3 class="item-heading">{{ 'addon.mod_quiz.overallfeedback' | translate }}</h3> |                     <h3 class="item-heading">{{ 'addon.mod_quiz.overallfeedback' | translate }}</h3> | ||||||
|                     <p><core-format-text [component]="component" [componentId]="componentId" [text]="overallFeedback" |                     <p><core-format-text [component]="component" [componentId]="componentId" [text]="overallFeedback" | ||||||
|                         contextLevel="module" [contextInstanceId]="module?.id" [courseId]="courseId"> |                         contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId"> | ||||||
|                     </core-format-text></p> |                     </core-format-text></p> | ||||||
|                 </ion-label> |                 </ion-label> | ||||||
|             </ion-item> |             </ion-item> | ||||||
|  | |||||||
| @ -129,7 +129,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp | |||||||
|         try { |         try { | ||||||
|             await AddonModQuiz.logViewQuiz(this.quiz.id, this.quiz.name); |             await AddonModQuiz.logViewQuiz(this.quiz.id, this.quiz.name); | ||||||
| 
 | 
 | ||||||
|             CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata); |             CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata); | ||||||
|         } catch { |         } catch { | ||||||
|             // Ignore errors.
 |             // Ignore errors.
 | ||||||
|         } |         } | ||||||
| @ -162,7 +162,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp | |||||||
|         this.showStatusSpinner = true; |         this.showStatusSpinner = true; | ||||||
| 
 | 
 | ||||||
|         try { |         try { | ||||||
|             await AddonModQuizPrefetchHandler.prefetch(this.module!, this.courseId, true); |             await AddonModQuizPrefetchHandler.prefetch(this.module, this.courseId, true); | ||||||
| 
 | 
 | ||||||
|             // Success downloading, open quiz.
 |             // Success downloading, open quiz.
 | ||||||
|             this.openQuiz(); |             this.openQuiz(); | ||||||
| @ -190,7 +190,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp | |||||||
|     protected async fetchContent(refresh: boolean = false, sync: boolean = false, showErrors: boolean = false): Promise<void> { |     protected async fetchContent(refresh: boolean = false, sync: boolean = false, showErrors: boolean = false): Promise<void> { | ||||||
|         try { |         try { | ||||||
|             // First get the quiz instance.
 |             // First get the quiz instance.
 | ||||||
|             const quiz = await AddonModQuiz.getQuiz(this.courseId!, this.module!.id); |             const quiz = await AddonModQuiz.getQuiz(this.courseId, this.module.id); | ||||||
| 
 | 
 | ||||||
|             this.gradeMethodReadable = AddonModQuiz.getQuizGradeMethod(quiz.grademethod); |             this.gradeMethodReadable = AddonModQuiz.getQuizGradeMethod(quiz.grademethod); | ||||||
|             this.now = Date.now(); |             this.now = Date.now(); | ||||||
| @ -231,7 +231,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp | |||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             // Get quiz access info.
 |             // Get quiz access info.
 | ||||||
|             this.quizAccessInfo = await AddonModQuiz.getQuizAccessInformation(quiz.id, { cmId: this.module!.id }); |             this.quizAccessInfo = await AddonModQuiz.getQuizAccessInformation(quiz.id, { cmId: this.module.id }); | ||||||
| 
 | 
 | ||||||
|             this.showReviewColumn = this.quizAccessInfo.canreviewmyattempts; |             this.showReviewColumn = this.quizAccessInfo.canreviewmyattempts; | ||||||
|             this.accessRules = this.quizAccessInfo.accessrules; |             this.accessRules = this.quizAccessInfo.accessrules; | ||||||
| @ -242,7 +242,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp | |||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             // Get question types in the quiz.
 |             // Get question types in the quiz.
 | ||||||
|             const types = await AddonModQuiz.getQuizRequiredQtypes(quiz.id, { cmId: this.module!.id }); |             const types = await AddonModQuiz.getQuizRequiredQtypes(quiz.id, { cmId: this.module.id }); | ||||||
| 
 | 
 | ||||||
|             this.unsupportedQuestions = AddonModQuiz.getUnsupportedQuestions(types); |             this.unsupportedQuestions = AddonModQuiz.getUnsupportedQuestions(types); | ||||||
|             this.hasSupportedQuestions = !!types.find((type) => type != 'random' && this.unsupportedQuestions.indexOf(type) == -1); |             this.hasSupportedQuestions = !!types.find((type) => type != 'random' && this.unsupportedQuestions.indexOf(type) == -1); | ||||||
| @ -265,10 +265,10 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp | |||||||
|     protected async getAttempts(quiz: AddonModQuizQuizData): Promise<void> { |     protected async getAttempts(quiz: AddonModQuizQuizData): Promise<void> { | ||||||
| 
 | 
 | ||||||
|         // Get access information of last attempt (it also works if no attempts made).
 |         // Get access information of last attempt (it also works if no attempts made).
 | ||||||
|         this.attemptAccessInfo = await AddonModQuiz.getAttemptAccessInformation(quiz.id, 0, { cmId: this.module!.id }); |         this.attemptAccessInfo = await AddonModQuiz.getAttemptAccessInformation(quiz.id, 0, { cmId: this.module.id }); | ||||||
| 
 | 
 | ||||||
|         // Get attempts.
 |         // Get attempts.
 | ||||||
|         const attempts = await AddonModQuiz.getUserAttempts(quiz.id, { cmId: this.module!.id }); |         const attempts = await AddonModQuiz.getUserAttempts(quiz.id, { cmId: this.module.id }); | ||||||
| 
 | 
 | ||||||
|         this.attempts = await this.treatAttempts(quiz, attempts); |         this.attempts = await this.treatAttempts(quiz, attempts); | ||||||
| 
 | 
 | ||||||
| @ -386,7 +386,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp | |||||||
|         if (quiz.showFeedbackColumn) { |         if (quiz.showFeedbackColumn) { | ||||||
|             // Get the quiz overall feedback.
 |             // Get the quiz overall feedback.
 | ||||||
|             const response = await AddonModQuiz.getFeedbackForGrade(quiz.id, this.gradebookData.grade, { |             const response = await AddonModQuiz.getFeedbackForGrade(quiz.id, this.gradebookData.grade, { | ||||||
|                 cmId: this.module!.id, |                 cmId: this.module.id, | ||||||
|             }); |             }); | ||||||
| 
 | 
 | ||||||
|             this.overallFeedback = response.feedbacktext; |             this.overallFeedback = response.feedbacktext; | ||||||
| @ -404,14 +404,14 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // If we go to auto review it means an attempt was finished. Check completion status.
 |         // If we go to auto review it means an attempt was finished. Check completion status.
 | ||||||
|         CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata); |         CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata); | ||||||
| 
 | 
 | ||||||
|         // Verify that user can see the review.
 |         // Verify that user can see the review.
 | ||||||
|         const attemptId = this.autoReview.attemptId; |         const attemptId = this.autoReview.attemptId; | ||||||
| 
 | 
 | ||||||
|         if (this.quizAccessInfo?.canreviewmyattempts) { |         if (this.quizAccessInfo?.canreviewmyattempts) { | ||||||
|             try { |             try { | ||||||
|                 await AddonModQuiz.getAttemptReview(attemptId, { page: -1, cmId: this.module!.id }); |                 await AddonModQuiz.getAttemptReview(attemptId, { page: -1, cmId: this.module.id }); | ||||||
| 
 | 
 | ||||||
|                 await CoreNavigator.navigate(`review/${attemptId}`); |                 await CoreNavigator.navigate(`review/${attemptId}`); | ||||||
|             } catch { |             } catch { | ||||||
| @ -429,7 +429,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp | |||||||
|     protected hasSyncSucceed(result: AddonModQuizSyncResult): boolean { |     protected hasSyncSucceed(result: AddonModQuizSyncResult): boolean { | ||||||
|         if (result.attemptFinished) { |         if (result.attemptFinished) { | ||||||
|             // An attempt was finished, check completion status.
 |             // An attempt was finished, check completion status.
 | ||||||
|             CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata); |             CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // If the sync call isn't rejected it means the sync was successful.
 |         // If the sync call isn't rejected it means the sync was successful.
 | ||||||
| @ -488,7 +488,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp | |||||||
|     protected async invalidateContent(): Promise<void> { |     protected async invalidateContent(): Promise<void> { | ||||||
|         const promises: Promise<void>[] = []; |         const promises: Promise<void>[] = []; | ||||||
| 
 | 
 | ||||||
|         promises.push(AddonModQuiz.invalidateQuizData(this.courseId!)); |         promises.push(AddonModQuiz.invalidateQuizData(this.courseId)); | ||||||
| 
 | 
 | ||||||
|         if (this.quiz) { |         if (this.quiz) { | ||||||
|             promises.push(AddonModQuiz.invalidateUserAttemptsForUser(this.quiz.id)); |             promises.push(AddonModQuiz.invalidateUserAttemptsForUser(this.quiz.id)); | ||||||
| @ -497,7 +497,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp | |||||||
|             promises.push(AddonModQuiz.invalidateAttemptAccessInformation(this.quiz.id)); |             promises.push(AddonModQuiz.invalidateAttemptAccessInformation(this.quiz.id)); | ||||||
|             promises.push(AddonModQuiz.invalidateCombinedReviewOptionsForUser(this.quiz.id)); |             promises.push(AddonModQuiz.invalidateCombinedReviewOptionsForUser(this.quiz.id)); | ||||||
|             promises.push(AddonModQuiz.invalidateUserBestGradeForUser(this.quiz.id)); |             promises.push(AddonModQuiz.invalidateUserBestGradeForUser(this.quiz.id)); | ||||||
|             promises.push(AddonModQuiz.invalidateGradeFromGradebook(this.courseId!)); |             promises.push(AddonModQuiz.invalidateGradeFromGradebook(this.courseId)); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         await Promise.all(promises); |         await Promise.all(promises); | ||||||
| @ -536,7 +536,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp | |||||||
| 
 | 
 | ||||||
|         CoreNavigator.navigate('player', { |         CoreNavigator.navigate('player', { | ||||||
|             params: { |             params: { | ||||||
|                 moduleUrl: this.module?.url, |                 moduleUrl: this.module.url, | ||||||
|             }, |             }, | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| @ -594,7 +594,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // Get combined review options.
 |         // Get combined review options.
 | ||||||
|         promises.push(AddonModQuiz.getCombinedReviewOptions(quiz.id, { cmId: this.module!.id }).then((options) => { |         promises.push(AddonModQuiz.getCombinedReviewOptions(quiz.id, { cmId: this.module.id }).then((options) => { | ||||||
|             this.options = options; |             this.options = options; | ||||||
| 
 | 
 | ||||||
|             return; |             return; | ||||||
| @ -633,11 +633,11 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp | |||||||
|      * @return Promise resolved when done. |      * @return Promise resolved when done. | ||||||
|      */ |      */ | ||||||
|     protected async getQuizGrade(quiz: AddonModQuizQuizData): Promise<void> { |     protected async getQuizGrade(quiz: AddonModQuizQuizData): Promise<void> { | ||||||
|         this.bestGrade = await AddonModQuiz.getUserBestGrade(quiz.id, { cmId: this.module!.id }); |         this.bestGrade = await AddonModQuiz.getUserBestGrade(quiz.id, { cmId: this.module.id }); | ||||||
| 
 | 
 | ||||||
|         try { |         try { | ||||||
|             // Get gradebook grade.
 |             // Get gradebook grade.
 | ||||||
|             const data = await AddonModQuiz.getGradeFromGradebook(this.courseId!, this.module!.id); |             const data = await AddonModQuiz.getGradeFromGradebook(this.courseId, this.module.id); | ||||||
| 
 | 
 | ||||||
|             if (data) { |             if (data) { | ||||||
|                 this.gradebookData = { |                 this.gradebookData = { | ||||||
|  | |||||||
| @ -22,7 +22,7 @@ | |||||||
| 
 | 
 | ||||||
|     <core-course-module-description *ngIf="mode != 'iframe' && (mode != 'embedded' || displayDescription)" |     <core-course-module-description *ngIf="mode != 'iframe' && (mode != 'embedded' || displayDescription)" | ||||||
|         [description]="description" [component]="component" [componentId]="componentId" contextLevel="module" |         [description]="description" [component]="component" [componentId]="componentId" contextLevel="module" | ||||||
|         [contextInstanceId]="module!.id" [courseId]="courseId"> |         [contextInstanceId]="module.id" [courseId]="courseId"> | ||||||
|     </core-course-module-description> |     </core-course-module-description> | ||||||
| 
 | 
 | ||||||
|     <ion-card class="core-warning-card" *ngIf="warning"> |     <ion-card class="core-warning-card" *ngIf="warning"> | ||||||
|  | |||||||
| @ -64,8 +64,8 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource | |||||||
| 
 | 
 | ||||||
|         await this.loadContent(); |         await this.loadContent(); | ||||||
|         try { |         try { | ||||||
|             await AddonModResource.logView(this.module!.instance!, this.module!.name); |             await AddonModResource.logView(this.module.instance!, this.module.name); | ||||||
|             CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata); |             CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata); | ||||||
|         } catch { |         } catch { | ||||||
|             // Ignore errors.
 |             // Ignore errors.
 | ||||||
|         } |         } | ||||||
| @ -77,7 +77,7 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource | |||||||
|      * @return Resolved when done. |      * @return Resolved when done. | ||||||
|      */ |      */ | ||||||
|     protected async invalidateContent(): Promise<void> { |     protected async invalidateContent(): Promise<void> { | ||||||
|         return AddonModResource.invalidateContent(this.module!.id, this.courseId!); |         return AddonModResource.invalidateContent(this.module.id, this.courseId); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -88,9 +88,9 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource | |||||||
|      */ |      */ | ||||||
|     protected async fetchContent(refresh?: boolean): Promise<void> { |     protected async fetchContent(refresh?: boolean): Promise<void> { | ||||||
|         // Load module contents if needed. Passing refresh is needed to force reloading contents.
 |         // Load module contents if needed. Passing refresh is needed to force reloading contents.
 | ||||||
|         await CoreCourse.loadModuleContents(this.module!, this.courseId, undefined, false, refresh); |         await CoreCourse.loadModuleContents(this.module, this.courseId, undefined, false, refresh); | ||||||
| 
 | 
 | ||||||
|         if (!this.module!.contents || !this.module!.contents.length) { |         if (!this.module.contents || !this.module.contents.length) { | ||||||
|             throw new CoreError(Translate.instant('core.filenotfound')); |             throw new CoreError(Translate.instant('core.filenotfound')); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -99,11 +99,11 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource | |||||||
| 
 | 
 | ||||||
|         // Get the resource instance to get the latest name/description and to know if it's embedded.
 |         // Get the resource instance to get the latest name/description and to know if it's embedded.
 | ||||||
|         if (this.canGetResource) { |         if (this.canGetResource) { | ||||||
|             resource = await CoreUtils.ignoreErrors(AddonModResource.getResourceData(this.courseId!, this.module!.id)); |             resource = await CoreUtils.ignoreErrors(AddonModResource.getResourceData(this.courseId, this.module.id)); | ||||||
|             this.description = resource?.intro || ''; |             this.description = resource?.intro || ''; | ||||||
|             options = resource?.displayoptions ? CoreTextUtils.unserialize(resource.displayoptions) : {}; |             options = resource?.displayoptions ? CoreTextUtils.unserialize(resource.displayoptions) : {}; | ||||||
|         } else { |         } else { | ||||||
|             resource = await CoreUtils.ignoreErrors(CoreCourse.getModule(this.module!.id, this.courseId)); |             resource = await CoreUtils.ignoreErrors(CoreCourse.getModule(this.module.id, this.courseId)); | ||||||
|             this.description = resource?.description || ''; |             this.description = resource?.description || ''; | ||||||
|             options = resource?.customdata ? CoreTextUtils.unserialize(CoreTextUtils.parseJSON(resource.customdata)) : {}; |             options = resource?.customdata ? CoreTextUtils.unserialize(CoreTextUtils.parseJSON(resource.customdata)) : {}; | ||||||
|         } |         } | ||||||
| @ -114,9 +114,9 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource | |||||||
|                 this.dataRetrieved.emit(resource); |                 this.dataRetrieved.emit(resource); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             if (AddonModResourceHelper.isDisplayedInIframe(this.module!)) { |             if (AddonModResourceHelper.isDisplayedInIframe(this.module)) { | ||||||
|                 const downloadResult = await this.downloadResourceIfNeeded(refresh, true); |                 const downloadResult = await this.downloadResourceIfNeeded(refresh, true); | ||||||
|                 const src = await AddonModResourceHelper.getIframeSrc(this.module!); |                 const src = await AddonModResourceHelper.getIframeSrc(this.module); | ||||||
|                 this.mode = 'iframe'; |                 this.mode = 'iframe'; | ||||||
| 
 | 
 | ||||||
|                 if (this.src && src.toString() == this.src.toString()) { |                 if (this.src && src.toString() == this.src.toString()) { | ||||||
| @ -137,11 +137,11 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource | |||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             if (resource && 'display' in resource && AddonModResourceHelper.isDisplayedEmbedded(this.module!, resource.display)) { |             if (resource && 'display' in resource && AddonModResourceHelper.isDisplayedEmbedded(this.module, resource.display)) { | ||||||
|                 this.mode = 'embedded'; |                 this.mode = 'embedded'; | ||||||
|                 this.warning = ''; |                 this.warning = ''; | ||||||
| 
 | 
 | ||||||
|                 this.contentText = await AddonModResourceHelper.getEmbeddedHtml(this.module!, this.courseId!); |                 this.contentText = await AddonModResourceHelper.getEmbeddedHtml(this.module, this.courseId); | ||||||
|                 this.mode = this.contentText.length > 0 ? 'embedded' : 'external'; |                 this.mode = this.contentText.length > 0 ? 'embedded' : 'external'; | ||||||
|             } else { |             } else { | ||||||
|                 this.mode = 'external'; |                 this.mode = 'external'; | ||||||
| @ -158,20 +158,20 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource | |||||||
|      * @return Promise resolved when done. |      * @return Promise resolved when done. | ||||||
|      */ |      */ | ||||||
|     async open(): Promise<void> { |     async open(): Promise<void> { | ||||||
|         let downloadable = await CoreCourseModulePrefetchDelegate.isModuleDownloadable(this.module!, this.courseId!); |         let downloadable = await CoreCourseModulePrefetchDelegate.isModuleDownloadable(this.module, this.courseId); | ||||||
| 
 | 
 | ||||||
|         if (downloadable) { |         if (downloadable) { | ||||||
|             // Check if the main file is downloadle.
 |             // Check if the main file is downloadle.
 | ||||||
|             // This isn't done in "isDownloadable" to prevent extra WS calls in the course page.
 |             // This isn't done in "isDownloadable" to prevent extra WS calls in the course page.
 | ||||||
|             downloadable = await AddonModResourceHelper.isMainFileDownloadable(this.module!); |             downloadable = await AddonModResourceHelper.isMainFileDownloadable(this.module); | ||||||
| 
 | 
 | ||||||
|             if (downloadable) { |             if (downloadable) { | ||||||
|                 return AddonModResourceHelper.openModuleFile(this.module!, this.courseId!); |                 return AddonModResourceHelper.openModuleFile(this.module, this.courseId); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // The resource cannot be downloaded, open the activity in browser.
 |         // The resource cannot be downloaded, open the activity in browser.
 | ||||||
|         await CoreSites.getCurrentSite()?.openInBrowserWithAutoLoginIfSameSite(this.module!.url!); |         await CoreSites.getCurrentSite()?.openInBrowserWithAutoLoginIfSameSite(this.module.url!); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -16,7 +16,7 @@ | |||||||
| <core-loading [hideUntil]="loaded" class="core-loading-center"> | <core-loading [hideUntil]="loaded" class="core-loading-center"> | ||||||
| 
 | 
 | ||||||
|     <core-course-module-description *ngIf="displayDescription" [description]="description" [component]="component" |     <core-course-module-description *ngIf="displayDescription" [description]="description" [component]="component" | ||||||
|         [componentId]="componentId" contextLevel="module" [contextInstanceId]="module!.id" [courseId]="courseId"> |         [componentId]="componentId" contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId"> | ||||||
|     </core-course-module-description> |     </core-course-module-description> | ||||||
| 
 | 
 | ||||||
|     <div *ngIf="shouldIframe || (shouldEmbed && isOther)" class="addon-mod_url-embedded-url"> |     <div *ngIf="shouldIframe || (shouldEmbed && isOther)" class="addon-mod_url-embedded-url"> | ||||||
|  | |||||||
| @ -75,7 +75,7 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo | |||||||
|      * @return Resolved when done. |      * @return Resolved when done. | ||||||
|      */ |      */ | ||||||
|     protected async invalidateContent(): Promise<void> { |     protected async invalidateContent(): Promise<void> { | ||||||
|         await AddonModUrl.invalidateContent(this.module!.id, this.courseId!); |         await AddonModUrl.invalidateContent(this.module.id, this.courseId); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -90,7 +90,7 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo | |||||||
|                 throw null; |                 throw null; | ||||||
|             } |             } | ||||||
|             // Fetch the module data.
 |             // Fetch the module data.
 | ||||||
|             const url = await AddonModUrl.getUrl(this.courseId!, this.module!.id); |             const url = await AddonModUrl.getUrl(this.courseId, this.module.id); | ||||||
| 
 | 
 | ||||||
|             this.name = url.name; |             this.name = url.name; | ||||||
|             this.description = url.intro; |             this.description = url.intro; | ||||||
| @ -102,17 +102,17 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo | |||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             // Try to load module contents, it's needed to get the URL with parameters.
 |             // Try to load module contents, it's needed to get the URL with parameters.
 | ||||||
|             await CoreCourse.loadModuleContents(this.module!, this.courseId, undefined, false, refresh, undefined, 'url'); |             await CoreCourse.loadModuleContents(this.module, this.courseId, undefined, false, refresh, undefined, 'url'); | ||||||
| 
 | 
 | ||||||
|             // Always use the URL from the module because it already includes the parameters.
 |             // Always use the URL from the module because it already includes the parameters.
 | ||||||
|             this.url = this.module!.contents[0] && this.module!.contents[0].fileurl ? this.module!.contents[0].fileurl : undefined; |             this.url = this.module.contents[0] && this.module.contents[0].fileurl ? this.module.contents[0].fileurl : undefined; | ||||||
| 
 | 
 | ||||||
|             await this.calculateDisplayOptions(url); |             await this.calculateDisplayOptions(url); | ||||||
| 
 | 
 | ||||||
|         } catch { |         } catch { | ||||||
|             // Fallback in case is not prefetched or not available.
 |             // Fallback in case is not prefetched or not available.
 | ||||||
|             const mod = |             const mod = | ||||||
|                 await CoreCourse.getModule(this.module!.id, this.courseId, undefined, false, false, undefined, 'url'); |                 await CoreCourse.getModule(this.module.id, this.courseId, undefined, false, false, undefined, 'url'); | ||||||
| 
 | 
 | ||||||
|             this.name = mod.name; |             this.name = mod.name; | ||||||
|             this.description = mod.description; |             this.description = mod.description; | ||||||
| @ -167,8 +167,8 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo | |||||||
|      */ |      */ | ||||||
|     protected async logView(): Promise<void> { |     protected async logView(): Promise<void> { | ||||||
|         try { |         try { | ||||||
|             await AddonModUrl.logView(this.module!.instance!, this.module!.name); |             await AddonModUrl.logView(this.module.instance!, this.module.name); | ||||||
|             CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata); |             CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata); | ||||||
|         } catch { |         } catch { | ||||||
|             // Ignore errors.
 |             // Ignore errors.
 | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -50,8 +50,8 @@ export type CoreCourseResourceDownloadResult = { | |||||||
| }) | }) | ||||||
| export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy, CoreCourseModuleMainComponent { | export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy, CoreCourseModuleMainComponent { | ||||||
| 
 | 
 | ||||||
|     @Input() module?: CoreCourseModule; // The module of the component.
 |     @Input() module!: CoreCourseModule; // The module of the component.
 | ||||||
|     @Input() courseId?: number; // Course ID the component belongs to.
 |     @Input() courseId!: number; // Course ID the component belongs to.
 | ||||||
|     @Output() dataRetrieved = new EventEmitter<unknown>(); // Called to notify changes the index page from the main component.
 |     @Output() dataRetrieved = new EventEmitter<unknown>(); // Called to notify changes the index page from the main component.
 | ||||||
| 
 | 
 | ||||||
|     loaded = false; // If the component has been loaded.
 |     loaded = false; // If the component has been loaded.
 | ||||||
| @ -90,10 +90,10 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy, | |||||||
|      */ |      */ | ||||||
|     async ngOnInit(): Promise<void> { |     async ngOnInit(): Promise<void> { | ||||||
|         this.siteId = CoreSites.getCurrentSiteId(); |         this.siteId = CoreSites.getCurrentSiteId(); | ||||||
|         this.description = this.module?.description; |         this.description = this.module.description; | ||||||
|         this.componentId = this.module?.id; |         this.componentId = this.module.id; | ||||||
|         this.externalUrl = this.module?.url; |         this.externalUrl = this.module.url; | ||||||
|         this.courseId = this.courseId || this.module?.course; |         this.courseId = this.courseId || this.module.course!; | ||||||
|         this.blog = await AddonBlog.isPluginEnabled(); |         this.blog = await AddonBlog.isPluginEnabled(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -107,6 +107,7 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy, | |||||||
|      */ |      */ | ||||||
|     async doRefresh(refresher?: CustomEvent<IonRefresher> | null, done?: () => void, showErrors: boolean = false): Promise<void> { |     async doRefresh(refresher?: CustomEvent<IonRefresher> | null, done?: () => void, showErrors: boolean = false): Promise<void> { | ||||||
|         if (!this.loaded || !this.module) { |         if (!this.loaded || !this.module) { | ||||||
|  |             // Module can be undefined if course format changes from single activity to weekly/topics.
 | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -193,12 +194,8 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy, | |||||||
|      * Fill the context menu options |      * Fill the context menu options | ||||||
|      */ |      */ | ||||||
|     protected fillContextMenu(refresh: boolean = false): void { |     protected fillContextMenu(refresh: boolean = false): void { | ||||||
|         if (!this.module) { |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         // All data obtained, now fill the context menu.
 |         // All data obtained, now fill the context menu.
 | ||||||
|         CoreCourseHelper.fillContextMenu(this, this.module, this.courseId!, refresh, this.component); |         CoreCourseHelper.fillContextMenu(this, this.module, this.courseId, refresh, this.component); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -215,10 +212,10 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy, | |||||||
|     expandDescription(): void { |     expandDescription(): void { | ||||||
|         CoreTextUtils.viewText(Translate.instant('core.description'), this.description!, { |         CoreTextUtils.viewText(Translate.instant('core.description'), this.description!, { | ||||||
|             component: this.component, |             component: this.component, | ||||||
|             componentId: this.module?.id, |             componentId: this.module.id, | ||||||
|             filter: true, |             filter: true, | ||||||
|             contextLevel: 'module', |             contextLevel: 'module', | ||||||
|             instanceId: this.module?.id, |             instanceId: this.module.id, | ||||||
|             courseId: this.courseId, |             courseId: this.courseId, | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| @ -227,7 +224,7 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy, | |||||||
|      * Go to blog posts. |      * Go to blog posts. | ||||||
|      */ |      */ | ||||||
|     async gotoBlog(): Promise<void> { |     async gotoBlog(): Promise<void> { | ||||||
|         const params: Params = { cmId: this.module?.id }; |         const params: Params = { cmId: this.module.id }; | ||||||
| 
 | 
 | ||||||
|         CoreNavigator.navigateToSitePath(AddonBlogMainMenuHandlerService.PAGE_NAME, { params }); |         CoreNavigator.navigateToSitePath(AddonBlogMainMenuHandlerService.PAGE_NAME, { params }); | ||||||
|     } |     } | ||||||
| @ -238,11 +235,7 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy, | |||||||
|      * @param done Function to call when done. |      * @param done Function to call when done. | ||||||
|      */ |      */ | ||||||
|     prefetch(done?: () => void): void { |     prefetch(done?: () => void): void { | ||||||
|         if (!this.module) { |         CoreCourseHelper.contextMenuPrefetch(this, this.module, this.courseId, done); | ||||||
|             return; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         CoreCourseHelper.contextMenuPrefetch(this, this.module, this.courseId!, done); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -251,17 +244,13 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy, | |||||||
|      * @param done Function to call when done. |      * @param done Function to call when done. | ||||||
|      */ |      */ | ||||||
|     removeFiles(done?: () => void): void { |     removeFiles(done?: () => void): void { | ||||||
|         if (!this.module) { |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if (this.prefetchStatus == CoreConstants.DOWNLOADING) { |         if (this.prefetchStatus == CoreConstants.DOWNLOADING) { | ||||||
|             CoreDomUtils.showAlertTranslated(undefined, 'core.course.cannotdeletewhiledownloading'); |             CoreDomUtils.showAlertTranslated(undefined, 'core.course.cannotdeletewhiledownloading'); | ||||||
| 
 | 
 | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         CoreCourseHelper.confirmAndRemoveFiles(this.module, this.courseId!, done); |         CoreCourseHelper.confirmAndRemoveFiles(this.module, this.courseId, done); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -309,13 +298,13 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy, | |||||||
|      * @return Promise resolved when done. |      * @return Promise resolved when done. | ||||||
|      */ |      */ | ||||||
|     protected async setStatusListener(): Promise<void> { |     protected async setStatusListener(): Promise<void> { | ||||||
|         if (typeof this.statusObserver != 'undefined' || !this.module) { |         if (typeof this.statusObserver != 'undefined') { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // Listen for changes on this module status.
 |         // Listen for changes on this module status.
 | ||||||
|         this.statusObserver = CoreEvents.on(CoreEvents.PACKAGE_STATUS_CHANGED, (data) => { |         this.statusObserver = CoreEvents.on(CoreEvents.PACKAGE_STATUS_CHANGED, (data) => { | ||||||
|             if (!this.module || data.componentId != this.module.id || data.component != this.component) { |             if (data.componentId != this.module.id || data.component != this.component) { | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
| @ -327,7 +316,7 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy, | |||||||
|         }, this.siteId); |         }, this.siteId); | ||||||
| 
 | 
 | ||||||
|         // Also, get the current status.
 |         // Also, get the current status.
 | ||||||
|         const status = await CoreCourseModulePrefetchDelegate.getModuleStatus(this.module, this.courseId!); |         const status = await CoreCourseModulePrefetchDelegate.getModuleStatus(this.module, this.courseId); | ||||||
| 
 | 
 | ||||||
|         this.currentStatus = status; |         this.currentStatus = status; | ||||||
|         this.showStatus(status); |         this.showStatus(status); | ||||||
| @ -350,17 +339,13 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy, | |||||||
|             failed: false, |             failed: false, | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if (!this.module) { |  | ||||||
|             return result; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         // Get module status to determine if it needs to be downloaded.
 |         // Get module status to determine if it needs to be downloaded.
 | ||||||
|         await this.setStatusListener(); |         await this.setStatusListener(); | ||||||
| 
 | 
 | ||||||
|         if (this.currentStatus != CoreConstants.DOWNLOADED) { |         if (this.currentStatus != CoreConstants.DOWNLOADED) { | ||||||
|             // Download content. This function also loads module contents if needed.
 |             // Download content. This function also loads module contents if needed.
 | ||||||
|             try { |             try { | ||||||
|                 await CoreCourseModulePrefetchDelegate.downloadModule(this.module, this.courseId!); |                 await CoreCourseModulePrefetchDelegate.downloadModule(this.module, this.courseId); | ||||||
| 
 | 
 | ||||||
|                 // If we reach here it means the download process already loaded the contents, no need to do it again.
 |                 // If we reach here it means the download process already loaded the contents, no need to do it again.
 | ||||||
|                 contentsAlreadyLoaded = true; |                 contentsAlreadyLoaded = true; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user