refactor: group query gerefactord
This commit is contained in:
		
							parent
							
								
									0784db3680
								
							
						
					
					
						commit
						9c58614382
					
				
					 2 changed files with 26 additions and 35 deletions
				
			
		|  | @ -12,43 +12,35 @@ export interface GroupResponse { | |||
| } | ||||
| 
 | ||||
| export class GroupController extends BaseController { | ||||
|     constructor() { | ||||
|         super(''); | ||||
|     constructor(classid: string, assignmentNumber: number) { | ||||
|         super(`class/${classid}/assignments/${assignmentNumber}/groups`); | ||||
|     } | ||||
| 
 | ||||
|     update(classid: string, assignmentNumber: number) { | ||||
|         this.basePath = `class/${classid}/assignments/${assignmentNumber}/groups`; | ||||
|     async getAll(full = true): Promise<GroupsResponse> { | ||||
|         return this.get<GroupsResponse>(`/`, { full }); | ||||
|     } | ||||
| 
 | ||||
|     protected getBasePath(classid: string, assignmentNumber: number) { | ||||
|         return `class/${classid}/assignments/${assignmentNumber}/groups`; | ||||
|     async getByNumber(num: number): Promise<GroupResponse> { | ||||
|         return this.get<GroupResponse>(`/${num}`); | ||||
|     } | ||||
| 
 | ||||
|     async getAll(classid: string, assignmentNumber: number, full = true): Promise<GroupsResponse> { | ||||
|         return this.get<GroupsResponse>(`${this.getBasePath(classid, assignmentNumber)}/`, { full }); | ||||
|     async createGroup(data: GroupDTO): Promise<GroupResponse> { | ||||
|         return this.post<GroupResponse>(`/`, data); | ||||
|     } | ||||
| 
 | ||||
|     async getByNumber(classid: string, assignmentNumber: number, num: number | string): Promise<GroupResponse> { | ||||
|         return this.get<GroupResponse>(`${this.getBasePath(classid, assignmentNumber)}/${num}`); | ||||
|     async deleteGroup(num: number): Promise<GroupResponse> { | ||||
|         return this.delete<GroupResponse>(`/${num}`); | ||||
|     } | ||||
| 
 | ||||
|     async createGroup(classid: string, assignmentNumber: number, data: GroupDTO): Promise<GroupResponse> { | ||||
|         return this.post<GroupResponse>(`${this.getBasePath(classid, assignmentNumber)}/`, data); | ||||
|     async updateGroup(num: number, data: Partial<GroupDTO>): Promise<GroupResponse> { | ||||
|         return this.put<GroupResponse>(`/${num}`, data); | ||||
|     } | ||||
| 
 | ||||
|     async deleteGroup(classid: string, assignmentNumber: number, num: number): Promise<GroupResponse> { | ||||
|         return this.delete<GroupResponse>(`${this.getBasePath(classid, assignmentNumber)}/${num}`); | ||||
|     async getSubmissions(num: number, full = true): Promise<SubmissionsResponse> { | ||||
|         return this.get<SubmissionsResponse>(`/${num}/submissions`, { full }); | ||||
|     } | ||||
| 
 | ||||
|     async updateGroup(classid: string, assignmentNumber: number, num: number, data: Partial<GroupDTO>): Promise<GroupResponse> { | ||||
|         return this.put<GroupResponse>(`${this.getBasePath(classid, assignmentNumber)}/${num}`, data); | ||||
|     } | ||||
| 
 | ||||
|     async getSubmissions(classid: string, assignmentNumber: number, groupNumber: number, full = true): Promise<SubmissionsResponse> { | ||||
|         return this.get<SubmissionsResponse>(`${this.getBasePath(classid, assignmentNumber)}/${groupNumber}/submissions`, { full }); | ||||
|     } | ||||
| 
 | ||||
|     async getQuestions(classid: string, assignmentNumber: number, groupNumber: number, full = true): Promise<QuestionsResponse> { | ||||
|         return this.get<QuestionsResponse>(`${this.getBasePath(classid, assignmentNumber)}/${groupNumber}/questions`, { full }); | ||||
|     async getQuestions(num: number, full = true): Promise<QuestionsResponse> { | ||||
|         return this.get<QuestionsResponse>(`/${num}/questions`, { full }); | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Reference in a new issue
	
	 Adriaan Jacquet
						Adriaan Jacquet