Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BC-5119-Prevent-creating-new-neXboards (Server) #4522

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 0 additions & 93 deletions .vscode/launch.default.json

This file was deleted.

23 changes: 0 additions & 23 deletions .vscode/settings.default.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class BoardCopyService {
const references: BoardElement[] = this.extractReferences(elements);

let boardCopy: Board = new Board({ references, course: destinationCourse });

let status: CopyStatus = {
title: 'board',
type: CopyElementType.BOARD,
Expand Down Expand Up @@ -84,7 +85,6 @@ export class BoardCopyService {
if (element.target === undefined) {
return Promise.reject(new Error('Broken boardelement - not pointing to any target entity'));
}

if (element.boardElementType === BoardElementType.Task && isTask(element.target)) {
return this.copyTask(element.target, user, destinationCourse).then((status) => [pos, status]);
}
Expand Down
15 changes: 12 additions & 3 deletions apps/server/src/modules/learnroom/service/course-copy.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,23 @@ export class CourseCopyService {
// 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);
Michaellinaresxk marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too should use the new feature flag condition...

const finishedCourseCopy = await this.finishCourseCopying(courseCopy);

const courseStatus = this.deriveCourseStatus(originalCourse, finishedCourseCopy, boardStatus);
const courseStatus = this.deriveCourseStatus(originalCourse, finishedCourseCopy, filteredBoardStatus);

return courseStatus;
}

// Exclude LESSON_CONTENT_NEXBOARD from boardStatus
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<Course> {
const { originalCourse, user, copyName } = params;
const courseCopy = new Course({
Expand Down Expand Up @@ -100,7 +110,6 @@ export class CourseCopyService {
if (courseGroupsExist) {
elements.push({ type: CopyElementType.COURSEGROUP_GROUP, status: CopyStatusEnum.NOT_IMPLEMENTED });
}

const status = {
title: courseCopy.name,
type: CopyElementType.COURSE,
Expand Down
Loading
Loading