Skip to content

Commit

Permalink
Added private filterOutNeXboardFromCopyStatus to copy course function…
Browse files Browse the repository at this point in the history
… to ignore LESSON_CONTENT_NEXBOARD.
  • Loading branch information
Michaellinaresxk committed Nov 14, 2023
1 parent 897036c commit 99428b9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ export class RoomsController {
@Param() urlParams: RoomUrlParams
): Promise<CopyApiResponse> {
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;
}
Expand Down
15 changes: 13 additions & 2 deletions apps/server/src/modules/learnroom/service/course-copy.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check failure on line 46 in apps/server/src/modules/learnroom/service/course-copy.service.ts

View workflow job for this annotation

GitHub Actions / nest_lint

Delete `↹`
const courseCopy = await this.copyCourseEntity({ user, originalCourse, copyName });
const boardStatus = await this.boardCopyService.copyBoard({ originalBoard, destinationCourse: courseCopy, user });
const filteredBoardStatus = this.filterOutNeXboardFromCopyStatus(boardStatus);

Check failure on line 49 in apps/server/src/modules/learnroom/service/course-copy.service.ts

View workflow job for this annotation

GitHub Actions / nest_lint

'filteredBoardStatus' is assigned a value but never used
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 =>

Check failure on line 58 in apps/server/src/modules/learnroom/service/course-copy.service.ts

View workflow job for this annotation

GitHub Actions / nest_lint

Replace `elementStatus·=>⏎↹↹↹↹` with `⏎↹↹↹↹(elementStatus)·=>·`
elementStatus.type !== CopyElementType.LESSON_CONTENT_NEXBOARD
);
}
return boardStatus;
}

private async copyCourseEntity(params: CourseCopyParams): Promise<Course> {
const { originalCourse, user, copyName } = params;
const courseCopy = new Course({
Expand Down Expand Up @@ -110,4 +119,6 @@ export class CourseCopyService {
};
return status;
}

Check failure on line 121 in apps/server/src/modules/learnroom/service/course-copy.service.ts

View workflow job for this annotation

GitHub Actions / nest_lint

Delete `⏎⏎`


}

0 comments on commit 99428b9

Please sign in to comment.