Merge branch 'dev' into feat/question-routes
This commit is contained in:
		
						commit
						0dafb2a3f5
					
				
					 9 changed files with 169 additions and 12 deletions
				
			
		|  | @ -11,7 +11,7 @@ router.post('/', createGroupHandler); | ||||||
| // Information about a group (members, ... [TODO DOC])
 | // Information about a group (members, ... [TODO DOC])
 | ||||||
| router.get('/:groupid', getGroupHandler); | router.get('/:groupid', getGroupHandler); | ||||||
| 
 | 
 | ||||||
| router.get('/:groupid', getGroupSubmissionsHandler); | router.get('/:groupid/submissions', getGroupSubmissionsHandler); | ||||||
| 
 | 
 | ||||||
| // The list of questions a group has made
 | // The list of questions a group has made
 | ||||||
| router.get('/:id/questions', (_req, res) => { | router.get('/:id/questions', (_req, res) => { | ||||||
|  |  | ||||||
|  | @ -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 { | export interface AssignmentsResponse { | ||||||
|     assignments: AssignmentDTO[]; |     assignments: AssignmentDTO[] | string[]; | ||||||
| } // TODO ID
 | } | ||||||
|  | 
 | ||||||
|  | export interface AssignmentResponse { | ||||||
|  |     assignment: AssignmentDTO; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export class AssignmentController extends BaseController { | ||||||
|  |     constructor(classid: string) { | ||||||
|  |         super(`class/${classid}/assignments`); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async getAll(full = true): Promise<AssignmentsResponse> { | ||||||
|  |         return this.get<AssignmentsResponse>(`/`, { full }); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async getByNumber(num: number): Promise<AssignmentResponse> { | ||||||
|  |         return this.get<AssignmentResponse>(`/${num}`); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async createAssignment(data: AssignmentDTO): Promise<AssignmentResponse> { | ||||||
|  |         return this.post<AssignmentResponse>(`/`, data); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async deleteAssignment(num: number): Promise<AssignmentResponse> { | ||||||
|  |         return this.delete<AssignmentResponse>(`/${num}`); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async getSubmissions(assignmentNumber: number, full = true): Promise<SubmissionsResponse> { | ||||||
|  |         return this.get<SubmissionsResponse>(`/${assignmentNumber}/submissions`, { full }); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async getQuestions(assignmentNumber: number, full = true): Promise<QuestionsResponse> { | ||||||
|  |         return this.get<QuestionsResponse>(`/${assignmentNumber}/questions`, { full }); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async getGroups(assignmentNumber: number, full = true): Promise<GroupsResponse> { | ||||||
|  |         return this.get<GroupsResponse>(`/${assignmentNumber}/groups`, { full }); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -1,5 +1,55 @@ | ||||||
| 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"; | ||||||
|  | import type { TeacherInvitationDTO } from "@dwengo-1/common/interfaces/teacher-invitation"; | ||||||
| 
 | 
 | ||||||
| export interface ClassesResponse { | export interface ClassesResponse { | ||||||
|     classes: ClassDTO[] | string[]; |     classes: ClassDTO[] | string[]; | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | export interface ClassResponse { | ||||||
|  |     class: ClassDTO; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface TeacherInvitationsResponse { | ||||||
|  |     invites: TeacherInvitationDTO[]; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface TeacherInvitationResponse { | ||||||
|  |     invite: TeacherInvitationDTO; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export class ClassController extends BaseController { | ||||||
|  |     constructor() { | ||||||
|  |         super("class"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async getAll(full = true): Promise<ClassesResponse> { | ||||||
|  |         return this.get<ClassesResponse>(`/`, { full }); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async getById(id: string): Promise<ClassResponse> { | ||||||
|  |         return this.get<ClassResponse>(`/${id}`); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async createClass(data: ClassDTO): Promise<ClassResponse> { | ||||||
|  |         return this.post<ClassResponse>(`/`, data); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async deleteClass(id: string): Promise<ClassResponse> { | ||||||
|  |         return this.delete<ClassResponse>(`/${id}`); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async getStudents(id: string, full = true): Promise<StudentsResponse> { | ||||||
|  |         return this.get<StudentsResponse>(`/${id}/students`, { full }); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async getTeacherInvitations(id: string, full = true): Promise<TeacherInvitationsResponse> { | ||||||
|  |         return this.get<TeacherInvitationsResponse>(`/${id}/teacher-invitations`, { full }); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async getAssignments(id: string, full = true): Promise<AssignmentsResponse> { | ||||||
|  |         return this.get<AssignmentsResponse>(`/${id}/assignments`, { full }); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -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 { | export interface GroupsResponse { | ||||||
|     groups: GroupDTO[]; |     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): Promise<GroupsResponse> { | ||||||
|  |         return this.get<GroupsResponse>(`/`, { full }); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async getByNumber(num: number): Promise<GroupResponse> { | ||||||
|  |         return this.get<GroupResponse>(`/${num}`); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async createGroup(data: GroupDTO): Promise<GroupResponse> { | ||||||
|  |         return this.post<GroupResponse>(`/`, data); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async deleteGroup(num: number): Promise<GroupResponse> { | ||||||
|  |         return this.delete<GroupResponse>(`/${num}`); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async getSubmissions(groupNumber: number, full = true): Promise<SubmissionsResponse> { | ||||||
|  |         return this.get<SubmissionsResponse>(`/${groupNumber}/submissions`, { full }); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async getQuestions(groupNumber: number, full = true): Promise<QuestionsResponse> { | ||||||
|  |         return this.get<QuestionsResponse>(`/${groupNumber}/questions`, { full }); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ import type { QuestionData, QuestionDTO, QuestionId } from "@dwengo-1/common/int | ||||||
| import { BaseController } from "@/controllers/base-controller.ts"; | import { BaseController } from "@/controllers/base-controller.ts"; | ||||||
| import type { LearningObjectIdentifierDTO } from "@dwengo-1/common/interfaces/learning-content"; | import type { LearningObjectIdentifierDTO } from "@dwengo-1/common/interfaces/learning-content"; | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| export interface QuestionsResponse { | export interface QuestionsResponse { | ||||||
|     questions: QuestionDTO[] | QuestionId[]; |     questions: QuestionDTO[] | QuestionId[]; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -4,8 +4,8 @@ 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 { StudentDTO } from "@dwengo-1/interfaces/student"; | import type { StudentDTO } from "@dwengo-1/common/interfaces/student"; | ||||||
| import type { ClassJoinRequestDTO } from "@dwengo-1/interfaces/class-join-request"; | import type { ClassJoinRequestDTO } from "@dwengo-1/common/interfaces/class-join-request"; | ||||||
| 
 | 
 | ||||||
| export interface StudentsResponse { | export interface StudentsResponse { | ||||||
|     students: StudentDTO[] | string[]; |     students: StudentDTO[] | string[]; | ||||||
|  |  | ||||||
|  | @ -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 { | export interface SubmissionsResponse { | ||||||
|     submissions: SubmissionDTO[] | SubmissionDTOId[]; |     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): Promise<SubmissionsResponse> { | ||||||
|  |         return this.get<SubmissionsResponse>(`/`, { full }); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async getByNumber(submissionNumber: number): Promise<SubmissionResponse> { | ||||||
|  |         return this.get<SubmissionResponse>(`/${submissionNumber}`); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async createSubmission(data: unknown): Promise<SubmissionResponse> { | ||||||
|  |         return this.post<SubmissionResponse>(`/`, data); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async deleteSubmission(submissionNumber: number): Promise<SubmissionResponse> { | ||||||
|  |         return this.delete<SubmissionResponse>(`/${submissionNumber}`); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -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/interfaces/teacher"; | import type { TeacherDTO } from "@dwengo-1/common/interfaces/teacher"; | ||||||
| 
 | 
 | ||||||
| export interface TeachersResponse { | export interface TeachersResponse { | ||||||
|     teachers: TeacherDTO[] | string[]; |     teachers: TeacherDTO[] | string[]; | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| import { BaseController } from "@/controllers/base-controller.ts"; | 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 { | export class ThemeController extends BaseController { | ||||||
|     constructor() { |     constructor() { | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 Gabriellvl
						Gabriellvl