style: fix linting issues met Prettier

This commit is contained in:
Lint Action 2025-04-17 17:08:18 +00:00
parent 205a4addad
commit 7f782915b6
12 changed files with 30 additions and 32 deletions

View file

@ -4,7 +4,7 @@ import { Class } from '../../entities/classes/class.entity.js';
export class AssignmentRepository extends DwengoEntityRepository<Assignment> {
public async findByClassAndId(within: Class, id: number): Promise<Assignment | null> {
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<Assignment | null> {
return this.findOne({ within: { classId: withinClass }, id: id });
@ -23,7 +23,7 @@ export class AssignmentRepository extends DwengoEntityRepository<Assignment> {
});
}
public async findAllAssignmentsInClass(within: Class): Promise<Assignment[]> {
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<void> {
return this.deleteWhere({ within: within, id: id });

View file

@ -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<Student> = new Collection<Student>(this);
}

View file

@ -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<Teacher>;
@ManyToMany({entity: () => Student, owner: true, inversedBy: 'classes'})
@ManyToMany({ entity: () => Student, owner: true, inversedBy: 'classes' })
students!: Collection<Student>;
}

View file

@ -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<Class>;
@ManyToMany({entity: () => Group, mappedBy: 'members'})
@ManyToMany({ entity: () => Group, mappedBy: 'members' })
groups: Collection<Group> = new Collection<Group>(this);
}

View file

@ -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<Class>;
}

View file

@ -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

View file

@ -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: [],
})
});
}

View file

@ -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),
};
}

View file

@ -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();

View file

@ -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(

View file

@ -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<SubmissionDTO[] | SubmissionDTOId[]> {

View file

@ -10,7 +10,7 @@ export interface GroupDTO {
}
export interface GroupDTOId {
class: string,
assignment: number,
groupNumber: number,
}
class: string;
assignment: number;
groupNumber: number;
}