Merge pull request #3363 from dpalou/MOBILE-4121
MOBILE-4121 completion: Invalidate when data sent in scorm/lessonmain
commit
d2c932b365
|
@ -417,8 +417,16 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo
|
|||
this.dataSentObserver?.off();
|
||||
|
||||
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.
|
||||
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.siteId);
|
||||
|
|
|
@ -16,6 +16,7 @@ import { CoreConstants } from '@/core/constants';
|
|||
import { Component, OnInit, Optional } from '@angular/core';
|
||||
import { CoreCourseModuleMainActivityComponent } from '@features/course/classes/main-activity-component';
|
||||
import { CoreCourseContentsPage } from '@features/course/pages/contents/contents';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
import { IonContent } from '@ionic/angular';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { CoreSync } from '@services/sync';
|
||||
|
@ -542,6 +543,11 @@ export class AddonModScormIndexComponent extends CoreCourseModuleMainActivityCom
|
|||
this.dataSentObserver = CoreEvents.on(AddonModScormProvider.DATA_SENT_EVENT, (data) => {
|
||||
if (data.scormId === this.scorm!.id) {
|
||||
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);
|
||||
|
||||
|
|
|
@ -227,8 +227,7 @@ export class CoreCourseProvider {
|
|||
* @param completion Completion status of the module.
|
||||
*/
|
||||
checkModuleCompletion(courseId: number, completion?: CoreCourseModuleCompletionData): void {
|
||||
if (completion && completion.tracking === CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_AUTOMATIC &&
|
||||
completion.state === CoreCourseModuleCompletionStatus.COMPLETION_INCOMPLETE) {
|
||||
if (completion && this.isIncompleteAutomaticCompletion(completion)) {
|
||||
this.invalidateSections(courseId).finally(() => {
|
||||
CoreEvents.trigger(CoreEvents.COMPLETION_MODULE_VIEWED, {
|
||||
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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue