diff --git a/backend/src/services/students.ts b/backend/src/services/students.ts index a8300db5..5fc3427f 100644 --- a/backend/src/services/students.ts +++ b/backend/src/services/students.ts @@ -23,8 +23,8 @@ import { GroupDTO } from '@dwengo-1/common/interfaces/group'; import { SubmissionDTO, SubmissionDTOId } from '@dwengo-1/common/interfaces/submission'; import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question'; import { ClassJoinRequestDTO } from '@dwengo-1/common/interfaces/class-join-request'; -import {BadRequestException} from "../exceptions/bad-request-exception"; -import {ConflictException} from "../exceptions/conflict-exception"; +import { BadRequestException } from '../exceptions/bad-request-exception'; +import { ConflictException } from '../exceptions/conflict-exception'; export async function getAllStudents(full: boolean): Promise { const studentRepository = getStudentRepository(); @@ -138,7 +138,7 @@ export async function createClassJoinRequest(username: string, classId: string): const cls = await fetchClass(classId); if (cls.students.contains(student)) { - throw new ConflictException("Student already in this class"); + throw new ConflictException('Student already in this class'); } const request = mapToStudentRequest(student, cls); diff --git a/backend/src/services/teachers.ts b/backend/src/services/teachers.ts index 4e67d27d..4973ce81 100644 --- a/backend/src/services/teachers.ts +++ b/backend/src/services/teachers.ts @@ -22,15 +22,15 @@ import { Question } from '../entities/questions/question.entity.js'; import { ClassJoinRequestRepository } from '../data/classes/class-join-request-repository.js'; import { Student } from '../entities/users/student.entity.js'; import { NotFoundException } from '../exceptions/not-found-exception.js'; -import {addClassStudent, fetchClass, getClassStudents, getClassStudentsDTO} from './classes.js'; +import { addClassStudent, fetchClass, getClassStudents, getClassStudentsDTO } from './classes.js'; import { TeacherDTO } from '@dwengo-1/common/interfaces/teacher'; import { ClassDTO } from '@dwengo-1/common/interfaces/class'; import { StudentDTO } from '@dwengo-1/common/interfaces/student'; import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question'; import { ClassJoinRequestDTO } from '@dwengo-1/common/interfaces/class-join-request'; import { ClassJoinRequestStatus } from '@dwengo-1/common/util/class-join-request'; -import {BadRequestException} from "../exceptions/bad-request-exception"; -import {ConflictException} from "../exceptions/conflict-exception"; +import { BadRequestException } from '../exceptions/bad-request-exception'; +import { ConflictException } from '../exceptions/conflict-exception'; export async function getAllTeachers(full: boolean): Promise { const teacherRepository: TeacherRepository = getTeacherRepository(); @@ -152,7 +152,7 @@ export async function updateClassJoinRequestStatus(studentUsername: string, clas const cls = await fetchClass(classId); if (cls.students.contains(student)) { - throw new ConflictException("Student already in this class"); + throw new ConflictException('Student already in this class'); } const request: ClassJoinRequest | null = await requestRepo.findByStudentAndClass(student, cls); @@ -163,7 +163,7 @@ export async function updateClassJoinRequestStatus(studentUsername: string, clas request.status = ClassJoinRequestStatus.Declined; - if (accepted){ + if (accepted) { request.status = ClassJoinRequestStatus.Accepted; await addClassStudent(classId, studentUsername); } diff --git a/backend/tests/controllers/teachers.test.ts b/backend/tests/controllers/teachers.test.ts index 21533876..c29ecbb3 100644 --- a/backend/tests/controllers/teachers.test.ts +++ b/backend/tests/controllers/teachers.test.ts @@ -16,7 +16,7 @@ import { BadRequestException } from '../../src/exceptions/bad-request-exception. import { EntityAlreadyExistsException } from '../../src/exceptions/entity-already-exists-exception.js'; import { getStudentRequestsHandler } from '../../src/controllers/students.js'; import { TeacherDTO } from '@dwengo-1/common/interfaces/teacher'; -import {getClassHandler} from "../../src/controllers/classes"; +import { getClassHandler } from '../../src/controllers/classes'; describe('Teacher controllers', () => { let req: Partial; @@ -183,7 +183,7 @@ describe('Teacher controllers', () => { it('Update join request status', async () => { req = { - params: { classId: 'id02', studentUsername: 'PinkFloyd'}, + params: { classId: 'id02', studentUsername: 'PinkFloyd' }, body: { accepted: 'true' }, }; @@ -201,11 +201,11 @@ describe('Teacher controllers', () => { expect(status).toBeTruthy(); req = { - params: { id: 'id02' } - } + params: { id: 'id02' }, + }; await getClassHandler(req as Request, res as Response); const students: string[] = jsonMock.mock.lastCall?.[0].class.students; - expect(students).contains("PinkFloyd"); + expect(students).contains('PinkFloyd'); }); });