fix: merge + fixes

This commit is contained in:
Gabriellvl 2025-04-02 19:48:42 +02:00
parent 7d8a0fcbb2
commit 3c1eb82ce3
20 changed files with 52 additions and 41 deletions

View file

@ -14,8 +14,8 @@ import {
getStudentQuestions, getStudentQuestions,
getStudentSubmissions, getStudentSubmissions,
} from '../services/students.js'; } from '../services/students.js';
import { StudentDTO } from '../interfaces/student.js';
import { requireFields } from './error-helper.js'; import { requireFields } from './error-helper.js';
import { StudentDTO } from '@dwengo-1/common/interfaces/student';
export async function getAllStudentsHandler(req: Request, res: Response): Promise<void> { export async function getAllStudentsHandler(req: Request, res: Response): Promise<void> {
const full = req.query.full === 'true'; const full = req.query.full === 'true';

View file

@ -11,10 +11,7 @@ import {
updateClassJoinRequestStatus, updateClassJoinRequestStatus,
} from '../services/teachers.js'; } from '../services/teachers.js';
import { requireFields } from './error-helper.js'; import { requireFields } from './error-helper.js';
import { TeacherDTO } from 'dwengo-1-common/src/interfaces/teacher'; import { TeacherDTO } from '@dwengo-1/common/interfaces/teacher';
import { ClassDTO } from 'dwengo-1-common/src/interfaces/class';
import { StudentDTO } from 'dwengo-1-common/src/interfaces/student';
import { QuestionDTO, QuestionId } from 'dwengo-1-common/src/interfaces/question';
export async function getAllTeachersHandler(req: Request, res: Response): Promise<void> { export async function getAllTeachersHandler(req: Request, res: Response): Promise<void> {
const full = req.query.full === 'true'; const full = req.query.full === 'true';
@ -58,7 +55,7 @@ export async function getTeacherClassHandler(req: Request, res: Response): Promi
const full = req.query.full === 'true'; const full = req.query.full === 'true';
requireFields({ username }); requireFields({ username });
const classes: ClassDTO[] | string[] = await getClassesByTeacher(username, full); const classes = await getClassesByTeacher(username, full);
res.json({ classes }); res.json({ classes });
} }
@ -68,7 +65,7 @@ export async function getTeacherStudentHandler(req: Request, res: Response): Pro
const full = req.query.full === 'true'; const full = req.query.full === 'true';
requireFields({ username }); requireFields({ username });
const students: StudentDTO[] | string[] = await getStudentsByTeacher(username, full); const students = await getStudentsByTeacher(username, full);
res.json({ students }); res.json({ students });
} }
@ -78,7 +75,7 @@ export async function getTeacherQuestionHandler(req: Request, res: Response): Pr
const full = req.query.full === 'true'; const full = req.query.full === 'true';
requireFields({ username }); requireFields({ username });
const questions: QuestionDTO[] | QuestionId[] = await getTeacherQuestions(username, full); const questions = await getTeacherQuestions(username, full);
res.json({ questions }); res.json({ questions });
} }

View file

