From 99428b9e857e462961b952b46b0579cdcb90fe7f Mon Sep 17 00:00:00 2001 From: Michael Linares Date: Tue, 14 Nov 2023 13:57:50 +0100 Subject: [PATCH] Added private filterOutNeXboardFromCopyStatus to copy course function to ignore LESSON_CONTENT_NEXBOARD. --- .../learnroom/controller/rooms.controller.ts | 5 ----- .../learnroom/service/course-copy.service.ts | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/apps/server/src/modules/learnroom/controller/rooms.controller.ts b/apps/server/src/modules/learnroom/controller/rooms.controller.ts index a63e5c5ab5c..fe8f8d67671 100644 --- a/apps/server/src/modules/learnroom/controller/rooms.controller.ts +++ b/apps/server/src/modules/learnroom/controller/rooms.controller.ts @@ -69,11 +69,6 @@ export class RoomsController { @Param() urlParams: RoomUrlParams ): Promise { const copyStatus = await this.courseCopyUc.copyCourse(currentUser.userId, urlParams.roomId); - const newElements = copyStatus.elements?.filter((element) => { - const filterCopyBoard = element.type !== CopyElementType.LESSON_CONTENT_NEXBOARD; - return filterCopyBoard; - }); - copyStatus.elements = newElements; const dto = CopyMapper.mapToResponse(copyStatus); return dto; } diff --git a/apps/server/src/modules/learnroom/service/course-copy.service.ts b/apps/server/src/modules/learnroom/service/course-copy.service.ts index 7e17efcabf5..eb47daa34ab 100644 --- a/apps/server/src/modules/learnroom/service/course-copy.service.ts +++ b/apps/server/src/modules/learnroom/service/course-copy.service.ts @@ -43,16 +43,25 @@ export class CourseCopyService { const existingNames = existingCourses.map((course: Course) => course.name); const copyName = this.copyHelperService.deriveCopyName(newName || originalCourse.name, existingNames); - // copy course and board + // copy course and board const courseCopy = await this.copyCourseEntity({ user, originalCourse, copyName }); const boardStatus = await this.boardCopyService.copyBoard({ originalBoard, destinationCourse: courseCopy, user }); + const filteredBoardStatus = this.filterOutNeXboardFromCopyStatus(boardStatus); const finishedCourseCopy = await this.finishCourseCopying(courseCopy); - const courseStatus = this.deriveCourseStatus(originalCourse, finishedCourseCopy, boardStatus); return courseStatus; } + private filterOutNeXboardFromCopyStatus(boardStatus: CopyStatus): CopyStatus { + if (boardStatus.elements) { + boardStatus.elements = boardStatus.elements.filter(elementStatus => + elementStatus.type !== CopyElementType.LESSON_CONTENT_NEXBOARD + ); + } + return boardStatus; + } + private async copyCourseEntity(params: CourseCopyParams): Promise { const { originalCourse, user, copyName } = params; const courseCopy = new Course({ @@ -110,4 +119,6 @@ export class CourseCopyService { }; return status; } + + }