Merge pull request #3608 from moodlehq/MOBILE-4277

MOBILE-4277 course: Show modules in course index
main
Dani Palou 2023-04-19 08:09:28 +02:00 committed by GitHub
commit 6b121f4ec1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 4 deletions

View File

@ -441,8 +441,10 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
await CoreCourseModuleDelegate.getModuleDataFor(module.modname, module, this.course.id);
}
if (CoreCourseHelper.canUserViewModule(module, section) && module.handlerData?.action) {
module.handlerData.action(data.event, module, module.course);
if (CoreCourseHelper.canUserViewModule(module, section)) {
this.scrollToModule(module.id);
module.handlerData?.action?.(data.event, module, module.course);
}
this.moduleId = data.moduleId;

View File

@ -18,9 +18,10 @@ import {
CoreCourseModuleCompletionTracking,
CoreCourseProvider,
} from '@features/course/services/course';
import { CoreCourseHelper, CoreCourseSection } from '@features/course/services/course-helper';
import { CoreCourseHelper, CoreCourseModuleData, CoreCourseSection } from '@features/course/services/course-helper';
import { CoreCourseFormatDelegate } from '@features/course/services/format-delegate';
import { CoreCourseAnyCourseData } from '@features/courses/services/courses';
import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { ModalController } from '@singletons';
import { CoreDom } from '@singletons/dom';
@ -79,7 +80,7 @@ export class CoreCourseCourseIndexComponent implements OnInit {
.filter((section) => !CoreCourseHelper.isSectionStealth(section))
.map((section) => {
const modules = section.modules
.filter((module) => !CoreCourseHelper.isModuleStealth(module, section) && !module.noviewlink)
.filter((module) => this.renderModule(section, module))
.map((module) => {
const completionStatus = !completionEnabled || module.completiondata === undefined ||
module.completiondata.tracking == CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_NONE
@ -155,6 +156,27 @@ export class CoreCourseCourseIndexComponent implements OnInit {
ModalController.dismiss({ event, sectionId, moduleId });
}
/**
* Check whether a module should be rendered or not.
*
* @param section Section.
* @param module Module
* @returns Whether the module should be rendered or not.
*/
protected renderModule(section: CoreCourseSection, module: CoreCourseModuleData): boolean {
if (CoreCourseHelper.isModuleStealth(module, section)) {
return false;
}
const site = CoreSites.getRequiredCurrentSite();
if (site.isVersionGreaterEqualThan('4.2')) {
return true;
}
return !module.noviewlink;
}
}
type CourseIndexSection = {