MOBILE-4483 completion: Check isoverallcomplete to mark as completed
parent
cbbf61088a
commit
2d317e3857
|
@ -16,7 +16,6 @@ import { Component, ElementRef, Input, OnInit } from '@angular/core';
|
|||
import {
|
||||
CoreCourse,
|
||||
CoreCourseModuleCompletionStatus,
|
||||
CoreCourseModuleCompletionTracking,
|
||||
CoreCourseProvider,
|
||||
} from '@features/course/services/course';
|
||||
import { CoreCourseHelper, CoreCourseModuleData, CoreCourseSection } from '@features/course/services/course-helper';
|
||||
|
@ -88,10 +87,9 @@ export class CoreCourseCourseIndexComponent implements OnInit {
|
|||
const modules = section.modules
|
||||
.filter((module) => this.renderModule(section, module))
|
||||
.map((module) => {
|
||||
const completionStatus = !completionEnabled || module.completiondata === undefined ||
|
||||
module.completiondata.tracking == CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_NONE
|
||||
? undefined
|
||||
: module.completiondata.state;
|
||||
const completionStatus = completionEnabled
|
||||
? CoreCourseHelper.getCompletionStatus(module.completiondata)
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
id: module.id,
|
||||
|
|
|
@ -17,7 +17,6 @@ import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChange } from '@a
|
|||
import { CoreCourseModuleCompletionBaseComponent } from '@features/course/classes/module-completion';
|
||||
import {
|
||||
CoreCourseModuleCompletionStatus,
|
||||
CoreCourseModuleCompletionTracking,
|
||||
} from '@features/course/services/course';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreCourseModuleCompletionDetailsComponent } from '../module-completion-details/module-completion-details';
|
||||
|
@ -87,9 +86,7 @@ export class CoreCourseModuleCompletionComponent
|
|||
return;
|
||||
}
|
||||
|
||||
const completionStatus = this.completion.tracking == CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_NONE
|
||||
? undefined
|
||||
: this.completion.state;
|
||||
const completionStatus = CoreCourseHelper.getCompletionStatus(this.completion);
|
||||
|
||||
this.completed = completionStatus !== CoreCourseModuleCompletionStatus.COMPLETION_INCOMPLETE &&
|
||||
completionStatus !== CoreCourseModuleCompletionStatus.COMPLETION_COMPLETE_FAIL;
|
||||
|
|
|
@ -2082,6 +2082,29 @@ export class CoreCourseHelperProvider {
|
|||
return !!adminOptions[courseId]?.['reports'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the completion status of a module.
|
||||
*
|
||||
* @param completion Completion data.
|
||||
* @returns Completion status or undefined if not available.
|
||||
*/
|
||||
getCompletionStatus(completion?: CoreCourseModuleCompletionData): CoreCourseModuleCompletionStatus | undefined {
|
||||
if (completion === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (completion.tracking === CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_NONE) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (completion.isoverallcomplete === true) {
|
||||
// If the module is marked as overall complete, we'll show it as complete.
|
||||
return CoreCourseModuleCompletionStatus.COMPLETION_COMPLETE;
|
||||
}
|
||||
|
||||
return completion.state;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const CoreCourseHelper = makeSingleton(CoreCourseHelperProvider);
|
||||
|
|
Loading…
Reference in New Issue