MOBILE-3213 course: Pass section on activities block

main
Pau Ferrer Ocaña 2019-12-13 13:22:44 +01:00
parent 9ee135e0b5
commit 1d8cf13348
2 changed files with 15 additions and 18 deletions

View File

@ -8,11 +8,13 @@
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content> <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
</ion-refresher> </ion-refresher>
<core-loading [hideUntil]="loaded"> <core-loading [hideUntil]="loaded">
<core-empty-box *ngIf="!modules || !modules.length" icon="qr-scanner" [message]="'core.course.nocontentavailable' | translate"></core-empty-box> <core-empty-box *ngIf="!sections || !sections.length" icon="qr-scanner" [message]="'core.course.nocontentavailable' | translate"></core-empty-box>
<ion-list> <ion-list>
<ng-container *ngFor="let module of modules"> <ng-container text-wrap *ngFor="let section of sections" >
<core-course-module *ngIf="module.visibleoncoursepage !== 0" [module]="module" [courseId]="courseId" [downloadEnabled]="downloadEnabled"></core-course-module> <ng-container *ngFor="let module of section.modules">
<core-course-module *ngIf="module.visibleoncoursepage !== 0" [module]="module" [section]="section" [courseId]="courseId" [downloadEnabled]="downloadEnabled"></core-course-module>
</ng-container>
</ng-container> </ng-container>
</ion-list> </ion-list>
</core-loading> </core-loading>

View File

@ -31,7 +31,7 @@ import { CoreConstants } from '@core/constants';
}) })
export class CoreCourseListModTypePage { export class CoreCourseListModTypePage {
modules = []; sections = [];
title: string; title: string;
loaded = false; loaded = false;
downloadEnabled = false; downloadEnabled = false;
@ -69,17 +69,15 @@ export class CoreCourseListModTypePage {
// Get all the modules in the course. // Get all the modules in the course.
return this.courseProvider.getSections(this.courseId, false, true).then((sections) => { return this.courseProvider.getSections(this.courseId, false, true).then((sections) => {
this.modules = []; this.sections = sections.filter((section) => {
sections.forEach((section) => {
if (!section.modules) { if (!section.modules) {
return; return false;
} }
section.modules.forEach((mod) => { section.modules = section.modules.filter((mod) => {
if (mod.uservisible === false || !this.courseProvider.moduleHasView(mod)) { if (mod.uservisible === false || !this.courseProvider.moduleHasView(mod)) {
// Ignore this module. // Ignore this module.
return; return false;
} }
if (this.modName === 'resources') { if (this.modName === 'resources') {
@ -90,21 +88,18 @@ export class CoreCourseListModTypePage {
} }
if (this.archetypes[mod.modname] == CoreConstants.MOD_ARCHETYPE_RESOURCE) { if (this.archetypes[mod.modname] == CoreConstants.MOD_ARCHETYPE_RESOURCE) {
this.modules.push(mod); return true;
} }
} else if (mod.modname == this.modName) { } else if (mod.modname == this.modName) {
this.modules.push(mod); return true;
} }
}); });
return section.modules.length > 0;
}); });
// Get the handler data for the modules. this.courseHelper.addHandlerDataForModules(this.sections, this.courseId);
const fakeSection = {
visible: 1,
modules: this.modules
};
this.courseHelper.addHandlerDataForModules([fakeSection], this.courseId);
}).catch((error) => { }).catch((error) => {
this.domUtils.showErrorModalDefault(error, 'Error getting data'); this.domUtils.showErrorModalDefault(error, 'Error getting data');
}); });