MOBILE-3814 course: Fix empty course index
parent
b4b7ec2faf
commit
857679a89d
|
@ -55,18 +55,19 @@ export class CoreCourseCourseIndexComponent implements OnInit {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
|
if (!this.course || !this.sections) {
|
||||||
if (!this.course || !this.sections || !this.course.enablecompletion || !('courseformatoptions' in this.course) ||
|
|
||||||
!this.course.courseformatoptions) {
|
|
||||||
this.closeModal();
|
this.closeModal();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatOptions = CoreUtils.objectToKeyValueMap(this.course.courseformatoptions, 'name', 'value');
|
let completionEnabled = !!this.course.enablecompletion;
|
||||||
|
if (completionEnabled && 'courseformatoptions' in this.course && this.course.courseformatoptions) {
|
||||||
|
const formatOptions = CoreUtils.objectToKeyValueMap(this.course.courseformatoptions, 'name', 'value');
|
||||||
|
|
||||||
if (!formatOptions || formatOptions.completionusertracked === false) {
|
if (formatOptions) {
|
||||||
return;
|
completionEnabled = !!formatOptions.completionusertracked;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentSection = await CoreCourseFormatDelegate.getCurrentSection(this.course, this.sections);
|
const currentSection = await CoreCourseFormatDelegate.getCurrentSection(this.course, this.sections);
|
||||||
|
@ -85,7 +86,7 @@ export class CoreCourseCourseIndexComponent implements OnInit {
|
||||||
const modules = section.modules
|
const modules = section.modules
|
||||||
.filter((module) => module.visibleoncoursepage !== 0 && !module.noviewlink)
|
.filter((module) => module.visibleoncoursepage !== 0 && !module.noviewlink)
|
||||||
.map((module) => {
|
.map((module) => {
|
||||||
const completionStatus = module.completiondata === undefined ||
|
const completionStatus = !completionEnabled || module.completiondata === undefined ||
|
||||||
module.completiondata.tracking == CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_NONE
|
module.completiondata.tracking == CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_NONE
|
||||||
? undefined
|
? undefined
|
||||||
: module.completiondata.state;
|
: module.completiondata.state;
|
||||||
|
|
Loading…
Reference in New Issue