From 2d480a29b68b4159200d1bd815e489ff7302a431 Mon Sep 17 00:00:00 2001 From: Firas Shmit Date: Fri, 13 Dec 2024 16:18:11 +0100 Subject: [PATCH] EW-1060 modified linked task of topic --- .../lesson-client/dto/lesson.dto.ts | 2 +- .../lesson-client/mapper/lesson-dto.mapper.ts | 1 + .../common-cartridge-export.service.spec.ts | 28 ++----------------- .../common-cartridge-export.service.ts | 2 +- 4 files changed, 5 insertions(+), 28 deletions(-) diff --git a/apps/server/src/modules/common-cartridge/common-cartridge-client/lesson-client/dto/lesson.dto.ts b/apps/server/src/modules/common-cartridge/common-cartridge-client/lesson-client/dto/lesson.dto.ts index 69935291c5..1385d6136e 100644 --- a/apps/server/src/modules/common-cartridge/common-cartridge-client/lesson-client/dto/lesson.dto.ts +++ b/apps/server/src/modules/common-cartridge/common-cartridge-client/lesson-client/dto/lesson.dto.ts @@ -19,7 +19,7 @@ export class LessonDto { public materials: LessonMaterialsDto[]; - public linkedTasks?: LessonLinkedTaskDto[]; + public linkedTasks: LessonLinkedTaskDto[]; constructor(props: LessonDto) { this.lessonId = props.lessonId; diff --git a/apps/server/src/modules/common-cartridge/common-cartridge-client/lesson-client/mapper/lesson-dto.mapper.ts b/apps/server/src/modules/common-cartridge/common-cartridge-client/lesson-client/mapper/lesson-dto.mapper.ts index a587c98459..aeeeba2cf3 100644 --- a/apps/server/src/modules/common-cartridge/common-cartridge-client/lesson-client/mapper/lesson-dto.mapper.ts +++ b/apps/server/src/modules/common-cartridge/common-cartridge-client/lesson-client/mapper/lesson-dto.mapper.ts @@ -50,6 +50,7 @@ export class LessonDtoMapper { contents: lessonResponse.contents .map((content) => this.mapToLessenContentDto(content)) .filter((contetnDto) => contetnDto !== null), + linkedTasks: [], materials: lessonResponse.materials.map((material) => this.mapToLessonMaterialDto(material)), }); diff --git a/apps/server/src/modules/common-cartridge/service/common-cartridge-export.service.spec.ts b/apps/server/src/modules/common-cartridge/service/common-cartridge-export.service.spec.ts index ffc209887a..769de8f23e 100644 --- a/apps/server/src/modules/common-cartridge/service/common-cartridge-export.service.spec.ts +++ b/apps/server/src/modules/common-cartridge/service/common-cartridge-export.service.spec.ts @@ -185,7 +185,7 @@ describe('CommonCartridgeExportService', () => { const { archive, lesson } = await setup(); const manifest = archive.getEntry('imsmanifest.xml')?.getData().toString(); - lesson.linkedTasks?.forEach((linkedTask) => { + lesson.linkedTasks.forEach((linkedTask) => { expect(manifest).toContain(`${linkedTask.name}`); }); }); @@ -254,7 +254,7 @@ describe('CommonCartridgeExportService', () => { const { archive, lesson } = await setup(); const manifest = archive.getEntry('imsmanifest.xml')?.getData().toString(); - lesson.linkedTasks?.forEach((linkedTask) => { + lesson.linkedTasks.forEach((linkedTask) => { expect(manifest).toContain(`${linkedTask.name}`); }); }); @@ -337,29 +337,5 @@ describe('CommonCartridgeExportService', () => { ); }); }); - - describe('when topics has no linked tasks', () => { - const setup = async () => setupParams(CommonCartridgeVersion.V_1_1_0, false, true, true); - - it('should add lesson without linked tasks', async () => { - const { archive, lesson } = await setup(); - lesson.linkedTasks = undefined; - - expect(getFileContent(archive, 'imsmanifest.xml')).not.toContain(createXmlString('title', lesson.name)); - }); - }); - - describe('when columnBoards has no cards', () => { - const setup = async () => setupParams(CommonCartridgeVersion.V_1_1_0, true, true, false); - - it('should add column boards without cards', async () => { - const { archive, boardSkeleton } = await setup(); - boardSkeleton.columns[0].cards = []; - - expect(getFileContent(archive, 'imsmanifest.xml')).not.toContain( - createXmlString('title', boardSkeleton.columns[0].title) - ); - }); - }); }); }); diff --git a/apps/server/src/modules/common-cartridge/service/common-cartridge-export.service.ts b/apps/server/src/modules/common-cartridge/service/common-cartridge-export.service.ts index 0628e8579b..5a708fda0d 100644 --- a/apps/server/src/modules/common-cartridge/service/common-cartridge-export.service.ts +++ b/apps/server/src/modules/common-cartridge/service/common-cartridge-export.service.ts @@ -106,7 +106,7 @@ export class CommonCartridgeExportService { this.addComponentToOrganization(content, lessonsOrganization); }); - lesson.linkedTasks?.forEach((task) => { + lesson.linkedTasks.forEach((task) => { lessonsOrganization.addResource(this.mapper.mapLinkedTaskToResource(task, version)); }); });