style: fix linting issues met Prettier
This commit is contained in:
parent
205a4addad
commit
7f782915b6
12 changed files with 30 additions and 32 deletions
|
@ -4,7 +4,7 @@ import { Class } from '../../entities/classes/class.entity.js';
|
||||||
|
|
||||||
export class AssignmentRepository extends DwengoEntityRepository<Assignment> {
|
export class AssignmentRepository extends DwengoEntityRepository<Assignment> {
|
||||||
public async findByClassAndId(within: Class, id: number): Promise<Assignment | null> {
|
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> {
|
public async findByClassIdAndAssignmentId(withinClass: string, id: number): Promise<Assignment | null> {
|
||||||
return this.findOne({ within: { classId: withinClass }, id: id });
|
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[]> {
|
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> {
|
public async deleteByClassAndId(within: Class, id: number): Promise<void> {
|
||||||
return this.deleteWhere({ within: within, id: id });
|
return this.deleteWhere({ within: within, id: id });
|
||||||
|
|
|
@ -16,14 +16,14 @@ export class Group {
|
||||||
|
|
||||||
@ManyToOne({
|
@ManyToOne({
|
||||||
entity: () => Assignment,
|
entity: () => Assignment,
|
||||||
primary: true
|
primary: true,
|
||||||
})
|
})
|
||||||
assignment!: Assignment;
|
assignment!: Assignment;
|
||||||
|
|
||||||
@ManyToMany({
|
@ManyToMany({
|
||||||
entity: () => Student,
|
entity: () => Student,
|
||||||
owner: true,
|
owner: true,
|
||||||
inversedBy: "groups"
|
inversedBy: 'groups',
|
||||||
})
|
})
|
||||||
members: Collection<Student> = new Collection<Student>(this);
|
members: Collection<Student> = new Collection<Student>(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,9 @@ export class Class {
|
||||||
@Property({ type: 'string' })
|
@Property({ type: 'string' })
|
||||||
displayName!: string;
|
displayName!: string;
|
||||||
|
|
||||||
@ManyToMany({entity: () => Teacher, owner: true, inversedBy: 'classes'})
|
@ManyToMany({ entity: () => Teacher, owner: true, inversedBy: 'classes' })
|
||||||
teachers!: Collection<Teacher>;
|
teachers!: Collection<Teacher>;
|
||||||
|
|
||||||
@ManyToMany({entity: () => Student, owner: true, inversedBy: 'classes'})
|
@ManyToMany({ entity: () => Student, owner: true, inversedBy: 'classes' })
|
||||||
students!: Collection<Student>;
|
students!: Collection<Student>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,9 @@ import { StudentRepository } from '../../data/users/student-repository.js';
|
||||||
repository: () => StudentRepository,
|
repository: () => StudentRepository,
|
||||||
})
|
})
|
||||||
export class Student extends User {
|
export class Student extends User {
|
||||||
@ManyToMany({entity: () => Class, mappedBy: 'students'})
|
@ManyToMany({ entity: () => Class, mappedBy: 'students' })
|
||||||
classes!: Collection<Class>;
|
classes!: Collection<Class>;
|
||||||
|
|
||||||
@ManyToMany({entity: () => Group, mappedBy: 'members'})
|
@ManyToMany({ entity: () => Group, mappedBy: 'members' })
|
||||||
groups: Collection<Group> = new Collection<Group>(this);
|
groups: Collection<Group> = new Collection<Group>(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,6 @@ import { TeacherRepository } from '../../data/users/teacher-repository.js';
|
||||||
|
|
||||||
@Entity({ repository: () => TeacherRepository })
|
@Entity({ repository: () => TeacherRepository })
|
||||||
export class Teacher extends User {
|
export class Teacher extends User {
|
||||||
@ManyToMany({entity: () => Class, mappedBy: 'teachers'})
|
@ManyToMany({ entity: () => Class, mappedBy: 'teachers' })
|
||||||
classes!: Collection<Class>;
|
classes!: Collection<Class>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* Exception for HTTP 500 Internal Server Error
|
||||||
|
|
|
@ -9,11 +9,11 @@ import { getAssignmentHandler } from '../controllers/assignments.js';
|
||||||
import { getAssignmentRepository, getClassRepository } from '../data/repositories.js';
|
import { getAssignmentRepository, getClassRepository } from '../data/repositories.js';
|
||||||
|
|
||||||
export function mapToAssignmentDTOId(assignment: Assignment): AssignmentDTOId {
|
export function mapToAssignmentDTOId(assignment: Assignment): AssignmentDTOId {
|
||||||
return {
|
return {
|
||||||
id: assignment.id!,
|
id: assignment.id!,
|
||||||
within: assignment.within.classId!,
|
within: assignment.within.classId!,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mapToAssignmentDTO(assignment: Assignment): AssignmentDTO {
|
export function mapToAssignmentDTO(assignment: Assignment): AssignmentDTO {
|
||||||
return {
|
return {
|
||||||
|
@ -23,7 +23,7 @@ export function mapToAssignmentDTO(assignment: Assignment): AssignmentDTO {
|
||||||
description: assignment.description,
|
description: assignment.description,
|
||||||
learningPath: assignment.learningPathHruid,
|
learningPath: assignment.learningPathHruid,
|
||||||
language: assignment.learningPathLanguage,
|
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,
|
learningPathHruid: assignmentData.learningPath,
|
||||||
learningPathLanguage: languageMap[assignmentData.language],
|
learningPathLanguage: languageMap[assignmentData.language],
|
||||||
groups: [],
|
groups: [],
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,7 @@ export function mapToGroupDTO(group: Group, cls: Class): GroupDTO {
|
||||||
class: cls.classId!,
|
class: cls.classId!,
|
||||||
assignment: group.assignment.id!,
|
assignment: group.assignment.id!,
|
||||||
groupNumber: group.groupNumber!,
|
groupNumber: group.groupNumber!,
|
||||||
members: group.members.map(mapToStudentDTO)
|
members: group.members.map(mapToStudentDTO),
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,6 @@ export async function createAssignment(classid: string, assignmentData: Assignme
|
||||||
const assignment = mapToAssignment(assignmentData, cls);
|
const assignment = mapToAssignment(assignmentData, cls);
|
||||||
await assignmentRepository.save(assignment);
|
await assignmentRepository.save(assignment);
|
||||||
|
|
||||||
|
|
||||||
if (assignmentData.groups) {
|
if (assignmentData.groups) {
|
||||||
/*
|
/*
|
||||||
For some reason when trying to add groups, it does not work when using the original assignment variable.
|
For some reason when trying to add groups, it does not work when using the original assignment variable.
|
||||||
|
@ -68,7 +67,7 @@ export async function createAssignment(classid: string, assignmentData: Assignme
|
||||||
const assignmentCopy = await assignmentRepository.findByClassAndId(cls, assignment.id!);
|
const assignmentCopy = await assignmentRepository.findByClassAndId(cls, assignment.id!);
|
||||||
|
|
||||||
if (assignmentCopy === null) {
|
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();
|
const groupRepository = getGroupRepository();
|
||||||
|
|
|
@ -68,7 +68,7 @@ export async function createGroup(groupData: GroupDTO, classid: string, assignme
|
||||||
const groupRepository = getGroupRepository();
|
const groupRepository = getGroupRepository();
|
||||||
const newGroup = groupRepository.create({
|
const newGroup = groupRepository.create({
|
||||||
assignment: assignment,
|
assignment: assignment,
|
||||||
members: members
|
members: members,
|
||||||
});
|
});
|
||||||
|
|
||||||
await groupRepository.save(newGroup);
|
await groupRepository.save(newGroup);
|
||||||
|
@ -83,10 +83,10 @@ export async function getAllGroups(classId: string, assignmentNumber: number, fu
|
||||||
const groups = await groupRepository.findAllGroupsForAssignment(assignment);
|
const groups = await groupRepository.findAllGroupsForAssignment(assignment);
|
||||||
|
|
||||||
if (full) {
|
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(
|
export async function getGroupSubmissions(
|
||||||
|
|
|
@ -104,10 +104,10 @@ export async function getStudentGroups(username: string, full: boolean): Promise
|
||||||
const groups = await groupRepository.findAllGroupsWithStudent(student);
|
const groups = await groupRepository.findAllGroupsWithStudent(student);
|
||||||
|
|
||||||
if (full) {
|
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[]> {
|
export async function getStudentSubmissions(username: string, full: boolean): Promise<SubmissionDTO[] | SubmissionDTOId[]> {
|
||||||
|
|
|
@ -10,7 +10,7 @@ export interface GroupDTO {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GroupDTOId {
|
export interface GroupDTOId {
|
||||||
class: string,
|
class: string;
|
||||||
assignment: number,
|
assignment: number;
|
||||||
groupNumber: number,
|
groupNumber: number;
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue