From 7f782915b6e3a1d9c2f3c707b85b7fe5db6b3bac Mon Sep 17 00:00:00 2001 From: Lint Action Date: Thu, 17 Apr 2025 17:08:18 +0000 Subject: [PATCH] style: fix linting issues met Prettier --- .../src/data/assignments/assignment-repository.ts | 4 ++-- backend/src/entities/assignments/group.entity.ts | 4 ++-- backend/src/entities/classes/class.entity.ts | 4 ++-- backend/src/entities/users/student.entity.ts | 4 ++-- backend/src/entities/users/teacher.entity.ts | 2 +- backend/src/exceptions/server-error-exception.ts | 2 +- backend/src/interfaces/assignment.ts | 14 +++++++------- backend/src/interfaces/group.ts | 3 +-- backend/src/services/assignments.ts | 7 +++---- backend/src/services/groups.ts | 6 +++--- backend/src/services/students.ts | 4 ++-- common/src/interfaces/group.ts | 8 ++++---- 12 files changed, 30 insertions(+), 32 deletions(-) diff --git a/backend/src/data/assignments/assignment-repository.ts b/backend/src/data/assignments/assignment-repository.ts index bdfa9fa7..1c8bb504 100644 --- a/backend/src/data/assignments/assignment-repository.ts +++ b/backend/src/data/assignments/assignment-repository.ts @@ -4,7 +4,7 @@ import { Class } from '../../entities/classes/class.entity.js'; export class AssignmentRepository extends DwengoEntityRepository { public async findByClassAndId(within: Class, id: number): Promise { - return this.findOne({ within: within, id: id }, { populate: [ "groups", "groups.members" ]}); + return this.findOne({ within: within, id: id }, { populate: ['groups', 'groups.members'] }); } public async findByClassIdAndAssignmentId(withinClass: string, id: number): Promise { return this.findOne({ within: { classId: withinClass }, id: id }); @@ -23,7 +23,7 @@ export class AssignmentRepository extends DwengoEntityRepository { }); } public async findAllAssignmentsInClass(within: Class): Promise { - return this.findAll({ where: { within: within }, populate: [ "groups", "groups.members" ] }); + return this.findAll({ where: { within: within }, populate: ['groups', 'groups.members'] }); } public async deleteByClassAndId(within: Class, id: number): Promise { return this.deleteWhere({ within: within, id: id }); diff --git a/backend/src/entities/assignments/group.entity.ts b/backend/src/entities/assignments/group.entity.ts index d27821c3..62d5fee9 100644 --- a/backend/src/entities/assignments/group.entity.ts +++ b/backend/src/entities/assignments/group.entity.ts @@ -16,14 +16,14 @@ export class Group { @ManyToOne({ entity: () => Assignment, - primary: true + primary: true, }) assignment!: Assignment; @ManyToMany({ entity: () => Student, owner: true, - inversedBy: "groups" + inversedBy: 'groups', }) members: Collection = new Collection(this); } diff --git a/backend/src/entities/classes/class.entity.ts b/backend/src/entities/classes/class.entity.ts index 7ad66c52..b2c59ade 100644 --- a/backend/src/entities/classes/class.entity.ts +++ b/backend/src/entities/classes/class.entity.ts @@ -14,9 +14,9 @@ export class Class { @Property({ type: 'string' }) displayName!: string; - @ManyToMany({entity: () => Teacher, owner: true, inversedBy: 'classes'}) + @ManyToMany({ entity: () => Teacher, owner: true, inversedBy: 'classes' }) teachers!: Collection; - @ManyToMany({entity: () => Student, owner: true, inversedBy: 'classes'}) + @ManyToMany({ entity: () => Student, owner: true, inversedBy: 'classes' }) students!: Collection; } diff --git a/backend/src/entities/users/student.entity.ts b/backend/src/entities/users/student.entity.ts index 2c4cfb68..9f294d3c 100644 --- a/backend/src/entities/users/student.entity.ts +++ b/backend/src/entities/users/student.entity.ts @@ -8,9 +8,9 @@ import { StudentRepository } from '../../data/users/student-repository.js'; repository: () => StudentRepository, }) export class Student extends User { - @ManyToMany({entity: () => Class, mappedBy: 'students'}) + @ManyToMany({ entity: () => Class, mappedBy: 'students' }) classes!: Collection; - @ManyToMany({entity: () => Group, mappedBy: 'members'}) + @ManyToMany({ entity: () => Group, mappedBy: 'members' }) groups: Collection = new Collection(this); } diff --git a/backend/src/entities/users/teacher.entity.ts b/backend/src/entities/users/teacher.entity.ts index 900e3610..8fbe5e51 100644 --- a/backend/src/entities/users/teacher.entity.ts +++ b/backend/src/entities/users/teacher.entity.ts @@ -5,6 +5,6 @@ import { TeacherRepository } from '../../data/users/teacher-repository.js'; @Entity({ repository: () => TeacherRepository }) export class Teacher extends User { - @ManyToMany({entity: () => Class, mappedBy: 'teachers'}) + @ManyToMany({ entity: () => Class, mappedBy: 'teachers' }) classes!: Collection; } diff --git a/backend/src/exceptions/server-error-exception.ts b/backend/src/exceptions/server-error-exception.ts index 76850a50..04db25fe 100644 --- a/backend/src/exceptions/server-error-exception.ts +++ b/backend/src/exceptions/server-error-exception.ts @@ -1,4 +1,4 @@ -import { ExceptionWithHttpState } from "./exception-with-http-state"; +import { ExceptionWithHttpState } from './exception-with-http-state'; /** * Exception for HTTP 500 Internal Server Error diff --git a/backend/src/interfaces/assignment.ts b/backend/src/interfaces/assignment.ts index 2df9d8bd..167f943f 100644 --- a/backend/src/interfaces/assignment.ts +++ b/backend/src/interfaces/assignment.ts @@ -9,11 +9,11 @@ import { getAssignmentHandler } from '../controllers/assignments.js'; import { getAssignmentRepository, getClassRepository } from '../data/repositories.js'; export function mapToAssignmentDTOId(assignment: Assignment): AssignmentDTOId { - return { - id: assignment.id!, - within: assignment.within.classId!, - }; - } + return { + id: assignment.id!, + within: assignment.within.classId!, + }; +} export function mapToAssignmentDTO(assignment: Assignment): AssignmentDTO { return { @@ -23,7 +23,7 @@ export function mapToAssignmentDTO(assignment: Assignment): AssignmentDTO { description: assignment.description, learningPath: assignment.learningPathHruid, language: assignment.learningPathLanguage, - groups: assignment.groups.map(group => mapToGroupDTO(group, assignment.within)), + groups: assignment.groups.map((group) => mapToGroupDTO(group, assignment.within)), }; } @@ -35,5 +35,5 @@ export function mapToAssignment(assignmentData: AssignmentDTO, cls: Class): Assi learningPathHruid: assignmentData.learningPath, learningPathLanguage: languageMap[assignmentData.language], groups: [], - }) + }); } diff --git a/backend/src/interfaces/group.ts b/backend/src/interfaces/group.ts index 1d15b459..d886c204 100644 --- a/backend/src/interfaces/group.ts +++ b/backend/src/interfaces/group.ts @@ -25,8 +25,7 @@ export function mapToGroupDTO(group: Group, cls: Class): GroupDTO { class: cls.classId!, assignment: group.assignment.id!, groupNumber: group.groupNumber!, - members: group.members.map(mapToStudentDTO) - + members: group.members.map(mapToStudentDTO), }; } diff --git a/backend/src/services/assignments.ts b/backend/src/services/assignments.ts index a3992344..2141671d 100644 --- a/backend/src/services/assignments.ts +++ b/backend/src/services/assignments.ts @@ -58,17 +58,16 @@ export async function createAssignment(classid: string, assignmentData: Assignme const assignment = mapToAssignment(assignmentData, cls); await assignmentRepository.save(assignment); - if (assignmentData.groups) { /* For some reason when trying to add groups, it does not work when using the original assignment variable. The assignment needs to be refetched in order for it to work. */ - + const assignmentCopy = await assignmentRepository.findByClassAndId(cls, assignment.id!); - + if (assignmentCopy === null) { - throw new ServerErrorException("Something has gone horribly wrong. Could not find newly added assignment which is needed to add groups."); + throw new ServerErrorException('Something has gone horribly wrong. Could not find newly added assignment which is needed to add groups.'); } const groupRepository = getGroupRepository(); diff --git a/backend/src/services/groups.ts b/backend/src/services/groups.ts index 0bda8237..5382b608 100644 --- a/backend/src/services/groups.ts +++ b/backend/src/services/groups.ts @@ -68,7 +68,7 @@ export async function createGroup(groupData: GroupDTO, classid: string, assignme const groupRepository = getGroupRepository(); const newGroup = groupRepository.create({ assignment: assignment, - members: members + members: members, }); await groupRepository.save(newGroup); @@ -83,10 +83,10 @@ export async function getAllGroups(classId: string, assignmentNumber: number, fu const groups = await groupRepository.findAllGroupsForAssignment(assignment); if (full) { - return groups.map(group => mapToGroupDTO(group, assignment.within)); + return groups.map((group) => mapToGroupDTO(group, assignment.within)); } - return groups.map(group => mapToGroupDTOId(group, assignment.within)); + return groups.map((group) => mapToGroupDTOId(group, assignment.within)); } export async function getGroupSubmissions( diff --git a/backend/src/services/students.ts b/backend/src/services/students.ts index c0c64400..4052b577 100644 --- a/backend/src/services/students.ts +++ b/backend/src/services/students.ts @@ -104,10 +104,10 @@ export async function getStudentGroups(username: string, full: boolean): Promise const groups = await groupRepository.findAllGroupsWithStudent(student); if (full) { - return groups.map(group => mapToGroupDTO(group, group.assignment.within)); + return groups.map((group) => mapToGroupDTO(group, group.assignment.within)); } - return groups.map(group => mapToGroupDTOId(group, group.assignment.within)); + return groups.map((group) => mapToGroupDTOId(group, group.assignment.within)); } export async function getStudentSubmissions(username: string, full: boolean): Promise { diff --git a/common/src/interfaces/group.ts b/common/src/interfaces/group.ts index cd6e9a3a..77721a1a 100644 --- a/common/src/interfaces/group.ts +++ b/common/src/interfaces/group.ts @@ -10,7 +10,7 @@ export interface GroupDTO { } export interface GroupDTOId { - class: string, - assignment: number, - groupNumber: number, -} \ No newline at end of file + class: string; + assignment: number; + groupNumber: number; +}