Skip to content

Commit

Permalink
Merge pull request #24 from TU-Wien-dataLAB/release-0.3.1
Browse files Browse the repository at this point in the history
Release 0.3.1
  • Loading branch information
meffmadd authored Jan 29, 2024
2 parents 29695ef + b78e8c2 commit 3184fc0
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 43 deletions.
29 changes: 19 additions & 10 deletions src/services/assignments.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function getAllAssignments(
});
url += '?' + searchParams;
}
return request<AssignmentDetail[]>(HTTPMethod.GET, url, reload);
return request<AssignmentDetail[]>(HTTPMethod.GET, url, null, reload);
}

export function getAssignment(
Expand All @@ -43,17 +43,21 @@ export function getAssignment(
return request<Assignment>(
HTTPMethod.GET,
`/lectures/${lectureId}/assignments/${assignmentId}`,
null,
reload
);
}

export function getAssignmentProperties(
lectureId: number,
assignmentId: number
assignmentId: number,
reload: boolean = false
): Promise<any> {
return request<any>(
HTTPMethod.GET,
`/lectures/${lectureId}/assignments/${assignmentId}/properties`
`/lectures/${lectureId}/assignments/${assignmentId}/properties`,
null,
reload
);
}

Expand All @@ -74,15 +78,17 @@ export function generateAssignment(
): Promise<any> {
return request<any>(
HTTPMethod.PUT,
`/lectures/${lectureId}/assignments/${assignment.id}/generate`
`/lectures/${lectureId}/assignments/${assignment.id}/generate`,
null
);
}

export function fetchAssignment(
lectureId: number,
assignmentId: number,
instructor: boolean = false,
metadataOnly: boolean = false
metadataOnly: boolean = false,
reload: boolean = false
): Promise<Assignment> {
let url = `/lectures/${lectureId}/assignments/${assignmentId}`;
if (instructor || metadataOnly) {
Expand All @@ -93,7 +99,7 @@ export function fetchAssignment(
url += '?' + searchParams;
}

return request<Assignment>(HTTPMethod.GET, url);
return request<Assignment>(HTTPMethod.GET, url, null, reload);
}

export function deleteAssignment(
Expand All @@ -102,7 +108,8 @@ export function deleteAssignment(
): Promise<void> {
return request<void>(
HTTPMethod.DELETE,
`/lectures/${lectureId}/assignments/${assignmentId}`
`/lectures/${lectureId}/assignments/${assignmentId}`,
null
);
}

Expand All @@ -119,7 +126,7 @@ export function pushAssignment(
});
url += '?' + searchParams;
}
return request<void>(HTTPMethod.PUT, url);
return request<void>(HTTPMethod.PUT, url, null);
}

export function pullAssignment(
Expand All @@ -129,7 +136,8 @@ export function pullAssignment(
): Promise<void> {
return request<void>(
HTTPMethod.GET,
`/lectures/${lectureId}/assignments/${assignmentId}/pull/${repoType}`
`/lectures/${lectureId}/assignments/${assignmentId}/pull/${repoType}`,
null
);
}

Expand All @@ -139,6 +147,7 @@ export function resetAssignment(
): Promise<void> {
return request<void>(
HTTPMethod.GET,
`/lectures/${lecture.id}/assignments/${assignment.id}/reset`
`/lectures/${lecture.id}/assignments/${assignment.id}/reset`,
null
);
}
18 changes: 12 additions & 6 deletions src/services/grading.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export function createManualFeedback(
): Promise<any> {
return request<any>(
HTTPMethod.GET,
`/lectures/${lectid}/assignments/${assignid}/grading/${subid}/manual`
`/lectures/${lectid}/assignments/${assignid}/grading/${subid}/manual`,
null
);
}

Expand All @@ -33,7 +34,7 @@ export function saveSubmissions(
});
url += '?' + searchParams;
}
return request<any>(HTTPMethod.PUT, url);
return request<any>(HTTPMethod.PUT, url, null);
}

export function autogradeSubmission(
Expand All @@ -43,7 +44,8 @@ export function autogradeSubmission(
): Promise<any> {
return request<Assignment>(
HTTPMethod.GET,
`/lectures/${lecture.id}/assignments/${assignment.id}/grading/${submission.id}/auto`
`/lectures/${lecture.id}/assignments/${assignment.id}/grading/${submission.id}/auto`,
null
);
}

Expand All @@ -54,7 +56,8 @@ export function generateFeedback(
): Promise<Submission> {
return request<Submission>(
HTTPMethod.GET,
`/lectures/${lecture_id}/assignments/${assignment_id}/grading/${submission_id}/feedback`
`/lectures/${lecture_id}/assignments/${assignment_id}/grading/${submission_id}/feedback`,
null
);
}

Expand All @@ -68,6 +71,7 @@ export function getStudentSubmissions(
return request<any>(
HTTPMethod.GET,
`/lectures/${lecture.id}/assignements/${assignment.id}/grading`,
null,
reload
);
}
Expand All @@ -79,7 +83,8 @@ export function getManualFeedback(
): Promise<object> {
return request<object>(
HTTPMethod.GET,
`/lectures/${lecture.id}/assignments/${assignment.id}/grading/${student.name}/manual`
`/lectures/${lecture.id}/assignments/${assignment.id}/grading/${student.name}/manual`,
null
);
}

Expand Down Expand Up @@ -116,6 +121,7 @@ export function getGrade(
): Promise<any> {
return request<any>(
HTTPMethod.GET,
`/lectures/${lecture.id}/assignments/${assignment.id}/grading/${student.name}/score`
`/lectures/${lecture.id}/assignments/${assignment.id}/grading/${student.name}/score`,
null
);
}
18 changes: 12 additions & 6 deletions src/services/lectures.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function getAllLectures(
});
url += '?' + searchParams;
}
return request<Lecture[]>(HTTPMethod.GET, url, reload);
return request<Lecture[]>(HTTPMethod.GET, url, null, reload);
}

export function updateLecture(lecture: Lecture): Promise<Lecture> {
Expand All @@ -37,19 +37,25 @@ export function getLecture(
lectureId: number,
reload = false
): Promise<Lecture> {
return request<Lecture>(HTTPMethod.GET, `/lectures/${lectureId}`, reload);
return request<Lecture>(
HTTPMethod.GET,
`/lectures/${lectureId}`,
null,
reload
);
}

export function deleteLecture(lectureId: number): void {
request<void>(HTTPMethod.DELETE, `/lectures/${lectureId}`);
export function deleteLecture(lectureId: number): Promise<void> {
return request<void>(HTTPMethod.DELETE, `/lectures/${lectureId}`, null);
}

export function getUsers(
lectureId: number
lectureId: number,
reload: boolean = false
): Promise<{ instructors: string[]; tutors: string[]; students: string[] }> {
return request<{
instructors: string[];
tutors: string[];
students: string[];
}>(HTTPMethod.GET, `/lectures/${lectureId}/users`);
}>(HTTPMethod.GET, `/lectures/${lectureId}/users`, null, reload);
}
10 changes: 0 additions & 10 deletions src/services/ltisync.service.ts

This file was deleted.

3 changes: 2 additions & 1 deletion src/services/permission.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export namespace UserPermissions {
permissions = {};
const response = await request<{ lecture_code: string; scope: number }[]>(
HTTPMethod.GET,
'/permissions'
'/permissions',
null
);
response.forEach(role => {
permissions[role.lecture_code] = role.scope;
Expand Down
4 changes: 2 additions & 2 deletions src/services/request.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export enum HTTPMethod {
DELETE = 'DELETE'
}

export function request<T, B = any>(
export function request<T, B = any | null>(
method: HTTPMethod,
endPoint: string,
body: B = null,
body: B,
reload: boolean = false
): Promise<T> {
const options: RequestInit = {};
Expand Down
18 changes: 10 additions & 8 deletions src/services/submissions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function submitAssignment(
});
url += '?' + searchParams;
}
return request<Submission>(HTTPMethod.PUT, url);
return request<Submission>(HTTPMethod.PUT, url, null);
}

export async function pullFeedback(
Expand All @@ -31,7 +31,8 @@ export async function pullFeedback(
) {
return request<void>(
HTTPMethod.GET,
`/lectures/${lecture.id}/assignments/${assignment.id}/grading/${submission.id}/pull/feedback`
`/lectures/${lecture.id}/assignments/${assignment.id}/grading/${submission.id}/pull/feedback`,
null
);
}

Expand All @@ -46,7 +47,7 @@ export async function pullSubmissionFiles(
subid: String(submission.id)
});
url += '?' + searchParams;
return request<void>(HTTPMethod.GET, url);
return request<void>(HTTPMethod.GET, url, null);
}

export async function createSubmissionFiles(
Expand All @@ -59,7 +60,7 @@ export async function createSubmissionFiles(
for_user: username
});
url += '?' + searchParams;
return request<void>(HTTPMethod.PUT, url);
return request<void>(HTTPMethod.PUT, url, null);
}

export async function pushSubmissionFiles(
Expand All @@ -72,7 +73,7 @@ export async function pushSubmissionFiles(
subid: String(submission.id)
});
url += '?' + searchParams;
return request<void>(HTTPMethod.PUT, url);
return request<void>(HTTPMethod.PUT, url, null);
}

export function getSubmissions(
Expand All @@ -88,7 +89,7 @@ export function getSubmissions(
});
url += '?' + searchParams;
}
return request<any>(HTTPMethod.GET, url, reload);
return request<any>(HTTPMethod.GET, url, null, reload);
}

export function getAllSubmissions(
Expand Down Expand Up @@ -124,7 +125,7 @@ export function getFeedback(
});
url += '?' + searchParams;
}
return request<any>(HTTPMethod.GET, url);
return request<any>(HTTPMethod.GET, url, null);
}

export function getProperties(
Expand Down Expand Up @@ -193,6 +194,7 @@ export function ltiSyncSubmissions(
const url = `/lectures/${lectureId}/assignments/${assignmentId}/submissions/lti`;
return request<{ syncable_users: number; synced_user: number }>(
HTTPMethod.PUT,
url
url,
null
);
}

0 comments on commit 3184fc0

Please sign in to comment.