@ -1,4 +1,4 @@
import { Theme } from 'dwengo-1-common/src/interfaces/theme'; import { Theme } from 'common/src/interfaces/theme';
export const themes: Theme[] = [ export const themes: Theme[] = [
{ {

View file

@ -1,6 +1,7 @@
import { Question } from '../entities/questions/question.entity.js'; import { Question } from '../entities/questions/question.entity.js';
import { mapToStudentDTO } from './student.js'; import { mapToStudentDTO } from './student.js';
import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question'; import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question';
import { LearningObjectIdentifier } from '@dwengo-1/common/interfaces/learning-content';
function getLearningObjectIdentifier(question: Question): LearningObjectIdentifier { function getLearningObjectIdentifier(question: Question): LearningObjectIdentifier {
return { return {

View file

@ -3,7 +3,7 @@ import { ClassJoinRequest, ClassJoinRequestStatus } from '../entities/classes/cl
import { getClassJoinRequestRepository } from '../data/repositories.js'; import { getClassJoinRequestRepository } from '../data/repositories.js';
import { Student } from '../entities/users/student.entity.js'; import { Student } from '../entities/users/student.entity.js';
import { Class } from '../entities/classes/class.entity.js'; import { Class } from '../entities/classes/class.entity.js';
import { ClassJoinRequestDTO } from 'dwengo-1-common/src/interfaces/class-join-request'; import { ClassJoinRequestDTO } from 'common/src/interfaces/class-join-request';
export function mapToStudentRequestDTO(request: ClassJoinRequest): ClassJoinRequestDTO { export function mapToStudentRequestDTO(request: ClassJoinRequest): ClassJoinRequestDTO {
return { return {

View file

@ -6,17 +6,23 @@ import {
getStudentRepository, getStudentRepository,
getSubmissionRepository, getSubmissionRepository,
} from '../data/repositories.js'; } from '../data/repositories.js';
import { AssignmentDTO } from '../interfaces/assignment.js'; import { mapToClassDTO } from '../interfaces/class.js';
import { ClassDTO, mapToClassDTO } from '../interfaces/class.js'; import { mapToGroupDTO, mapToGroupDTOId } from '../interfaces/group.js';
import { GroupDTO, mapToGroupDTO, mapToGroupDTOId } from '../interfaces/group.js'; import { mapToStudent, mapToStudentDTO } from '../interfaces/student.js';
import { mapToStudent, mapToStudentDTO, StudentDTO } from '../interfaces/student.js'; import { mapToSubmissionDTO, mapToSubmissionDTOId } from '../interfaces/submission.js';
import { mapToSubmissionDTO, mapToSubmissionDTOId, SubmissionDTO, SubmissionDTOId } from '../interfaces/submission.js';
import { getAllAssignments } from './assignments.js'; import { getAllAssignments } from './assignments.js';
import { mapToQuestionDTO, mapToQuestionDTOId, QuestionDTO, QuestionId } from '../interfaces/question.js'; import { mapToQuestionDTO, mapToQuestionDTOId } from '../interfaces/question.js';
import { mapToStudentRequest, mapToStudentRequestDTO, StudentRequestDTO } from '../interfaces/student-request.js'; import { mapToStudentRequest, mapToStudentRequestDTO } from '../interfaces/student-request.js';
import { Student } from '../entities/users/student.entity.js'; import { Student } from '../entities/users/student.entity.js';
import { NotFoundException } from '../exceptions/not-found-exception.js'; import { NotFoundException } from '../exceptions/not-found-exception.js';
import { fetchClass } from './classes.js'; import { fetchClass } from './classes.js';
import { StudentDTO } from '@dwengo-1/common/interfaces/student';
import { ClassDTO } from '@dwengo-1/common/interfaces/class';
import { AssignmentDTO } from '@dwengo-1/common/interfaces/assignment';
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';
export async function getAllStudents(full: boolean): Promise<StudentDTO[] | string[]> { export async function getAllStudents(full: boolean): Promise<StudentDTO[] | string[]> {
const studentRepository = getStudentRepository(); const studentRepository = getStudentRepository();
@ -123,7 +129,7 @@ export async function getStudentQuestions(username: string, full: boolean): Prom
return questions.map(mapToQuestionDTOId); return questions.map(mapToQuestionDTOId);
} }
export async function createClassJoinRequest(username: string, classId: string): Promise<StudentRequestDTO> { export async function createClassJoinRequest(username: string, classId: string): Promise<ClassJoinRequestDTO> {
const requestRepo = getClassJoinRequestRepository(); const requestRepo = getClassJoinRequestRepository();
const student = await fetchStudent(username); // Throws error if student not found const student = await fetchStudent(username); // Throws error if student not found
@ -134,7 +140,7 @@ export async function createClassJoinRequest(username: string, classId: string):
return mapToStudentRequestDTO(request); return mapToStudentRequestDTO(request);
} }
export async function getJoinRequestsByStudent(username: string): Promise<StudentRequestDTO[]> { export async function getJoinRequestsByStudent(username: string): Promise<ClassJoinRequestDTO[]> {
const requestRepo = getClassJoinRequestRepository(); const requestRepo = getClassJoinRequestRepository();
const student = await fetchStudent(username); const student = await fetchStudent(username);
@ -143,7 +149,7 @@ export async function getJoinRequestsByStudent(username: string): Promise<Studen
return requests.map(mapToStudentRequestDTO); return requests.map(mapToStudentRequestDTO);
} }
export async function getJoinRequestByStudentClass(username: string, classId: string): Promise<StudentRequestDTO> { export async function getJoinRequestByStudentClass(username: string, classId: string): Promise<ClassJoinRequestDTO> {
const requestRepo = getClassJoinRequestRepository(); const requestRepo = getClassJoinRequestRepository();
const student = await fetchStudent(username); const student = await fetchStudent(username);
@ -157,7 +163,7 @@ export async function getJoinRequestByStudentClass(username: string, classId: st
return mapToStudentRequestDTO(request); return mapToStudentRequestDTO(request);
} }
export async function deleteClassJoinRequest(username: string, classId: string): Promise<StudentRequestDTO> { export async function deleteClassJoinRequest(username: string, classId: string): Promise<ClassJoinRequestDTO> {
const requestRepo = getClassJoinRequestRepository(); const requestRepo = getClassJoinRequestRepository();
const student = await fetchStudent(username); const student = await fetchStudent(username);

View file

@ -5,17 +5,16 @@ import {
getQuestionRepository, getQuestionRepository,
getTeacherRepository, getTeacherRepository,
} from '../data/repositories.js'; } from '../data/repositories.js';
import { ClassDTO, mapToClassDTO } from '../interfaces/class.js'; import { mapToClassDTO } from '../interfaces/class.js';
import { mapToQuestionDTO, mapToQuestionDTOId, QuestionDTO, QuestionId } from '../interfaces/question.js'; import { mapToQuestionDTO, mapToQuestionDTOId } from '../interfaces/question.js';
import { mapToTeacher, mapToTeacherDTO, TeacherDTO } from '../interfaces/teacher.js'; import { mapToTeacher, mapToTeacherDTO } from '../interfaces/teacher.js';
import { Teacher } from '../entities/users/teacher.entity.js'; import { Teacher } from '../entities/users/teacher.entity.js';
import { fetchStudent } from './students.js'; import { fetchStudent } from './students.js';
import { ClassJoinRequest, ClassJoinRequestStatus } from '../entities/classes/class-join-request.entity.js'; import { ClassJoinRequest } from '../entities/classes/class-join-request.entity.js';
import { mapToStudentRequestDTO, StudentRequestDTO } from '../interfaces/student-request.js'; import { mapToStudentRequestDTO } from '../interfaces/student-request.js';
import { TeacherRepository } from '../data/users/teacher-repository.js'; import { TeacherRepository } from '../data/users/teacher-repository.js';
import { ClassRepository } from '../data/classes/class-repository.js'; import { ClassRepository } from '../data/classes/class-repository.js';
import { Class } from '../entities/classes/class.entity.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 { LearningObjectRepository } from '../data/content/learning-object-repository.js';
import { LearningObject } from '../entities/content/learning-object.entity.js'; import { LearningObject } from '../entities/content/learning-object.entity.js';
import { QuestionRepository } from '../data/questions/question-repository.js'; import { QuestionRepository } from '../data/questions/question-repository.js';
@ -24,6 +23,12 @@ import { ClassJoinRequestRepository } from '../data/classes/class-join-request-r
import { Student } from '../entities/users/student.entity.js'; import { Student } from '../entities/users/student.entity.js';
import { NotFoundException } from '../exceptions/not-found-exception.js'; import { NotFoundException } from '../exceptions/not-found-exception.js';
import { getClassStudents } from './classes.js'; import { getClassStudents } 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';
export async function getAllTeachers(full: boolean): Promise<TeacherDTO[] | string[]> { export async function getAllTeachers(full: boolean): Promise<TeacherDTO[] | string[]> {
const teacherRepository: TeacherRepository = getTeacherRepository(); const teacherRepository: TeacherRepository = getTeacherRepository();
@ -123,7 +128,7 @@ export async function getTeacherQuestions(username: string, full: boolean): Prom
return questions.map(mapToQuestionDTOId); return questions.map(mapToQuestionDTOId);
} }
export async function getJoinRequestsByClass(classId: string): Promise<StudentRequestDTO[]> { export async function getJoinRequestsByClass(classId: string): Promise<ClassJoinRequestDTO[]> {
const classRepository: ClassRepository = getClassRepository(); const classRepository: ClassRepository = getClassRepository();
const cls: Class | null = await classRepository.findById(classId); const cls: Class | null = await classRepository.findById(classId);
@ -136,7 +141,7 @@ export async function getJoinRequestsByClass(classId: string): Promise<StudentRe
return requests.map(mapToStudentRequestDTO); return requests.map(mapToStudentRequestDTO);
} }
export async function updateClassJoinRequestStatus(studentUsername: string, classId: string, accepted = true): Promise<StudentRequestDTO> { export async function updateClassJoinRequestStatus(studentUsername: string, classId: string, accepted = true): Promise<ClassJoinRequestDTO> {
const requestRepo: ClassJoinRequestRepository = getClassJoinRequestRepository(); const requestRepo: ClassJoinRequestRepository = getClassJoinRequestRepository();
const classRepo: ClassRepository = getClassRepository(); const classRepo: ClassRepository = getClassRepository();

View file

@ -20,7 +20,8 @@ import { NotFoundException } from '../../src/exceptions/not-found-exception.js';
import { BadRequestException } from '../../src/exceptions/bad-request-exception.js'; import { BadRequestException } from '../../src/exceptions/bad-request-exception.js';
import { ConflictException } from '../../src/exceptions/conflict-exception.js'; import { ConflictException } from '../../src/exceptions/conflict-exception.js';
import { EntityAlreadyExistsException } from '../../src/exceptions/entity-already-exists-exception.js'; import { EntityAlreadyExistsException } from '../../src/exceptions/entity-already-exists-exception.js';
import { StudentDTO } from 'dwengo-1-common/src/interfaces/student'; import { StudentDTO } from '@dwengo-1/common/interfaces/student';
describe('Student controllers', () => { describe('Student controllers', () => {
let req: Partial<Request>; let req: Partial<Request>;

View file

@ -15,7 +15,7 @@ import {
import { BadRequestException } from '../../src/exceptions/bad-request-exception.js'; import { BadRequestException } from '../../src/exceptions/bad-request-exception.js';
import { EntityAlreadyExistsException } from '../../src/exceptions/entity-already-exists-exception.js'; import { EntityAlreadyExistsException } from '../../src/exceptions/entity-already-exists-exception.js';
import { getStudentRequestsHandler } from '../../src/controllers/students.js'; import { getStudentRequestsHandler } from '../../src/controllers/students.js';
import { TeacherDTO } from 'dwengo-1-common/src/interfaces/teacher'; import { TeacherDTO } from '@dwengo-1/common/interfaces/teacher';
describe('Teacher controllers', () => { describe('Teacher controllers', () => {
let req: Partial<Request>; let req: Partial<Request>;

View file

@ -1,4 +1,5 @@
import { StudentDTO } from './student'; import { StudentDTO } from './student';
import {ClassJoinRequestStatus} from "../util/class-join-request";
export interface ClassJoinRequestDTO { export interface ClassJoinRequestDTO {
requester: StudentDTO; requester: StudentDTO;

View file

@ -1,4 +1,4 @@
import type { AssignmentDTO } from "dwengo-1-common/src/interfaces/assignment"; import type { AssignmentDTO } from "@dwengo-1/interfaces/assignment";
export interface AssignmentsResponse { export interface AssignmentsResponse {
assignments: AssignmentDTO[]; assignments: AssignmentDTO[];

View file

@ -1,4 +1,4 @@
import type { ClassDTO } from "dwengo-1-common/src/interfaces/class"; import type { ClassDTO } from "@dwengo-1/interfaces/class";
export interface ClassesResponse { export interface ClassesResponse {
classes: ClassDTO[] | string[]; classes: ClassDTO[] | string[];

View file

@ -1,4 +1,4 @@
import type { GroupDTO } from "dwengo-1-common/src/interfaces/group"; import type { GroupDTO } from "@dwengo-1/interfaces/group";
export interface GroupsResponse { export interface GroupsResponse {
groups: GroupDTO[]; groups: GroupDTO[];

View file

@ -1,4 +1,4 @@
import type { QuestionDTO, QuestionId } from "dwengo-1-common/src/interfaces/question"; import type { QuestionDTO, QuestionId } from "@dwengo-1/interfaces/question";
export interface QuestionsResponse { export interface QuestionsResponse {
questions: QuestionDTO[] | QuestionId[]; questions: QuestionDTO[] | QuestionId[];

View file

@ -1,11 +1,11 @@
import { BaseController } from "@/controllers/base-controller.ts"; import { BaseController } from "@/controllers/base-controller.ts";
import type { StudentDTO } from "dwengo-1-common/src/interfaces/student";
import type { ClassesResponse } from "@/controllers/classes.ts"; import type { ClassesResponse } from "@/controllers/classes.ts";
import type { AssignmentsResponse } from "@/controllers/assignments.ts"; import type { AssignmentsResponse } from "@/controllers/assignments.ts";
import type { GroupsResponse } from "@/controllers/groups.ts"; import type { GroupsResponse } from "@/controllers/groups.ts";
import type { SubmissionsResponse } from "@/controllers/submissions.ts"; import type { SubmissionsResponse } from "@/controllers/submissions.ts";
import type { QuestionsResponse } from "@/controllers/questions.ts"; import type { QuestionsResponse } from "@/controllers/questions.ts";
import type { ClassJoinRequestDTO } from "dwengo-1-common/src/interfaces/class-join-request"; import type { StudentDTO } from "@dwengo-1/interfaces/student";
import type { ClassJoinRequestDTO } from "@dwengo-1/interfaces/class-join-request";
export interface StudentsResponse { export interface StudentsResponse {
students: StudentDTO[] | string[]; students: StudentDTO[] | string[];

View file

@ -1,4 +1,4 @@
import { type SubmissionDTO, SubmissionDTOId } from "dwengo-1-common/src/interfaces/submission"; import { type SubmissionDTO, SubmissionDTOId } from "@dwengo-1/interfaces/submission";
export interface SubmissionsResponse { export interface SubmissionsResponse {
submissions: SubmissionDTO[] | SubmissionDTOId[]; submissions: SubmissionDTO[] | SubmissionDTOId[];

View file

@ -2,7 +2,7 @@ import { BaseController } from "@/controllers/base-controller.ts";
import type { JoinRequestResponse, JoinRequestsResponse, StudentsResponse } from "@/controllers/students.ts"; import type { JoinRequestResponse, JoinRequestsResponse, StudentsResponse } from "@/controllers/students.ts";
import type { QuestionsResponse } from "@/controllers/questions.ts"; import type { QuestionsResponse } from "@/controllers/questions.ts";
import type { ClassesResponse } from "@/controllers/classes.ts"; import type { ClassesResponse } from "@/controllers/classes.ts";
import type { TeacherDTO } from "dwengo-1-common/src/interfaces/teacher"; import type { TeacherDTO } from "@dwengo-1/interfaces/teacher";
export interface TeachersResponse { export interface TeachersResponse {
teachers: TeacherDTO[] | string[]; teachers: TeacherDTO[] | string[];

View file

@ -1,5 +1,5 @@
import { BaseController } from "@/controllers/base-controller.ts"; import { BaseController } from "@/controllers/base-controller.ts";
import type { Theme } from "dwengo-1-common/src/interfaces/theme"; import type { Theme } from "@dwengo-1/interfaces/theme";
export class ThemeController extends BaseController { export class ThemeController extends BaseController {
constructor() { constructor() {

View file

@ -1,7 +1,7 @@
import { useQuery, type UseQueryReturnType } from "@tanstack/vue-query"; import { useQuery, type UseQueryReturnType } from "@tanstack/vue-query";
import { type MaybeRefOrGetter, toValue } from "vue"; import { type MaybeRefOrGetter, toValue } from "vue";
import { ThemeController } from "@/controllers/themes.ts"; import { ThemeController } from "@/controllers/themes.ts";
import type { Theme } from "dwengo-1-common/src/interfaces/theme"; import type { Theme } from "../../../common/src/interfaces/theme";
const themeController = new ThemeController(); const themeController = new ThemeController();