diff --git a/src/core/features/course/components/module/core-course-module.html b/src/core/features/course/components/module/core-course-module.html index 209ee9b14..98b0ee2ac 100644 --- a/src/core/features/course/components/module/core-course-module.html +++ b/src/core/features/course/components/module/core-course-module.html @@ -80,14 +80,14 @@ -
-
+
@@ -95,7 +95,7 @@
-
diff --git a/src/core/features/course/components/module/module.ts b/src/core/features/course/components/module/module.ts index cccd63e81..439b3dab6 100644 --- a/src/core/features/course/components/module/module.ts +++ b/src/core/features/course/components/module/module.ts @@ -50,6 +50,11 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy { @Input() showActivityDates = false; // Whether to show activity dates. @Input() showCompletionConditions = false; // Whether to show activity completion conditions. @Input() showLegacyCompletion?: boolean; // Whether to show module completion in the old format. + @Input() showCompletion = true; // Whether to show module completion. + @Input() showAvailability = true; // Whether to show module availability. + @Input() showExtra = true; // Whether to show extra badges. + @Input() showDownloadStatus = true; // Whether to show download status. + @Input() showIndentation = true; // Whether to show indentation @Input() isLastViewed = false; // Whether it's the last module viewed in a course. @Output() completionChanged = new EventEmitter(); // Notify when module completion changes. @HostBinding('class.indented') indented = false; @@ -70,14 +75,24 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy { */ async ngOnInit(): Promise { const site = CoreSites.getRequiredCurrentSite(); - const enableIndentation = await CoreCourse.isCourseIndentationEnabled(site, this.module.course); - this.indented = enableIndentation && this.module.indent > 0; + if (this.showIndentation && this.module.indent > 0) { + this.indented = await CoreCourse.isCourseIndentationEnabled(site, this.module.course); + } else { + this.indented = false; + } this.modNameTranslated = CoreCourse.translateModuleName(this.module.modname, this.module.modplural); - this.showLegacyCompletion = this.showLegacyCompletion ?? - CoreConstants.CONFIG.uselegacycompletion ?? - !site.isVersionGreaterEqualThan('3.11'); - this.checkShowCompletion(); + if (this.showCompletion) { + this.showLegacyCompletion = this.showLegacyCompletion ?? + CoreConstants.CONFIG.uselegacycompletion ?? + !site.isVersionGreaterEqualThan('3.11'); + this.checkShowCompletion(); + } else { + this.showLegacyCompletion = false; + this.showCompletionConditions = false; + this.showManualCompletion = false; + this.hasCompletion = false; + } if (!this.module.handlerData) { return; @@ -86,7 +101,7 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy { this.module.handlerData.a11yTitle = this.module.handlerData.a11yTitle ?? this.module.handlerData.title; this.moduleHasView = CoreCourse.moduleHasView(this.module); - if (this.module.handlerData?.showDownloadButton) { + if (this.showDownloadStatus && this.module.handlerData.showDownloadButton) { const status = await CoreCourseModulePrefetchDelegate.getModuleStatus(this.module, this.module.course); this.updateModuleStatus(status); diff --git a/src/core/features/course/pages/list-mod-type/list-mod-type.html b/src/core/features/course/pages/list-mod-type/list-mod-type.html index edf62be15..8fdd57ed8 100644 --- a/src/core/features/course/pages/list-mod-type/list-mod-type.html +++ b/src/core/features/course/pages/list-mod-type/list-mod-type.html @@ -18,8 +18,17 @@ + + +

+ + +

+
+
- +
diff --git a/src/core/features/course/pages/list-mod-type/list-mod-type.ts b/src/core/features/course/pages/list-mod-type/list-mod-type.ts index c27314dcc..8e9ab9a25 100644 --- a/src/core/features/course/pages/list-mod-type/list-mod-type.ts +++ b/src/core/features/course/pages/list-mod-type/list-mod-type.ts @@ -37,7 +37,7 @@ export class CoreCourseListModTypePage implements OnInit { sections: CoreCourseSection[] = []; title = ''; loaded = false; - courseId?: number; + courseId = 0; protected modName?: string; protected archetypes: Record = {}; // To speed up the check of modules. @@ -64,9 +64,16 @@ export class CoreCourseListModTypePage implements OnInit { * @inheritdoc */ async ngOnInit(): Promise { - this.title = CoreNavigator.getRouteParam('title') || ''; - this.courseId = CoreNavigator.getRouteNumberParam('courseId'); - this.modName = CoreNavigator.getRouteParam('modName'); + try { + this.title = CoreNavigator.getRouteParam('title') || ''; + this.courseId = CoreNavigator.getRequiredRouteParam('courseId'); + this.modName = CoreNavigator.getRequiredRouteParam('modName'); + } catch (error) { + CoreDomUtils.showErrorModal(error); + CoreNavigator.back(); + + return; + } try { await this.fetchData(); @@ -95,7 +102,9 @@ export class CoreCourseListModTypePage implements OnInit { } section.modules = section.modules.filter((mod) => { - if (!CoreCourseHelper.canUserViewModule(mod, section) || !CoreCourse.moduleHasView(mod)) { + if (!CoreCourseHelper.canUserViewModule(mod, section) || + !CoreCourse.moduleHasView(mod) || + mod.visibleoncoursepage === 0) { // Ignore this module. return false; } @@ -110,11 +119,11 @@ export class CoreCourseListModTypePage implements OnInit { ); } - if (this.archetypes[mod.modname] == CoreConstants.MOD_ARCHETYPE_RESOURCE) { + if (this.archetypes[mod.modname] === CoreConstants.MOD_ARCHETYPE_RESOURCE) { return true; } - } else if (mod.modname == this.modName) { + } else if (mod.modname === this.modName) { return true; } }); @@ -137,7 +146,7 @@ export class CoreCourseListModTypePage implements OnInit { * @returns Promise resolved when done. */ async refreshData(refresher: IonRefresher): Promise { - await CoreUtils.ignoreErrors(CoreCourse.invalidateSections(this.courseId || 0)); + await CoreUtils.ignoreErrors(CoreCourse.invalidateSections(this.courseId)); try { await this.fetchData();