forked from EVOgeek/Vmeda.Online
		
	MOBILE-4121 completion: Invalidate when data sent in scorm/lesson
This commit is contained in:
		
							parent
							
								
									e7b8a824c2
								
							
						
					
					
						commit
						38cf037162
					
				| @ -417,8 +417,16 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo | |||||||
|         this.dataSentObserver?.off(); |         this.dataSentObserver?.off(); | ||||||
| 
 | 
 | ||||||
|         this.dataSentObserver = CoreEvents.on(AddonModLessonProvider.DATA_SENT_EVENT, (data) => { |         this.dataSentObserver = CoreEvents.on(AddonModLessonProvider.DATA_SENT_EVENT, (data) => { | ||||||
|  |             if (data.lessonId !== this.lesson?.id || data.type === 'launch') { | ||||||
|                 // Ignore launch sending because it only affects timers.
 |                 // Ignore launch sending because it only affects timers.
 | ||||||
|             if (data.lessonId === this.lesson?.id && data.type != 'launch') { |                 return; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             if (data.type === 'finish') { | ||||||
|  |                 // Lesson finished, check completion now.
 | ||||||
|  |                 this.dataSent = false; | ||||||
|  |                 this.checkCompletion(); | ||||||
|  |             } else { | ||||||
|                 this.dataSent = true; |                 this.dataSent = true; | ||||||
|             } |             } | ||||||
|         }, this.siteId); |         }, this.siteId); | ||||||
|  | |||||||
| @ -16,6 +16,7 @@ import { CoreConstants } from '@/core/constants'; | |||||||
| import { Component, OnInit, Optional } from '@angular/core'; | import { Component, OnInit, Optional } from '@angular/core'; | ||||||
| import { CoreCourseModuleMainActivityComponent } from '@features/course/classes/main-activity-component'; | import { CoreCourseModuleMainActivityComponent } from '@features/course/classes/main-activity-component'; | ||||||
| import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; | import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; | ||||||
|  | import { CoreCourse } from '@features/course/services/course'; | ||||||
| import { IonContent } from '@ionic/angular'; | import { IonContent } from '@ionic/angular'; | ||||||
| import { CoreNavigator } from '@services/navigator'; | import { CoreNavigator } from '@services/navigator'; | ||||||
| import { CoreSync } from '@services/sync'; | import { CoreSync } from '@services/sync'; | ||||||
| @ -542,6 +543,11 @@ export class AddonModScormIndexComponent extends CoreCourseModuleMainActivityCom | |||||||
|         this.dataSentObserver = CoreEvents.on(AddonModScormProvider.DATA_SENT_EVENT, (data) => { |         this.dataSentObserver = CoreEvents.on(AddonModScormProvider.DATA_SENT_EVENT, (data) => { | ||||||
|             if (data.scormId === this.scorm!.id) { |             if (data.scormId === this.scorm!.id) { | ||||||
|                 this.dataSent = true; |                 this.dataSent = true; | ||||||
|  | 
 | ||||||
|  |                 if (this.module.completiondata && CoreCourse.isIncompleteAutomaticCompletion(this.module.completiondata)) { | ||||||
|  |                     // Always invalidate section data when data is sent, the SCORM could have a link to a section.
 | ||||||
|  |                     CoreCourse.invalidateSections(this.courseId); | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|         }, this.siteId); |         }, this.siteId); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -227,8 +227,7 @@ export class CoreCourseProvider { | |||||||
|      * @param completion Completion status of the module. |      * @param completion Completion status of the module. | ||||||
|      */ |      */ | ||||||
|     checkModuleCompletion(courseId: number, completion?: CoreCourseModuleCompletionData): void { |     checkModuleCompletion(courseId: number, completion?: CoreCourseModuleCompletionData): void { | ||||||
|         if (completion && completion.tracking === CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_AUTOMATIC && |         if (completion && this.isIncompleteAutomaticCompletion(completion)) { | ||||||
|             completion.state === CoreCourseModuleCompletionStatus.COMPLETION_INCOMPLETE) { |  | ||||||
|             this.invalidateSections(courseId).finally(() => { |             this.invalidateSections(courseId).finally(() => { | ||||||
|                 CoreEvents.trigger(CoreEvents.COMPLETION_MODULE_VIEWED, { |                 CoreEvents.trigger(CoreEvents.COMPLETION_MODULE_VIEWED, { | ||||||
|                     courseId: courseId, |                     courseId: courseId, | ||||||
| @ -238,6 +237,17 @@ export class CoreCourseProvider { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     /** | ||||||
|  |      * Given some completion data, return whether it's an automatic completion that hasn't been completed yet. | ||||||
|  |      * | ||||||
|  |      * @param completion Completion data. | ||||||
|  |      * @return Whether it's an automatic completion that hasn't been completed yet. | ||||||
|  |      */ | ||||||
|  |     isIncompleteAutomaticCompletion(completion: CoreCourseModuleCompletionData): boolean { | ||||||
|  |         return completion.tracking === CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_AUTOMATIC && | ||||||
|  |             completion.state === CoreCourseModuleCompletionStatus.COMPLETION_INCOMPLETE; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     /** |     /** | ||||||
|      * Clear all courses status in a site. |      * Clear all courses status in a site. | ||||||
|      * |      * | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user