diff --git a/apps/server/src/modules/common-cartridge/import/common-cartridge-import.types.ts b/apps/server/src/modules/common-cartridge/import/common-cartridge-import.types.ts
index ce86755bb60..75b3bda8f90 100644
--- a/apps/server/src/modules/common-cartridge/import/common-cartridge-import.types.ts
+++ b/apps/server/src/modules/common-cartridge/import/common-cartridge-import.types.ts
@@ -10,7 +10,7 @@ export type CommonCartridgeFileParserOptions = {
export const DEFAULT_FILE_PARSER_OPTIONS: CommonCartridgeFileParserOptions = {
maxSearchDepth: 5,
pathSeparator: '/',
- inputFormat: InputFormat.RICH_TEXT_CK5,
+ inputFormat: InputFormat.RICH_TEXT_CK4,
};
export type CommonCartridgeOrganizationProps = {
@@ -27,7 +27,6 @@ export type CommonCartridgeOrganizationProps = {
export type CommonCartridgeWebContentResourceProps = {
type: CommonCartridgeResourceTypeV1P1.WEB_CONTENT;
- title: string;
html: string;
};
diff --git a/apps/server/src/modules/common-cartridge/import/common-cartridge-resource-factory.spec.ts b/apps/server/src/modules/common-cartridge/import/common-cartridge-resource-factory.spec.ts
index 6f0d867681b..8569df2a2b9 100644
--- a/apps/server/src/modules/common-cartridge/import/common-cartridge-resource-factory.spec.ts
+++ b/apps/server/src/modules/common-cartridge/import/common-cartridge-resource-factory.spec.ts
@@ -168,7 +168,6 @@ describe('CommonCartridgeResourceFactory', () => {
expect(result).toStrictEqual({
type: CommonCartridgeResourceTypeV1P1.WEB_CONTENT,
- title: organizationProps.title,
html: '
Content
',
});
});
@@ -191,7 +190,6 @@ describe('CommonCartridgeResourceFactory', () => {
expect(result).toStrictEqual({
type: CommonCartridgeResourceTypeV1P1.WEB_CONTENT,
- title: organizationProps.title,
html: '',
});
});
diff --git a/apps/server/src/modules/common-cartridge/import/common-cartridge-resource-factory.ts b/apps/server/src/modules/common-cartridge/import/common-cartridge-resource-factory.ts
index b80b9a80f3a..a12842f2b98 100644
--- a/apps/server/src/modules/common-cartridge/import/common-cartridge-resource-factory.ts
+++ b/apps/server/src/modules/common-cartridge/import/common-cartridge-resource-factory.ts
@@ -28,7 +28,7 @@ export class CommonCartridgeResourceFactory {
case CommonCartridgeResourceTypeV1P1.WEB_LINK:
return this.createWebLinkResource(content, title);
case CommonCartridgeResourceTypeV1P1.WEB_CONTENT:
- return this.createWebContentResource(content, title, inputFormat);
+ return this.createWebContentResource(content, inputFormat);
default:
return undefined;
}
@@ -59,7 +59,6 @@ export class CommonCartridgeResourceFactory {
private createWebContentResource(
content: string,
- title: string,
inputFormat: InputFormat
): CommonCartridgeWebContentResourceProps | undefined {
const document = this.tryCreateDocument(content, 'text/html');
@@ -72,7 +71,6 @@ export class CommonCartridgeResourceFactory {
return {
type: CommonCartridgeResourceTypeV1P1.WEB_CONTENT,
- title,
html,
};
}
diff --git a/apps/server/src/modules/common-cartridge/service/common-cartridge.mapper.spec.ts b/apps/server/src/modules/common-cartridge/service/common-cartridge.mapper.spec.ts
index aea5740c1f2..6d042b975e6 100644
--- a/apps/server/src/modules/common-cartridge/service/common-cartridge.mapper.spec.ts
+++ b/apps/server/src/modules/common-cartridge/service/common-cartridge.mapper.spec.ts
@@ -237,7 +237,7 @@ describe('CommonCartridgeExportMapper', () => {
expect(result).toEqual({
identifier: `i${task.id}`,
title: task.name,
- html: `${task.name}
${task.description ?? ''}
`,
+ html: `${task.description ?? ''}
`,
intendedUse: CommonCartridgeIntendedUseType.UNSPECIFIED,
type: CommonCartridgeResourceType.WEB_CONTENT,
});
@@ -252,7 +252,7 @@ describe('CommonCartridgeExportMapper', () => {
expect(result).toEqual({
identifier: `i${task.id}`,
title: task.name,
- html: `${task.name}
${task.description ?? ''}
`,
+ html: `${task.description ?? ''}
`,
intendedUse: CommonCartridgeIntendedUseType.ASSIGNMENT,
type: CommonCartridgeResourceType.WEB_CONTENT,
});
@@ -267,7 +267,7 @@ describe('CommonCartridgeExportMapper', () => {
expect(result).toEqual({
identifier: `i${task.id}`,
title: task.name,
- html: `${task.name}
${task.description ?? ''}
`,
+ html: `${task.description ?? ''}
`,
intendedUse: CommonCartridgeIntendedUseType.UNSPECIFIED,
type: CommonCartridgeResourceType.WEB_CONTENT,
});
diff --git a/apps/server/src/modules/common-cartridge/service/common-cartridge.mapper.ts b/apps/server/src/modules/common-cartridge/service/common-cartridge.mapper.ts
index 08bf79be0e5..c5c793a8c5a 100644
--- a/apps/server/src/modules/common-cartridge/service/common-cartridge.mapper.ts
+++ b/apps/server/src/modules/common-cartridge/service/common-cartridge.mapper.ts
@@ -64,9 +64,7 @@ export class CommonCartridgeExportMapper {
type: CommonCartridgeResourceType.WEB_CONTENT,
identifier: createIdentifier(lessonContent.id),
title: lessonContent.title,
- html: `${lessonContent.title ?? ''}
${
- (lessonContent.content as ComponentTextPropsDto).text ?? ''
- }
`,
+ html: `${(lessonContent.content as ComponentTextPropsDto).text ?? ''}
`,
intendedUse: CommonCartridgeIntendedUseType.UNSPECIFIED,
};
case LessonContentDtoComponentValues.GEO_GEBRA:
@@ -146,7 +144,7 @@ export class CommonCartridgeExportMapper {
type: CommonCartridgeResourceType.WEB_CONTENT,
identifier: createIdentifier(task.id),
title: task.name,
- html: `${task.name}
${task.description ?? ''}
`,
+ html: `${task.description ?? ''}
`,
intendedUse,
};
}
diff --git a/apps/server/src/modules/learnroom/mapper/common-cartridge-import.mapper.spec.ts b/apps/server/src/modules/learnroom/mapper/common-cartridge-import.mapper.spec.ts
index a2515c4d367..bce1e3668f0 100644
--- a/apps/server/src/modules/learnroom/mapper/common-cartridge-import.mapper.spec.ts
+++ b/apps/server/src/modules/learnroom/mapper/common-cartridge-import.mapper.spec.ts
@@ -60,34 +60,34 @@ describe('CommonCartridgeImportMapper', () => {
});
});
});
- });
- describe('mapOrganizationToCard', () => {
- describe('when organization is provided', () => {
+ describe('when organization is provided and withTitle is false', () => {
const setup = () => setupOrganization();
- it('should map organization to card', () => {
+ it('should set the title to an empty string', () => {
const { organization } = setup();
- const result = sut.mapOrganizationToCard(organization);
+ const result = sut.mapOrganizationToCard(organization, false);
expect(result).toEqual({
- title: organization.title,
+ title: '',
height: 150,
});
});
});
+ });
- describe('when organization is provided and withTitle is false', () => {
+ describe('mapOrganizationToCard', () => {
+ describe('when organization is provided', () => {
const setup = () => setupOrganization();
- it('should set the title to an empty string', () => {
+ it('should map organization to card', () => {
const { organization } = setup();
- const result = sut.mapOrganizationToCard(organization, false);
+ const result = sut.mapOrganizationToCard(organization);
expect(result).toEqual({
- title: '',
+ title: organization.title,
height: 150,
});
});
@@ -105,7 +105,7 @@ describe('CommonCartridgeImportMapper', () => {
const result = sut.mapOrganizationToTextElement(organization);
expect(result).toBeInstanceOf(RichTextContentBody);
- expect(result).toEqual({
+ expect(result).toEqual({
text: `${organization.title}`,
inputFormat: InputFormat.RICH_TEXT_CK5_SIMPLE,
});
@@ -156,7 +156,6 @@ describe('CommonCartridgeImportMapper', () => {
it('should return rich text content element body', () => {
const resource: CommonCartridgeImportResourceProps = {
type: CommonCartridgeResourceTypeV1P1.WEB_CONTENT,
- title: faker.lorem.words(3),
html: faker.lorem.paragraph(),
};
@@ -164,8 +163,8 @@ describe('CommonCartridgeImportMapper', () => {
expect(result).toBeInstanceOf(RichTextContentBody);
expect(result).toEqual({
+ inputFormat: InputFormat.RICH_TEXT_CK4,
text: resource.html,
- inputFormat: InputFormat.RICH_TEXT_CK5_SIMPLE,
});
});
});
diff --git a/apps/server/src/modules/learnroom/mapper/common-cartridge-import.mapper.ts b/apps/server/src/modules/learnroom/mapper/common-cartridge-import.mapper.ts
index 826186cd4e8..ac6d6ea27e2 100644
--- a/apps/server/src/modules/learnroom/mapper/common-cartridge-import.mapper.ts
+++ b/apps/server/src/modules/learnroom/mapper/common-cartridge-import.mapper.ts
@@ -1,4 +1,5 @@
import { AnyElementContentBody, ContentElementType, LinkContentBody, RichTextContentBody } from '@modules/board';
+import { CardProps, ColumnProps } from '@modules/board/domain';
import {
CommonCartridgeImportResourceProps,
CommonCartridgeImportWebContentResourceProps,
@@ -11,17 +12,18 @@ import { InputFormat } from '@shared/domain/types';
@Injectable()
export class CommonCartridgeImportMapper {
- public mapOrganizationToColumn(organization: CommonCartridgeOrganizationProps) {
- return {
+ public mapOrganizationToColumn(organization: CommonCartridgeOrganizationProps): Partial {
+ const column = {
title: organization.title,
};
+
+ return column;
}
- public mapOrganizationToCard(organization: CommonCartridgeOrganizationProps, withTitle = true) {
- return {
- title: withTitle ? organization.title : '',
- height: 150,
- };
+ public mapOrganizationToCard(organization: CommonCartridgeOrganizationProps, withTitle = true): Partial {
+ const card = { title: withTitle ? organization.title : '', height: 150 };
+
+ return card;
}
public mapOrganizationToTextElement(organization: CommonCartridgeOrganizationProps): AnyElementContentBody {
@@ -69,7 +71,7 @@ export class CommonCartridgeImportMapper {
const body = new RichTextContentBody();
body.text = resource.html;
- body.inputFormat = InputFormat.RICH_TEXT_CK5_SIMPLE;
+ body.inputFormat = InputFormat.RICH_TEXT_CK4;
return body;
}
diff --git a/apps/server/src/modules/learnroom/service/common-cartridge-import.service.spec.ts b/apps/server/src/modules/learnroom/service/common-cartridge-import.service.spec.ts
index 39b1c20ad64..8d05a62cb88 100644
--- a/apps/server/src/modules/learnroom/service/common-cartridge-import.service.spec.ts
+++ b/apps/server/src/modules/learnroom/service/common-cartridge-import.service.spec.ts
@@ -25,19 +25,14 @@ describe('CommonCartridgeImportService', () => {
const board2Title = '';
const board3Title = 'Spaltenboard 1';
- const column1ofBoard1Title = 'Test Text';
- const column1ofBoard2Title = 'Test Aufgabe';
- const column1ofBoard3Title = 'Spalte 1';
- const column2ofBoard3Title = 'Spalte 2';
- const column3ofBoard3Title = 'Spalte 3';
- const column4ofBoard3Title = 'Spalte 4';
-
- const emptyCardTitle = '';
const card1Title = 'Karte 1';
const card2Title = 'Karte 2';
const card3Title = 'Karte 3';
const card4Title = 'Karte 4';
+ const columnPlaceholderTitle1 = '1';
+ const columnPlaceholderTitle2 = '2';
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
const objectContainingTitle = (title: string) => expect.objectContaining({ title });
@@ -122,27 +117,15 @@ describe('CommonCartridgeImportService', () => {
expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
objectContainingTitle(board1Title),
- objectContainingTitle(column1ofBoard1Title)
+ objectContainingTitle(columnPlaceholderTitle1)
);
expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
objectContainingTitle(board2Title),
- objectContainingTitle(column1ofBoard2Title)
- );
- expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
- objectContainingTitle(board3Title),
- objectContainingTitle(column1ofBoard3Title)
+ objectContainingTitle(columnPlaceholderTitle1)
);
expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
objectContainingTitle(board3Title),
- objectContainingTitle(column2ofBoard3Title)
- );
- expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
- objectContainingTitle(board3Title),
- objectContainingTitle(column3ofBoard3Title)
- );
- expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
- objectContainingTitle(board3Title),
- objectContainingTitle(column4ofBoard3Title)
+ objectContainingTitle(columnPlaceholderTitle1)
);
});
@@ -154,28 +137,20 @@ describe('CommonCartridgeImportService', () => {
expect(spyBuildCard).toHaveBeenCalledTimes(6);
expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
- objectContainingTitle(column1ofBoard1Title),
- objectContainingTitle(emptyCardTitle)
- );
- expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
- objectContainingTitle(column1ofBoard2Title),
- objectContainingTitle(emptyCardTitle)
- );
- expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
- objectContainingTitle(column1ofBoard3Title),
- objectContainingTitle(card1Title)
+ objectContainingTitle(board1Title),
+ objectContainingTitle(columnPlaceholderTitle1)
);
expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
- objectContainingTitle(column2ofBoard3Title),
- objectContainingTitle(card2Title)
+ objectContainingTitle(board2Title),
+ objectContainingTitle(columnPlaceholderTitle1)
);
expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
- objectContainingTitle(column3ofBoard3Title),
- objectContainingTitle(card3Title)
+ objectContainingTitle(board3Title),
+ objectContainingTitle(columnPlaceholderTitle1)
);
expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
- objectContainingTitle(column4ofBoard3Title),
- objectContainingTitle(card4Title)
+ objectContainingTitle(board3Title),
+ objectContainingTitle(columnPlaceholderTitle2)
);
});
@@ -186,10 +161,6 @@ describe('CommonCartridgeImportService', () => {
expect(spyBuildContentElement).toHaveBeenCalledTimes(6);
- expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
- objectContainingTitle(emptyCardTitle),
- expect.any(RichTextElement)
- );
expect(boardNodeServiceMock.addToParent).toHaveBeenCalledWith(
objectContainingTitle(card1Title),
expect.any(RichTextElement)
@@ -209,16 +180,16 @@ describe('CommonCartridgeImportService', () => {
expect(boardNodeServiceMock.updateContent).toHaveBeenCalledTimes(6);
expect(boardNodeServiceMock.updateContent).toHaveBeenCalledWith(expect.any(RichTextElement), {
- text: 'Test TextDies ist ein Textinhalt.
',
- inputFormat: InputFormat.RICH_TEXT_CK5_SIMPLE,
+ text: 'Test Text
Dies ist ein Textinhalt.
',
+ inputFormat: InputFormat.RICH_TEXT_CK4,
});
expect(boardNodeServiceMock.updateContent).toHaveBeenCalledWith(expect.any(RichTextElement), {
- text: 'Test Aufgabe',
- inputFormat: InputFormat.RICH_TEXT_CK5_SIMPLE,
+ text: 'Test Aufgabe
',
+ inputFormat: InputFormat.RICH_TEXT_CK4,
});
expect(boardNodeServiceMock.updateContent).toHaveBeenCalledWith(expect.any(RichTextElement), {
text: 'Karteninhalt von Karte 1
',
- inputFormat: InputFormat.RICH_TEXT_CK5_SIMPLE,
+ inputFormat: InputFormat.RICH_TEXT_CK4,
});
expect(boardNodeServiceMock.updateContent).toHaveBeenCalledWith(expect.any(LinkElement), {
title: 'Example Domain',
diff --git a/apps/server/src/modules/learnroom/service/common-cartridge-import.service.ts b/apps/server/src/modules/learnroom/service/common-cartridge-import.service.ts
index b73e90a5e90..c5b2ce786ce 100644
--- a/apps/server/src/modules/learnroom/service/common-cartridge-import.service.ts
+++ b/apps/server/src/modules/learnroom/service/common-cartridge-import.service.ts
@@ -50,6 +50,7 @@ export class CommonCartridgeImportService {
boardProps: CommonCartridgeImportOrganizationProps,
organizations: CommonCartridgeImportOrganizationProps[]
): Promise {
+ const columnsTitleCounter = 0;
const columnBoard = this.boardNodeFactory.buildColumnBoard({
context: {
type: BoardExternalReferenceType.Course,
@@ -60,14 +61,15 @@ export class CommonCartridgeImportService {
});
await this.boardNodeService.addRoot(columnBoard);
- await this.createColumns(parser, columnBoard, boardProps, organizations);
+ await this.createColumns(parser, columnBoard, boardProps, organizations, columnsTitleCounter);
}
private async createColumns(
parser: CommonCartridgeFileParser,
columnBoard: ColumnBoard,
boardProps: CommonCartridgeImportOrganizationProps,
- organizations: CommonCartridgeImportOrganizationProps[]
+ organizations: CommonCartridgeImportOrganizationProps[],
+ counter: number
): Promise {
const columnsWithResource = organizations.filter(
(organization) =>
@@ -75,7 +77,8 @@ export class CommonCartridgeImportService {
);
for await (const columnWithResource of columnsWithResource) {
- await this.createColumnWithResource(parser, columnBoard, columnWithResource);
+ counter += 1;
+ await this.createColumnWithResource(parser, columnBoard, columnWithResource, counter);
}
const columnsWithoutResource = organizations.filter(
@@ -84,32 +87,33 @@ export class CommonCartridgeImportService {
);
for await (const columnWithoutResource of columnsWithoutResource) {
- await this.createColumn(parser, columnBoard, columnWithoutResource, organizations);
+ counter += 1;
+ await this.createColumn(parser, columnBoard, columnWithoutResource, organizations, counter);
}
}
private async createColumnWithResource(
parser: CommonCartridgeFileParser,
columnBoard: ColumnBoard,
- columnProps: CommonCartridgeImportOrganizationProps
+ columnProps: CommonCartridgeImportOrganizationProps,
+ counter: number
): Promise {
const column = this.boardNodeFactory.buildColumn();
- const { title } = this.mapper.mapOrganizationToColumn(columnProps);
- column.title = title;
+ column.title = `${counter}`;
await this.boardNodeService.addToParent(columnBoard, column);
- await this.createCardWithElement(parser, column, columnProps, false);
+ await this.createCardWithElement(parser, column, columnProps);
}
private async createColumn(
parser: CommonCartridgeFileParser,
columnBoard: ColumnBoard,
columnProps: CommonCartridgeImportOrganizationProps,
- organizations: CommonCartridgeImportOrganizationProps[]
+ organizations: CommonCartridgeImportOrganizationProps[],
+ counter: number
): Promise {
const column = this.boardNodeFactory.buildColumn();
- const { title } = this.mapper.mapOrganizationToColumn(columnProps);
- column.title = title;
await this.boardNodeService.addToParent(columnBoard, column);
+ column.title = `${counter}`;
const cards = organizations.filter(
(organization) => organization.pathDepth === 2 && organization.path.startsWith(columnProps.path)
@@ -118,7 +122,7 @@ export class CommonCartridgeImportService {
const cardsWithResource = cards.filter((card) => card.isResource);
for await (const card of cardsWithResource) {
- await this.createCardWithElement(parser, column, card, true);
+ await this.createCardWithElement(parser, column, card);
}
const cardsWithoutResource = cards.filter((card) => !card.isResource);
@@ -131,13 +135,11 @@ export class CommonCartridgeImportService {
private async createCardWithElement(
parser: CommonCartridgeFileParser,
column: Column,
- cardProps: CommonCartridgeImportOrganizationProps,
- withTitle = true
+ cardProps: CommonCartridgeImportOrganizationProps
): Promise {
const card = this.boardNodeFactory.buildCard();
- const { title, height } = this.mapper.mapOrganizationToCard(cardProps, withTitle);
+ const { title } = this.mapper.mapOrganizationToCard(cardProps);
card.title = title;
- card.height = height;
await this.boardNodeService.addToParent(column, card);
const resource = parser.getResource(cardProps);
const contentElementType = this.mapper.mapResourceTypeToContentElementType(resource?.type);
@@ -158,9 +160,8 @@ export class CommonCartridgeImportService {
organizations: CommonCartridgeImportOrganizationProps[]
): Promise {
const card = this.boardNodeFactory.buildCard();
- const { title, height } = this.mapper.mapOrganizationToCard(cardProps, true);
+ const { title } = this.mapper.mapOrganizationToCard(cardProps);
card.title = title;
- card.height = height;
await this.boardNodeService.addToParent(column, card);
const cardElements = organizations.filter(