MOBILE-3213 data: Log activity view in more cases
This commit is contained in:
		
							parent
							
								
									af38ef2383
								
							
						
					
					
						commit
						ece5905b36
					
				| @ -124,18 +124,8 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp | ||||
|         this.selectedGroup = this.group || 0; | ||||
| 
 | ||||
|         this.loadContent(false, true).then(() => { | ||||
|             if (!this.data || !this.data.id) { | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             this.dataProvider.logView(this.data.id, this.data.name).then(() => { | ||||
|                 this.courseProvider.checkModuleCompletion(this.courseId, this.module.completiondata); | ||||
|             }).catch(() => { | ||||
|                 // Ignore errors.
 | ||||
|             }); | ||||
|             return this.logView(true); | ||||
|         }); | ||||
| 
 | ||||
|         // Setup search modal.
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
| @ -362,7 +352,10 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp | ||||
|         this.loaded = false; | ||||
|         this.search.page = page; | ||||
| 
 | ||||
|         return this.fetchEntriesData().catch((message) => { | ||||
|         return this.fetchEntriesData().then(() => { | ||||
|             // Log activity view for coherence with Moodle web.
 | ||||
|             return this.logView(); | ||||
|         }).catch((message) => { | ||||
|             this.domUtils.showErrorModalDefault(message, 'core.course.errorgetmodule', true); | ||||
|         }).finally(() => { | ||||
|             this.loaded = true; | ||||
| @ -392,7 +385,10 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp | ||||
|         this.selectedGroup = groupId; | ||||
|         this.search.page = 0; | ||||
| 
 | ||||
|         return this.fetchEntriesData().catch((message) => { | ||||
|         return this.fetchEntriesData().then(() => { | ||||
|             // Log activity view for coherence with Moodle web.
 | ||||
|             return this.logView(); | ||||
|         }).catch((message) => { | ||||
|             this.domUtils.showErrorModalDefault(message, 'core.course.errorgetmodule', true); | ||||
| 
 | ||||
|             return Promise.reject(null); | ||||
| @ -454,6 +450,26 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp | ||||
|         return result.updated; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Log viewing the activity. | ||||
|      * | ||||
|      * @param checkCompletion Whether to check completion. | ||||
|      * @return Promise resolved when done. | ||||
|      */ | ||||
|     protected logView(checkCompletion?: boolean): Promise<any> { | ||||
|         if (!this.data || !this.data.id) { | ||||
|             return Promise.resolve(); | ||||
|         } | ||||
| 
 | ||||
|         return this.dataProvider.logView(this.data.id, this.data.name).then(() => { | ||||
|             if (checkCompletion) { | ||||
|                 this.courseProvider.checkModuleCompletion(this.courseId, this.module.completiondata); | ||||
|             } | ||||
|         }).catch(() => { | ||||
|             // Ignore errors, the user could be offline.
 | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Component being destroyed. | ||||
|      */ | ||||
|  | ||||
| @ -96,7 +96,9 @@ export class AddonModDataEntryPage implements OnDestroy { | ||||
|      */ | ||||
|     ionViewDidLoad(): void { | ||||
|         this.commentsEnabled = !this.commentsProvider.areCommentsDisabledInSite(); | ||||
|         this.fetchEntryData(); | ||||
|         this.fetchEntryData().then(() => { | ||||
|             this.logView(); | ||||
|         }); | ||||
| 
 | ||||
|         // Refresh data if this discussion is synchronized automatically.
 | ||||
|         this.syncObserver = this.eventsProvider.on(AddonModDataSyncProvider.AUTO_SYNCED, (data) => { | ||||
| @ -199,7 +201,9 @@ export class AddonModDataEntryPage implements OnDestroy { | ||||
|         this.entry = null; | ||||
|         this.entryLoaded = false; | ||||
| 
 | ||||
|         return this.fetchEntryData(); | ||||
|         return this.fetchEntryData().then(() => { | ||||
|             this.logView(); | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
| @ -258,7 +262,9 @@ export class AddonModDataEntryPage implements OnDestroy { | ||||
|         this.entryId = null; | ||||
|         this.entryLoaded = false; | ||||
| 
 | ||||
|         return this.fetchEntryData(); | ||||
|         return this.fetchEntryData().then(() => { | ||||
|             this.logView(); | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
| @ -363,6 +369,21 @@ export class AddonModDataEntryPage implements OnDestroy { | ||||
|         this.dataProvider.invalidateEntryData(this.data.id, this.entryId); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Log viewing the activity. | ||||
|      * | ||||
|      * @return Promise resolved when done. | ||||
|      */ | ||||
|     protected logView(): Promise<any> { | ||||
|         if (!this.data || !this.data.id) { | ||||
|             return Promise.resolve(); | ||||
|         } | ||||
| 
 | ||||
|         return this.dataProvider.logView(this.data.id, this.data.name).catch(() => { | ||||
|             // Ignore errors, the user could be offline.
 | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Component being destroyed. | ||||
|      */ | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user