feat: POST method voor class geimplementeerd
This commit is contained in:
parent
a1aaf342d7
commit
79422ab854
8 changed files with 85 additions and 8 deletions
|
@ -17,7 +17,7 @@ export interface AssignmentDTO {
|
|||
export function mapToAssignmentDTOId(assignment: Assignment): AssignmentDTO {
|
||||
return {
|
||||
id: assignment.id!,
|
||||
class: assignment.within.classId,
|
||||
class: assignment.within.classId!,
|
||||
title: assignment.title,
|
||||
description: assignment.description,
|
||||
learningPath: assignment.learningPathHruid,
|
||||
|
@ -29,7 +29,7 @@ export function mapToAssignmentDTOId(assignment: Assignment): AssignmentDTO {
|
|||
export function mapToAssignmentDTO(assignment: Assignment): AssignmentDTO {
|
||||
return {
|
||||
id: assignment.id!,
|
||||
class: assignment.within.classId,
|
||||
class: assignment.within.classId!,
|
||||
title: assignment.title,
|
||||
description: assignment.description,
|
||||
learningPath: assignment.learningPathHruid,
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
import { Collection } from '@mikro-orm/core';
|
||||
import { Class } from '../entities/classes/class.entity.js';
|
||||
import { Student } from '../entities/users/student.entity.js';
|
||||
import { Teacher } from '../entities/users/teacher.entity.js';
|
||||
|
||||
export interface ClassDTO {
|
||||
id: string;
|
||||
|
@ -16,7 +19,7 @@ export interface ClassDTO {
|
|||
|
||||
export function mapToClassDTO(cls: Class): ClassDTO {
|
||||
return {
|
||||
id: cls.classId,
|
||||
id: cls.classId!,
|
||||
displayName: cls.displayName,
|
||||
teachers: cls.teachers.map((teacher) => {
|
||||
return teacher.username;
|
||||
|
@ -27,3 +30,16 @@ export function mapToClassDTO(cls: Class): ClassDTO {
|
|||
joinRequests: [], // TODO
|
||||
};
|
||||
}
|
||||
|
||||
export function mapToClass(
|
||||
classData: ClassDTO,
|
||||
students: Collection<Student>,
|
||||
teachers: Collection<Teacher>
|
||||
): Class {
|
||||
const cls = new Class();
|
||||
cls.displayName = classData.displayName;
|
||||
cls.students = students;
|
||||
cls.teachers = teachers;
|
||||
|
||||
return cls;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ export function mapToGroupDTO(group: Group): GroupDTO {
|
|||
|
||||
export function mapToGroupDTOId(group: Group): GroupDTO {
|
||||
return {
|
||||
assignment: group.assignment.id,
|
||||
assignment: group.assignment.id!,
|
||||
groupNumber: group.groupNumber,
|
||||
members: group.members.map((member) => {
|
||||
return member.username;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue