style: fix linting issues met Prettier

This commit is contained in:
Lint Action 2025-03-30 21:24:37 +00:00
parent 9895d22521
commit ee5f69cbc8
20 changed files with 188 additions and 192 deletions

View file

@ -1,4 +1,4 @@
import {BadRequestException} from "../exceptions/bad-request-exception";
import { BadRequestException } from '../exceptions/bad-request-exception';
/**
* Checks for the presence of required fields and throws a BadRequestException

View file

@ -1,17 +1,20 @@
import { Request, Response } from 'express';
import {
createClassJoinRequest,
createStudent, deleteClassJoinRequest,
createStudent,
deleteClassJoinRequest,
deleteStudent,
getAllStudents, getJoinRequestsByStudent,
getAllStudents,
getJoinRequestsByStudent,
getStudent,
getStudentAssignments,
getStudentClasses,
getStudentGroups, getStudentQuestions,
getStudentGroups,
getStudentQuestions,
getStudentSubmissions,
} from '../services/students.js';
import { StudentDTO } from '../interfaces/student.js';
import {requireFields} from "./error-helper.js";
import { requireFields } from './error-helper.js';
export async function getAllStudentsHandler(req: Request, res: Response): Promise<void> {
const full = req.query.full === 'true';
@ -128,7 +131,7 @@ export async function getStudentRequestHandler(req: Request, res: Response): Pro
requireFields({ username });
const requests = await getJoinRequestsByStudent(username);
res.status(201).json({ requests })
res.status(201).json({ requests });
}
export async function deleteClassJoinRequestHandler(req: Request, res: Response) {
@ -139,5 +142,3 @@ export async function deleteClassJoinRequestHandler(req: Request, res: Response)
await deleteClassJoinRequest(username, classId);
res.sendStatus(204);
}

View file

@ -3,16 +3,18 @@ import {
createTeacher,
deleteTeacher,
getAllTeachers,
getClassesByTeacher, getJoinRequestsByClass,
getClassesByTeacher,
getJoinRequestsByClass,
getStudentsByTeacher,
getTeacher,
getTeacherQuestions, updateClassJoinRequestStatus
getTeacherQuestions,
updateClassJoinRequestStatus,
} from '../services/teachers.js';
import { ClassDTO } from '../interfaces/class.js';
import { StudentDTO } from '../interfaces/student.js';
import { QuestionDTO, QuestionId } from '../interfaces/question.js';
import { TeacherDTO } from '../interfaces/teacher.js';
import {requireFields} from "./error-helper.js";
import { requireFields } from './error-helper.js';
export async function getAllTeachersHandler(req: Request, res: Response): Promise<void> {
const full = req.query.full === 'true';

View file

@ -1,6 +1,6 @@
import { DwengoEntityRepository } from '../dwengo-entity-repository.js';
import { Class } from '../../entities/classes/class.entity.js';
import {ClassJoinRequest, ClassJoinRequestStatus} from '../../entities/classes/class-join-request.entity.js';
import { ClassJoinRequest, ClassJoinRequestStatus } from '../../entities/classes/class-join-request.entity.js';
import { Student } from '../../entities/users/student.entity.js';
export class ClassJoinRequestRepository extends DwengoEntityRepository<ClassJoinRequest> {
@ -8,7 +8,7 @@ export class ClassJoinRequestRepository extends DwengoEntityRepository<ClassJoin
return this.findAll({ where: { requester: requester } });
}
public findAllOpenRequestsTo(clazz: Class): Promise<ClassJoinRequest[]> {
return this.findAll({ where: { class: clazz, status: ClassJoinRequestStatus.Open, } }); // TODO check if works like this
return this.findAll({ where: { class: clazz, status: ClassJoinRequestStatus.Open } }); // TODO check if works like this
}
public findByStudentAndClass(requester: Student, clazz: Class): Promise<ClassJoinRequest | null> {
return this.findOne({ requester, class: clazz });

View file

@ -1,13 +1,13 @@
import {mapToStudentDTO, StudentDTO} from "./student";
import {ClassJoinRequest, ClassJoinRequestStatus} from "../entities/classes/class-join-request.entity";
import {getClassJoinRequestRepository} from "../data/repositories";
import {Student} from "../entities/users/student.entity";
import {Class} from "../entities/classes/class.entity";
import { mapToStudentDTO, StudentDTO } from './student';
import { ClassJoinRequest, ClassJoinRequestStatus } from '../entities/classes/class-join-request.entity';
import { getClassJoinRequestRepository } from '../data/repositories';
import { Student } from '../entities/users/student.entity';
import { Class } from '../entities/classes/class.entity';
export interface StudentRequestDTO {
requester: StudentDTO;
class: string;
status: ClassJoinRequestStatus
status: ClassJoinRequestStatus;
}
export function mapToStudentRequestDTO(request: ClassJoinRequest): StudentRequestDTO {

View file

@ -1,8 +1,5 @@
import express from "express";
import {
createStudentRequestHandler, deleteClassJoinRequestHandler,
getStudentRequestHandler,
} from "../controllers/students";
import express from 'express';
import { createStudentRequestHandler, deleteClassJoinRequestHandler, getStudentRequestHandler } from '../controllers/students';
const router = express.Router({ mergeParams: true });

View file

@ -10,7 +10,7 @@ import {
getStudentQuestionsHandler,
getStudentSubmissionsHandler,
} from '../controllers/students.js';
import joinRequestRouter from './student-join-requests.js'
import joinRequestRouter from './student-join-requests.js';
const router = express.Router();
@ -39,6 +39,6 @@ router.get('/:username/groups', getStudentGroupsHandler);
// A list of questions a user has created
router.get('/:username/questions', getStudentQuestionsHandler);
router.use('/:username/joinRequests', joinRequestRouter)
router.use('/:username/joinRequests', joinRequestRouter);
export default router;

View file

@ -2,11 +2,13 @@ import express from 'express';
import {
createTeacherHandler,
deleteTeacherHandler,
getAllTeachersHandler, getStudentJoinRequestHandler,
getAllTeachersHandler,
getStudentJoinRequestHandler,
getTeacherClassHandler,
getTeacherHandler,
getTeacherQuestionHandler,
getTeacherStudentHandler, updateStudentJoinRequestHandler,
getTeacherStudentHandler,
updateStudentJoinRequestHandler,
} from '../controllers/teachers.js';
const router = express.Router();

View file

@ -3,8 +3,8 @@ import { ClassDTO, mapToClassDTO } from '../interfaces/class.js';
import { mapToStudentDTO, StudentDTO } from '../interfaces/student.js';
import { mapToTeacherInvitationDTO, mapToTeacherInvitationDTOIds, TeacherInvitationDTO } from '../interfaces/teacher-invitation.js';
import { getLogger } from '../logging/initalize.js';
import {NotFoundException} from "../exceptions/not-found-exception";
import {Class} from "../entities/classes/class.entity";
import { NotFoundException } from '../exceptions/not-found-exception';
import { Class } from '../entities/classes/class.entity';
const logger = getLogger();
@ -13,7 +13,7 @@ export async function fetchClass(classId: string): Promise<Class> {
const cls = await classRepository.findById(classId);
if (!cls) {
throw new NotFoundException("Class with id not found");
throw new NotFoundException('Class with id not found');
}
return cls;

View file

@ -4,7 +4,7 @@ import {
getGroupRepository,
getQuestionRepository,
getStudentRepository,
getSubmissionRepository
getSubmissionRepository,
} from '../data/repositories.js';
import { AssignmentDTO } from '../interfaces/assignment.js';
import { ClassDTO, mapToClassDTO } from '../interfaces/class.js';
@ -13,17 +13,18 @@ import { mapToStudent, mapToStudentDTO, StudentDTO } from '../interfaces/student
import { mapToSubmissionDTO, mapToSubmissionDTOId, SubmissionDTO, SubmissionDTOId } from '../interfaces/submission.js';
import { getAllAssignments } from './assignments.js';
import { mapToQuestionDTO, mapToQuestionId, QuestionDTO, QuestionId } from '../interfaces/question.js';
import {mapToStudentRequest, mapToStudentRequestDTO} from "../interfaces/student-request.js";
import {Student} from "../entities/users/student.entity.js";
import {NotFoundException} from "../exceptions/not-found-exception.js";
import {fetchClass} from "./classes.js";
import { mapToStudentRequest, mapToStudentRequestDTO } from '../interfaces/student-request.js';
import { Student } from '../entities/users/student.entity.js';
import { NotFoundException } from '../exceptions/not-found-exception.js';
import { fetchClass } from './classes.js';
export async function getAllStudents(full: boolean): Promise<StudentDTO[] | string[]> {
const studentRepository = getStudentRepository();
const users = await studentRepository.findAll();
if (full)
{return users.map(mapToStudentDTO);}
if (full) {
return users.map(mapToStudentDTO);
}
return users.map((user) => user.username);
}
@ -33,7 +34,7 @@ export async function fetchStudent(username: string): Promise<Student> {
const user = await studentRepository.findByUsername(username);
if (!user) {
throw new NotFoundException("Student with username not found");
throw new NotFoundException('Student with username not found');
}
return user;
@ -115,8 +116,9 @@ export async function getStudentQuestions(username: string, full: boolean): Prom
const questionsDTO = questions.map(mapToQuestionDTO);
if (full)
{return questionsDTO;}
if (full) {
return questionsDTO;
}
return questionsDTO.map(mapToQuestionId);
}
@ -146,7 +148,6 @@ export async function deleteClassJoinRequest(studentUsername: string, classId: s
const student = await fetchStudent(studentUsername);
const cls = await fetchClass(classId);
const request = await requestRepo.findByStudentAndClass(student, cls);
if (!request) {

View file

@ -6,24 +6,24 @@ import {
getTeacherRepository,
} from '../data/repositories.js';
import { ClassDTO, mapToClassDTO } from '../interfaces/class.js';
import {mapToQuestionDTO, mapToQuestionId, QuestionDTO, QuestionId} from '../interfaces/question.js';
import { mapToQuestionDTO, mapToQuestionId, QuestionDTO, QuestionId } from '../interfaces/question.js';
import { mapToTeacher, mapToTeacherDTO, TeacherDTO } from '../interfaces/teacher.js';
import {Teacher} from "../entities/users/teacher.entity.js";
import {fetchStudent} from "./students.js";
import {ClassJoinRequest, ClassJoinRequestStatus} from "../entities/classes/class-join-request.entity.js";
import {mapToStudentRequestDTO, StudentRequestDTO} from "../interfaces/student-request.js";
import {TeacherRepository} from "../data/users/teacher-repository.js";
import {ClassRepository} from "../data/classes/class-repository.js";
import {Class} from "../entities/classes/class.entity.js";
import {StudentDTO} from "../interfaces/student.js";
import {LearningObjectRepository} from "../data/content/learning-object-repository.js";
import {LearningObject} from "../entities/content/learning-object.entity.js";
import {QuestionRepository} from "../data/questions/question-repository.js";
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 {getClassStudents} from "./classes.js";
import { Teacher } from '../entities/users/teacher.entity.js';
import { fetchStudent } from './students.js';
import { ClassJoinRequest, ClassJoinRequestStatus } from '../entities/classes/class-join-request.entity.js';
import { mapToStudentRequestDTO, StudentRequestDTO } from '../interfaces/student-request.js';
import { TeacherRepository } from '../data/users/teacher-repository.js';
import { ClassRepository } from '../data/classes/class-repository.js';
import { Class } from '../entities/classes/class.entity.js';
import { StudentDTO } from '../interfaces/student.js';
import { LearningObjectRepository } from '../data/content/learning-object-repository.js';
import { LearningObject } from '../entities/content/learning-object.entity.js';
import { QuestionRepository } from '../data/questions/question-repository.js';
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 { getClassStudents } from './classes.js';
export async function getAllTeachers(full: boolean): Promise<TeacherDTO[] | string[]> {
const teacherRepository: TeacherRepository = getTeacherRepository();
@ -40,7 +40,7 @@ export async function fetchTeacher(username: string): Promise<Teacher> {
const user: Teacher | null = await teacherRepository.findByUsername(username);
if (!user) {
throw new NotFoundException("Teacher with username not found");
throw new NotFoundException('Teacher with username not found');
}
return user;
@ -86,7 +86,7 @@ export async function getClassesByTeacher(username: string, full: boolean): Prom
export async function getStudentsByTeacher(username: string, full: boolean) {
const classes: ClassDTO[] = await fetchClassesByTeacher(username);
if (!classes || classes.length === 0){
if (!classes || classes.length === 0) {
return [];
}
@ -109,7 +109,7 @@ export async function getTeacherQuestions(username: string, full: boolean): Prom
// Console.log(learningObjects)
// TODO returns empty
if (!learningObjects || learningObjects.length === 0){
if (!learningObjects || learningObjects.length === 0) {
return [];
}
@ -125,12 +125,12 @@ export async function getTeacherQuestions(username: string, full: boolean): Prom
return questionsDTO.map(mapToQuestionId);
}
export async function getJoinRequestsByClass( classId: string ): Promise<StudentRequestDTO[]> {
export async function getJoinRequestsByClass(classId: string): Promise<StudentRequestDTO[]> {
const classRepository: ClassRepository = getClassRepository();
const cls: Class | null = await classRepository.findById(classId);
if (!cls) {
throw new NotFoundException("Class with id not found");
throw new NotFoundException('Class with id not found');
}
const requestRepo: ClassJoinRequestRepository = getClassJoinRequestRepository();
@ -138,7 +138,7 @@ export async function getJoinRequestsByClass( classId: string ): Promise<Student
return requests.map(mapToStudentRequestDTO);
}
export async function updateClassJoinRequestStatus( studentUsername: string, classId: string, accepted: boolean = true): Promise<void> {
export async function updateClassJoinRequestStatus(studentUsername: string, classId: string, accepted: boolean = true): Promise<void> {
const requestRepo: ClassJoinRequestRepository = getClassJoinRequestRepository();
const classRepo: ClassRepository = getClassRepository();