Skip to content
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
2 changes: 1 addition & 1 deletion api-dto/workspaces/workspace-user-dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export class WorkspaceUserDto {
userId!: number;

@ApiProperty({ nullable: true })
accessLevel!: string | null;
accessLevel!: number | null;
}
8 changes: 6 additions & 2 deletions apps/backend/src/app/admin/admin.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ import { BookletInfoService } from '../database/services/booklet-info.service';
import { UnitInfoService } from '../database/services/unit-info.service';
import FileUpload from '../database/entities/file_upload.entity';
import { ReplayStatisticsController } from './replay-statistics/replay-statistics.controller';
import { VariableBundleModule } from './variable-bundle/variable-bundle.module';
import { VariableBundleController } from './variable-bundle/variable-bundle.controller';

@Module({
imports: [
DatabaseModule,
AuthModule,
HttpModule,
TypeOrmModule.forFeature([FileUpload])
TypeOrmModule.forFeature([FileUpload]),
VariableBundleModule
],
controllers: [
UsersController,
Expand All @@ -54,7 +57,8 @@ import { ReplayStatisticsController } from './replay-statistics/replay-statistic
BookletInfoController,
UnitInfoController,
MissingsProfilesController,
ReplayStatisticsController
ReplayStatisticsController,
VariableBundleController
],
providers: [
BookletInfoService,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { ApiProperty } from '@nestjs/swagger';
import {
IsArray, IsNotEmpty, IsOptional, IsString
} from 'class-validator';
import { VariableDto } from './variable.dto';

export class CreateVariableBundleDto {
@ApiProperty({
description: 'The name of the variable bundle',
example: 'Mathematical Skills'
})
@IsNotEmpty()
@IsString()
name: string;

@ApiProperty({
description: 'The description of the variable bundle',
example: 'Variables for assessing mathematical skills',
required: false
})
@IsOptional()
@IsString()
description?: string;

@ApiProperty({
description: 'The variables in the bundle',
type: [VariableDto],
default: []
})
@IsArray()
variables: VariableDto[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsArray, IsOptional, IsString } from 'class-validator';
import { VariableDto } from './variable.dto';

export class UpdateVariableBundleDto {
@ApiProperty({
description: 'The name of the variable bundle',
example: 'Mathematical Skills',
required: false
})
@IsOptional()
@IsString()
name?: string;

@ApiProperty({
description: 'The description of the variable bundle',
example: 'Variables for assessing mathematical skills',
required: false
})
@IsOptional()
@IsString()
description?: string;

@ApiProperty({
description: 'The variables in the bundle',
type: [VariableDto],
required: false
})
@IsOptional()
@IsArray()
variables?: VariableDto[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { ApiProperty } from '@nestjs/swagger';
import { VariableBundle } from '../../../database/entities/variable-bundle.entity';
import { VariableDto } from './variable.dto';

export class VariableBundleDto {
@ApiProperty({
description: 'The ID of the variable bundle',
example: 1
})
id: number;

@ApiProperty({
description: 'The ID of the workspace',
example: 1
})
workspace_id: number;

@ApiProperty({
description: 'The name of the variable bundle',
example: 'Mathematical Skills'
})
name: string;

@ApiProperty({
description: 'The description of the variable bundle',
example: 'Variables for assessing mathematical skills',
required: false
})
description?: string;

@ApiProperty({
description: 'The variables in the bundle',
type: [VariableDto]
})
variables: VariableDto[];

@ApiProperty({
description: 'The date the variable bundle was created',
example: '2025-08-04T13:58:00.000Z'
})
created_at: Date;

@ApiProperty({
description: 'The date the variable bundle was last updated',
example: '2025-08-04T13:58:00.000Z'
})
updated_at: Date;

/**
* Static method to create a DTO from an entity
*/
static fromEntity(entity: VariableBundle): VariableBundleDto {
const dto = new VariableBundleDto();
dto.id = entity.id;
dto.workspace_id = entity.workspace_id;
dto.name = entity.name;
dto.description = entity.description;
// Transform each variable to a VariableDto
dto.variables = entity.variables.map(v => {
const variableDto = new VariableDto();
variableDto.unitName = v.unitName;
variableDto.variableId = v.variableId;
return variableDto;
});
dto.created_at = entity.created_at;
dto.updated_at = entity.updated_at;
return dto;
}
}
15 changes: 15 additions & 0 deletions apps/backend/src/app/admin/variable-bundle/dto/variable.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ApiProperty } from '@nestjs/swagger';

export class VariableDto {
@ApiProperty({
description: 'The unit name of the variable',
example: 'math101'
})
unitName: string;

@ApiProperty({
description: 'The variable ID',
example: 'addition'
})
variableId: string;
}
Loading