fix: integratie user + errors gefixt zodat het runt + format
This commit is contained in:
parent
6c4ea0eefb
commit
1b096b411b
55 changed files with 858 additions and 594 deletions
|
@ -1,14 +1,14 @@
|
|||
import { Assignment } from "../entities/assignments/assignment.entity.js";
|
||||
import { GroupDTO, mapToGroupDTO } from "./groups.js";
|
||||
import { Assignment } from '../entities/assignments/assignment.entity.js';
|
||||
import { GroupDTO, mapToGroupDTO } from './group.js';
|
||||
|
||||
export interface AssignmentDTO {
|
||||
id: number,
|
||||
class: string, // id of class 'within'
|
||||
title: string,
|
||||
description: string,
|
||||
learningPath: string,
|
||||
language: string,
|
||||
groups?: GroupDTO[] | string[], // TODO
|
||||
id: number;
|
||||
class: string; // Id of class 'within'
|
||||
title: string;
|
||||
description: string;
|
||||
learningPath: string;
|
||||
language: string;
|
||||
groups?: GroupDTO[] | string[]; // TODO
|
||||
}
|
||||
|
||||
export function mapToAssignmentDTOId(assignment: Assignment): AssignmentDTO {
|
||||
|
@ -19,8 +19,8 @@ export function mapToAssignmentDTOId(assignment: Assignment): AssignmentDTO {
|
|||
description: assignment.description,
|
||||
learningPath: assignment.learningPathHruid,
|
||||
language: assignment.learningPathLanguage,
|
||||
// groups: assignment.groups.map(group => group.groupNumber),
|
||||
}
|
||||
// Groups: assignment.groups.map(group => group.groupNumber),
|
||||
};
|
||||
}
|
||||
|
||||
export function mapToAssignmentDTO(assignment: Assignment): AssignmentDTO {
|
||||
|
@ -31,6 +31,6 @@ export function mapToAssignmentDTO(assignment: Assignment): AssignmentDTO {
|
|||
description: assignment.description,
|
||||
learningPath: assignment.learningPathHruid,
|
||||
language: assignment.learningPathLanguage,
|
||||
// groups: assignment.groups.map(mapToGroupDTO),
|
||||
// Groups: assignment.groups.map(mapToGroupDTO),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Class } from "../entities/classes/class.entity.js";
|
||||
import { Class } from '../entities/classes/class.entity.js';
|
||||
|
||||
export interface ClassDTO {
|
||||
id: string;
|
||||
|
@ -18,8 +18,12 @@ export function mapToClassDTO(cls: Class): ClassDTO {
|
|||
return {
|
||||
id: cls.classId,
|
||||
displayName: cls.displayName,
|
||||
teachers: cls.teachers.map(teacher => teacher.username),
|
||||
students: cls.students.map(student => student.username),
|
||||
teachers: cls.teachers.map((teacher) => {
|
||||
return teacher.username;
|
||||
}),
|
||||
students: cls.students.map((student) => {
|
||||
return student.username;
|
||||
}),
|
||||
joinRequests: [], // TODO
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,25 +1,27 @@
|
|||
import { Group } from "../entities/assignments/group.entity.js";
|
||||
import { AssignmentDTO, mapToAssignmentDTO } from "./assignments.js";
|
||||
import { mapToStudentDTO, StudentDTO } from "./students.js";
|
||||
import { Group } from '../entities/assignments/group.entity.js';
|
||||
import { AssignmentDTO, mapToAssignmentDTO } from './assignment.js';
|
||||
import { mapToStudentDTO, StudentDTO } from './student.js';
|
||||
|
||||
export interface GroupDTO {
|
||||
assignment: number | AssignmentDTO,
|
||||
groupNumber: number,
|
||||
members: string[] | StudentDTO[],
|
||||
};
|
||||
assignment: number | AssignmentDTO;
|
||||
groupNumber: number;
|
||||
members: string[] | StudentDTO[];
|
||||
}
|
||||
|
||||
export function mapToGroupDTO(group: Group): GroupDTO {
|
||||
return {
|
||||
assignment: mapToAssignmentDTO(group.assignment), // ERROR: , group.assignment.within),
|
||||
groupNumber: group.groupNumber,
|
||||
members: group.members.map(mapToStudentDTO),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function mapToGroupDTOId(group: Group): GroupDTO {
|
||||
return {
|
||||
assignment: group.assignment.id,
|
||||
groupNumber: group.groupNumber,
|
||||
members: group.members.map(member => member.username),
|
||||
}
|
||||
members: group.members.map((member) => {
|
||||
return member.username;
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// TODO: implement something like this but with named endpoints
|
||||
export interface List<T> {
|
||||
items: T[],
|
||||
endpoints?: string[],
|
||||
};
|
||||
items: T[];
|
||||
endpoints?: string[];
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import {Question} from "../entities/questions/question.entity";
|
||||
import {Enum, PrimaryKey} from "@mikro-orm/core";
|
||||
import {Language} from "../entities/content/language";
|
||||
import { Question } from '../entities/questions/question.entity.js';
|
||||
|
||||
export interface QuestionDTO {
|
||||
learningObjectHruid: string;
|
||||
|
@ -34,8 +32,17 @@ export function mapToQuestionDTO(question: Question): QuestionDTO {
|
|||
}
|
||||
|
||||
export interface QuestionId {
|
||||
learningObjectHruid: string,
|
||||
learningObjectLanguage: Language,
|
||||
learningObjectVersion: string,
|
||||
sequenceNumber: number
|
||||
learningObjectHruid: string;
|
||||
learningObjectLanguage: string;
|
||||
learningObjectVersion: string;
|
||||
sequenceNumber: number;
|
||||
}
|
||||
|
||||
export function mapToQuestionId(question: QuestionDTO): QuestionId {
|
||||
return {
|
||||
learningObjectHruid: question.learningObjectHruid,
|
||||
learningObjectLanguage: question.learningObjectLanguage,
|
||||
learningObjectVersion: question.learningObjectVersion,
|
||||
sequenceNumber: question.sequenceNumber,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Student } from "../entities/users/student.entity.js";
|
||||
import { Student } from '../entities/users/student.entity.js';
|
||||
|
||||
export interface StudentDTO {
|
||||
id: string;
|
||||
|
|
|
@ -1,22 +1,26 @@
|
|||
import { TeacherInvitation } from "../entities/classes/teacher-invitation.entity.js";
|
||||
import { ClassDTO, mapToClassDTO } from "./classes.js";
|
||||
import { mapToTeacherDTO, TeacherDTO } from "./teacher.js";
|
||||
import { TeacherInvitation } from '../entities/classes/teacher-invitation.entity.js';
|
||||
import { ClassDTO, mapToClassDTO } from './class.js';
|
||||
import { mapToUserDTO, UserDTO } from './user.js';
|
||||
|
||||
export interface TeacherInvitationDTO {
|
||||
sender: string | TeacherDTO,
|
||||
receiver: string | TeacherDTO,
|
||||
class: string | ClassDTO,
|
||||
sender: string | UserDTO;
|
||||
receiver: string | UserDTO;
|
||||
class: string | ClassDTO;
|
||||
}
|
||||
|
||||
export function mapToTeacherInvitationDTO(invitation: TeacherInvitation): TeacherInvitationDTO {
|
||||
export function mapToTeacherInvitationDTO(
|
||||
invitation: TeacherInvitation
|
||||
): TeacherInvitationDTO {
|
||||
return {
|
||||
sender: mapToTeacherDTO(invitation.sender),
|
||||
receiver: mapToTeacherDTO(invitation.receiver),
|
||||
sender: mapToUserDTO(invitation.sender),
|
||||
receiver: mapToUserDTO(invitation.receiver),
|
||||
class: mapToClassDTO(invitation.class),
|
||||
};
|
||||
}
|
||||
|
||||
export function mapToTeacherInvitationDTOIds(invitation: TeacherInvitation): TeacherInvitationDTO {
|
||||
export function mapToTeacherInvitationDTOIds(
|
||||
invitation: TeacherInvitation
|
||||
): TeacherInvitationDTO {
|
||||
return {
|
||||
sender: invitation.sender.username,
|
||||
receiver: invitation.receiver.username,
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
import { Teacher } from "../entities/users/teacher.entity.js";
|
||||
|
||||
/**
|
||||
* Teacher Data Transfer Object
|
||||
*/
|
||||
export interface TeacherDTO {
|
||||
username: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
endpoints?: {
|
||||
self: string;
|
||||
classes: string;
|
||||
questions: string;
|
||||
invitations: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps a Teacher entity to a TeacherDTO
|
||||
*/
|
||||
export function mapToTeacherDTO(teacher: Teacher): TeacherDTO {
|
||||
return {
|
||||
username: teacher.username,
|
||||
firstName: teacher.firstName,
|
||||
lastName: teacher.lastName,
|
||||
};
|
||||
}
|
||||
|
||||
export function mapToTeacher(teacherData: TeacherDTO): Teacher {
|
||||
const teacher = new Teacher();
|
||||
teacher.username = teacherData.username;
|
||||
teacher.firstName = teacherData.firstName;
|
||||
teacher.lastName = teacherData.lastName;
|
||||
|
||||
return teacher;
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
import { User } from "../entities/users/user.entity.js";
|
||||
import { User } from '../entities/users/user.entity.js';
|
||||
|
||||
export interface UserDTO {
|
||||
id?: string,
|
||||
id?: string;
|
||||
username: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
|
@ -22,7 +22,10 @@ export function mapToUserDTO(user: User): UserDTO {
|
|||
};
|
||||
}
|
||||
|
||||
export function mapToUser<T extends User>(userData: UserDTO, userInstance: T): T {
|
||||
export function mapToUser<T extends User>(
|
||||
userData: UserDTO,
|
||||
userInstance: T
|
||||
): T {
|
||||
userInstance.username = userData.username;
|
||||
userInstance.firstName = userData.firstName;
|
||||
userInstance.lastName = userData.lastName;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue