diff --git a/backend/src/routes/groups.ts b/backend/src/routes/groups.ts index dc8917bd..1486edce 100644 --- a/backend/src/routes/groups.ts +++ b/backend/src/routes/groups.ts @@ -11,7 +11,7 @@ router.post('/', createGroupHandler); // Information about a group (members, ... [TODO DOC]) router.get('/:groupid', getGroupHandler); -router.get('/:groupid', getGroupSubmissionsHandler); +router.get('/:groupid/submissions', getGroupSubmissionsHandler); // The list of questions a group has made router.get('/:id/questions', (_req, res) => { diff --git a/frontend/src/controllers/assignments.ts b/frontend/src/controllers/assignments.ts index 5fd5090a..e255ad66 100644 --- a/frontend/src/controllers/assignments.ts +++ b/frontend/src/controllers/assignments.ts @@ -1,5 +1,47 @@ -import type { AssignmentDTO } from "@dwengo-1/interfaces/assignment"; +import { BaseController } from "./base-controller"; +import type { AssignmentDTO } from "@dwengo-1/common/interfaces/assignment"; +import type { SubmissionsResponse } from "./submissions"; +import type { QuestionsResponse } from "./questions"; +import type { GroupsResponse } from "./groups"; export interface AssignmentsResponse { - assignments: AssignmentDTO[]; -} // TODO ID + assignments: AssignmentDTO[] | string[]; +} + +export interface AssignmentResponse { + assignment: AssignmentDTO; +} + +export class AssignmentController extends BaseController { + constructor(classid: string) { + super(`class/${classid}/assignments`); + } + + async getAll(full = true) { + return this.get(`/`, { full }); + } + + async getByNumber(num: number) { + return this.get(`/${num}`); + } + + async createAssignment(data: any) { + return this.post(`/`, data); + } + + async deleteAssignment(num: number) { + return this.delete(`/${num}`); + } + + async getSubmissions(assignmentNumber: number, full = true) { + return this.get(`/${assignmentNumber}/submissions`, { full }); + } + + async getQuestions(assignmentNumber: number, full = true) { + return this.get(`/${assignmentNumber}/questions`, { full }); + } + + async getGroups(assignmentNumber: number, full = true) { + return this.get(`/${assignmentNumber}/groups`, { full }); + } +} diff --git a/frontend/src/controllers/classes.ts b/frontend/src/controllers/classes.ts index d2d95ed5..374f0f6e 100644 --- a/frontend/src/controllers/classes.ts +++ b/frontend/src/controllers/classes.ts @@ -1,5 +1,47 @@ -import type { ClassDTO } from "@dwengo-1/interfaces/class"; +import { BaseController } from "./base-controller"; +import type { ClassDTO } from "@dwengo-1/common/interfaces/class"; +import type { StudentsResponse } from "./students"; +import type { AssignmentsResponse } from "./assignments"; export interface ClassesResponse { classes: ClassDTO[] | string[]; } + +export interface ClassResponse { + class: ClassDTO; +} + +export class ClassController extends BaseController { + constructor() { + super("class"); + } + + async getAll(full = true) { + return this.get(`/`, { full }); + } + + async getById(id: string) { + return this.get(`/${id}`); + } + + async createClass(data: any) { + return this.post(`/`, data); + } + + async deleteClass(id: string) { + return this.delete(`/${id}`); + } + + async getStudents(id: string, full = true) { + return this.get(`/${id}/students`, { full }); + } + + // TODO + async getTeacherInvitations(id: string, full = true) { + return this.get(`/${id}/teacher-invitations`, { full }); + } + + async getAssignments(id: string, full = true) { + return this.get(`/${id}/assignments`, { full }); + } +} diff --git a/frontend/src/controllers/groups.ts b/frontend/src/controllers/groups.ts index d6738e04..e82e5607 100644 --- a/frontend/src/controllers/groups.ts +++ b/frontend/src/controllers/groups.ts @@ -1,5 +1,42 @@ -import type { GroupDTO } from "@dwengo-1/interfaces/group"; +import { BaseController } from "./base-controller"; +import type { GroupDTO } from "@dwengo-1/common/interfaces/group"; +import type { SubmissionsResponse } from "./submissions"; +import type { QuestionsResponse } from "./questions"; export interface GroupsResponse { groups: GroupDTO[]; -} // | TODO id +} + +export interface GroupResponse { + group: GroupDTO; +} + +export class GroupController extends BaseController { + constructor(classid: string, assignmentNumber: number) { + super(`class/${classid}/assignments/${assignmentNumber}/groups`); + } + + async getAll(full = true) { + return this.get(`/`, { full }); + } + + async getByNumber(num: number) { + return this.get(`/${num}`); + } + + async createGroup(data: any) { + return this.post(`/`, data); + } + + async deleteGroup(num: number) { + return this.delete(`/${num}`); + } + + async getSubmissions(groupNumber: number, full = true) { + return this.get(`/${groupNumber}/submissions`, { full }); + } + + async getQuestions(groupNumber: number, full = true) { + return this.get(`/${groupNumber}/questions`, { full }); + } +} diff --git a/frontend/src/controllers/questions.ts b/frontend/src/controllers/questions.ts index 9b0182de..16abd38b 100644 --- a/frontend/src/controllers/questions.ts +++ b/frontend/src/controllers/questions.ts @@ -1,4 +1,4 @@ -import type { QuestionDTO, QuestionId } from "@dwengo-1/interfaces/question"; +import type { QuestionDTO, QuestionId } from "@dwengo-1/common/interfaces/question"; export interface QuestionsResponse { questions: QuestionDTO[] | QuestionId[]; diff --git a/frontend/src/controllers/students.ts b/frontend/src/controllers/students.ts index b36f1d5a..f74f02da 100644 --- a/frontend/src/controllers/students.ts +++ b/frontend/src/controllers/students.ts @@ -4,8 +4,8 @@ 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 { StudentDTO } from "@dwengo-1/interfaces/student"; -import type { ClassJoinRequestDTO } from "@dwengo-1/interfaces/class-join-request"; +import type { StudentDTO } from "@dwengo-1/common/interfaces/student"; +import type { ClassJoinRequestDTO } from "@dwengo-1/common/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 99b6ba8d..72621fcf 100644 --- a/frontend/src/controllers/submissions.ts +++ b/frontend/src/controllers/submissions.ts @@ -1,5 +1,32 @@ -import { type SubmissionDTO, SubmissionDTOId } from "@dwengo-1/interfaces/submission"; +import { BaseController } from "./base-controller"; +import type { SubmissionDTO, SubmissionDTOId } from "@dwengo-1/common/interfaces/submission"; export interface SubmissionsResponse { submissions: SubmissionDTO[] | SubmissionDTOId[]; } + +export interface SubmissionResponse { + submission: SubmissionDTO; +} + +export class SubmissionController extends BaseController { + constructor(classid: string, assignmentNumber: number, groupNumber: number) { + super(`class/${classid}/assignments/${assignmentNumber}/groups/${groupNumber}`); + } + + async getAll(full = true) { + return this.get(`/`, { full }); + } + + async getByNumber(submissionNumber: number) { + return this.get(`/${submissionNumber}`); + } + + async createSubmission(data: any) { + return this.post(`/`, data); + } + + async deleteSubmission(submissionNumber: number) { + return this.delete(`/${submissionNumber}`); + } +} diff --git a/frontend/src/controllers/teachers.ts b/frontend/src/controllers/teachers.ts index e0d38a6c..973e2b02 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/interfaces/teacher"; +import type { TeacherDTO } from "@dwengo-1/common/interfaces/teacher"; export interface TeachersResponse { teachers: TeacherDTO[] | string[]; diff --git a/frontend/src/controllers/themes.ts b/frontend/src/controllers/themes.ts index bb76249d..ca173373 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/interfaces/theme"; +import type { Theme } from "@dwengo-1/common/interfaces/theme"; export class ThemeController extends BaseController { constructor() {