diff --git a/backend/src/controllers/students.ts b/backend/src/controllers/students.ts index 4bc4394e..51488a2a 100644 --- a/backend/src/controllers/students.ts +++ b/backend/src/controllers/students.ts @@ -14,8 +14,8 @@ import { getStudentQuestions, getStudentSubmissions, } from '../services/students.js'; -import { StudentDTO } from '../interfaces/student.js'; import { requireFields } from './error-helper.js'; +import { StudentDTO } from '@dwengo-1/common/interfaces/student'; export async function getAllStudentsHandler(req: Request, res: Response): Promise { const full = req.query.full === 'true'; diff --git a/backend/src/controllers/teachers.ts b/backend/src/controllers/teachers.ts index abb5be69..9275ca92 100644 --- a/backend/src/controllers/teachers.ts +++ b/backend/src/controllers/teachers.ts @@ -11,10 +11,7 @@ import { updateClassJoinRequestStatus, } from '../services/teachers.js'; import { requireFields } from './error-helper.js'; -import { TeacherDTO } from 'dwengo-1-common/src/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'; +import { TeacherDTO } from '@dwengo-1/common/interfaces/teacher'; export async function getAllTeachersHandler(req: Request, res: Response): Promise { 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'; requireFields({ username }); - const classes: ClassDTO[] | string[] = await getClassesByTeacher(username, full); + const classes = await getClassesByTeacher(username, full); res.json({ classes }); } @@ -68,7 +65,7 @@ export async function getTeacherStudentHandler(req: Request, res: Response): Pro const full = req.query.full === 'true'; requireFields({ username }); - const students: StudentDTO[] | string[] = await getStudentsByTeacher(username, full); + const students = await getStudentsByTeacher(username, full); res.json({ students }); } @@ -78,7 +75,7 @@ export async function getTeacherQuestionHandler(req: Request, res: Response): Pr const full = req.query.full === 'true'; requireFields({ username }); - const questions: QuestionDTO[] | QuestionId[] = await getTeacherQuestions(username, full); + const questions = await getTeacherQuestions(username, full); res.json({ questions }); } diff --git a/backend/src/data/themes.ts b/backend/src/data/themes.ts index fb3ee47c..7bae807a 100644 --- a/backend/src/data/themes.ts +++ b/backend/src/data/themes.ts @@ -1,4 +1,4 @@ -import { Theme } from 'dwengo-1-common/src/interfaces/theme'; +import { Theme } from 'common/src/interfaces/theme'; export const themes: Theme[] = [ { diff --git a/backend/src/interfaces/question.ts b/backend/src/interfaces/question.ts index 06ec7878..48d64f11 100644 --- a/backend/src/interfaces/question.ts +++ b/backend/src/interfaces/question.ts @@ -1,6 +1,7 @@ import { Question } from '../entities/questions/question.entity.js'; import { mapToStudentDTO } from './student.js'; import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question'; +import { LearningObjectIdentifier } from '@dwengo-1/common/interfaces/learning-content'; function getLearningObjectIdentifier(question: Question): LearningObjectIdentifier { return { diff --git a/backend/src/interfaces/student-request.ts b/backend/src/interfaces/student-request.ts index ad45f8fe..31fce14f 100644 --- a/backend/src/interfaces/student-request.ts +++ b/backend/src/interfaces/student-request.ts @@ -3,7 +3,7 @@ import { ClassJoinRequest, ClassJoinRequestStatus } from '../entities/classes/cl import { getClassJoinRequestRepository } from '../data/repositories.js'; import { Student } from '../entities/users/student.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 { return { diff --git a/backend/src/services/students.ts b/backend/src/services/students.ts index 3f528dbc..7484277c 100644 --- a/backend/src/services/students.ts +++ b/backend/src/services/students.ts @@ -6,17 +6,23 @@ import { getStudentRepository, getSubmissionRepository, } from '../data/repositories.js'; -import { AssignmentDTO } from '../interfaces/assignment.js'; -import { ClassDTO, mapToClassDTO } from '../interfaces/class.js'; -import { GroupDTO, mapToGroupDTO, mapToGroupDTOId } from '../interfaces/group.js'; -import { mapToStudent, mapToStudentDTO, StudentDTO } from '../interfaces/student.js'; -import { mapToSubmissionDTO, mapToSubmissionDTOId, SubmissionDTO, SubmissionDTOId } from '../interfaces/submission.js'; +import { mapToClassDTO } from '../interfaces/class.js'; +import { mapToGroupDTO, mapToGroupDTOId } from '../interfaces/group.js'; +import { mapToStudent, mapToStudentDTO } from '../interfaces/student.js'; +import { mapToSubmissionDTO, mapToSubmissionDTOId } from '../interfaces/submission.js'; import { getAllAssignments } from './assignments.js'; -import { mapToQuestionDTO, mapToQuestionDTOId, QuestionDTO, QuestionId } from '../interfaces/question.js'; -import { mapToStudentRequest, mapToStudentRequestDTO, StudentRequestDTO } from '../interfaces/student-request.js'; +import { mapToQuestionDTO, mapToQuestionDTOId } 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 { 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 { const studentRepository = getStudentRepository(); @@ -123,7 +129,7 @@ export async function getStudentQuestions(username: string, full: boolean): Prom return questions.map(mapToQuestionDTOId); } -export async function createClassJoinRequest(username: string, classId: string): Promise { +export async function createClassJoinRequest(username: string, classId: string): Promise { const requestRepo = getClassJoinRequestRepository(); 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); } -export async function getJoinRequestsByStudent(username: string): Promise { +export async function getJoinRequestsByStudent(username: string): Promise { const requestRepo = getClassJoinRequestRepository(); const student = await fetchStudent(username); @@ -143,7 +149,7 @@ export async function getJoinRequestsByStudent(username: string): Promise { +export async function getJoinRequestByStudentClass(username: string, classId: string): Promise { const requestRepo = getClassJoinRequestRepository(); const student = await fetchStudent(username); @@ -157,7 +163,7 @@ export async function getJoinRequestByStudentClass(username: string, classId: st return mapToStudentRequestDTO(request); } -export async function deleteClassJoinRequest(username: string, classId: string): Promise { +export async function deleteClassJoinRequest(username: string, classId: string): Promise { const requestRepo = getClassJoinRequestRepository(); const student = await fetchStudent(username); diff --git a/backend/src/services/teachers.ts b/backend/src/services/teachers.ts index 98ac0a83..1b7643fb 100644 --- a/backend/src/services/teachers.ts +++ b/backend/src/services/teachers.ts @@ -5,17 +5,16 @@ import { getQuestionRepository, getTeacherRepository, } from '../data/repositories.js'; -import { ClassDTO, mapToClassDTO } from '../interfaces/class.js'; -import { mapToQuestionDTO, mapToQuestionDTOId, QuestionDTO, QuestionId } from '../interfaces/question.js'; -import { mapToTeacher, mapToTeacherDTO, TeacherDTO } from '../interfaces/teacher.js'; +import { mapToClassDTO } from '../interfaces/class.js'; +import { mapToQuestionDTO, mapToQuestionDTOId } from '../interfaces/question.js'; +import { mapToTeacher, mapToTeacherDTO } 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 { ClassJoinRequest } from '../entities/classes/class-join-request.entity.js'; +import { mapToStudentRequestDTO } 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'; @@ -24,6 +23,12 @@ import { ClassJoinRequestRepository } from '../data/classes/class-join-request-r import { Student } from '../entities/users/student.entity.js'; import { NotFoundException } from '../exceptions/not-found-exception.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 { const teacherRepository: TeacherRepository = getTeacherRepository(); @@ -123,7 +128,7 @@ export async function getTeacherQuestions(username: string, full: boolean): Prom return questions.map(mapToQuestionDTOId); } -export async function getJoinRequestsByClass(classId: string): Promise { +export async function getJoinRequestsByClass(classId: string): Promise { const classRepository: ClassRepository = getClassRepository(); const cls: Class | null = await classRepository.findById(classId); @@ -136,7 +141,7 @@ export async function getJoinRequestsByClass(classId: string): Promise { +export async function updateClassJoinRequestStatus(studentUsername: string, classId: string, accepted = true): Promise { const requestRepo: ClassJoinRequestRepository = getClassJoinRequestRepository(); const classRepo: ClassRepository = getClassRepository(); diff --git a/backend/tests/controllers/students.test.ts b/backend/tests/controllers/students.test.ts index 44919c4a..05151d03 100644 --- a/backend/tests/controllers/students.test.ts +++ b/backend/tests/controllers/students.test.ts @@ -20,7 +20,8 @@ import { NotFoundException } from '../../src/exceptions/not-found-exception.js'; import { BadRequestException } from '../../src/exceptions/bad-request-exception.js'; import { ConflictException } from '../../src/exceptions/conflict-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', () => { let req: Partial; diff --git a/backend/tests/controllers/teachers.test.ts b/backend/tests/controllers/teachers.test.ts index e5b33ea8..bee23987 100644 --- a/backend/tests/controllers/teachers.test.ts +++ b/backend/tests/controllers/teachers.test.ts @@ -15,7 +15,7 @@ import { import { BadRequestException } from '../../src/exceptions/bad-request-exception.js'; import { EntityAlreadyExistsException } from '../../src/exceptions/entity-already-exists-exception.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', () => { let req: Partial; diff --git a/common/src/interfaces/class-join-request.d.ts b/common/src/interfaces/class-join-request.ts similarity index 70% rename from common/src/interfaces/class-join-request.d.ts rename to common/src/interfaces/class-join-request.ts index 4ba6d520..0af70272 100644 --- a/common/src/interfaces/class-join-request.d.ts +++ b/common/src/interfaces/class-join-request.ts @@ -1,4 +1,5 @@ import { StudentDTO } from './student'; +import {ClassJoinRequestStatus} from "../util/class-join-request"; export interface ClassJoinRequestDTO { requester: StudentDTO; diff --git a/common/src/interfaces/theme.d.ts b/common/src/interfaces/theme.ts similarity index 100% rename from common/src/interfaces/theme.d.ts rename to common/src/interfaces/theme.ts diff --git a/frontend/src/controllers/assignments.ts b/frontend/src/controllers/assignments.ts index f6da213e..5fd5090a 100644 --- a/frontend/src/controllers/assignments.ts +++ b/frontend/src/controllers/assignments.ts @@ -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 { assignments: AssignmentDTO[]; diff --git a/frontend/src/controllers/classes.ts b/frontend/src/controllers/classes.ts index c0755cac..d2d95ed5 100644 --- a/frontend/src/controllers/classes.ts +++ b/frontend/src/controllers/classes.ts @@ -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 { classes: ClassDTO[] | string[]; diff --git a/frontend/src/controllers/groups.ts b/frontend/src/controllers/groups.ts index 4cc83dea..d6738e04 100644 --- a/frontend/src/controllers/groups.ts +++ b/frontend/src/controllers/groups.ts @@ -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 { groups: GroupDTO[]; diff --git a/frontend/src/controllers/questions.ts b/frontend/src/controllers/questions.ts index 0464578c..9b0182de 100644 --- a/frontend/src/controllers/questions.ts +++ b/frontend/src/controllers/questions.ts @@ -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 { questions: QuestionDTO[] | QuestionId[]; diff --git a/frontend/src/controllers/students.ts b/frontend/src/controllers/students.ts index 0640a971..b36f1d5a 100644 --- a/frontend/src/controllers/students.ts +++ b/frontend/src/controllers/students.ts @@ -1,11 +1,11 @@ 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 { AssignmentsResponse } from "@/controllers/assignments.ts"; import type { GroupsResponse } from "@/controllers/groups.ts"; import type { SubmissionsResponse } from "@/controllers/submissions.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 { students: StudentDTO[] | string[]; diff --git a/frontend/src/controllers/submissions.ts b/frontend/src/controllers/submissions.ts index fa16cbaf..99b6ba8d 100644 --- a/frontend/src/controllers/submissions.ts +++ b/frontend/src/controllers/submissions.ts @@ -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 { submissions: SubmissionDTO[] | SubmissionDTOId[]; diff --git a/frontend/src/controllers/teachers.ts b/frontend/src/controllers/teachers.ts index d356e3a2..e0d38a6c 100644 --- a/frontend/src/controllers/teachers.ts +++ b/frontend/src/controllers/teachers.ts @@ -2,7 +2,7 @@ import { BaseController } from "@/controllers/base-controller.ts"; import type { JoinRequestResponse, JoinRequestsResponse, StudentsResponse } from "@/controllers/students.ts"; import type { QuestionsResponse } from "@/controllers/questions.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 { teachers: TeacherDTO[] | string[]; diff --git a/frontend/src/controllers/themes.ts b/frontend/src/controllers/themes.ts index c810bf93..bb76249d 100644 --- a/frontend/src/controllers/themes.ts +++ b/frontend/src/controllers/themes.ts @@ -1,5 +1,5 @@ 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 { constructor() { diff --git a/frontend/src/queries/themes.ts b/frontend/src/queries/themes.ts index 75a6d876..c474efcd 100644 --- a/frontend/src/queries/themes.ts +++ b/frontend/src/queries/themes.ts @@ -1,7 +1,7 @@ import { useQuery, type UseQueryReturnType } from "@tanstack/vue-query"; import { type MaybeRefOrGetter, toValue } from "vue"; 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();