From 5ca9154e261f45e4d16336fd5c3c3b854795634c Mon Sep 17 00:00:00 2001 From: Floris Kornelis van Dijken Date: Mon, 20 May 2024 22:46:58 +0200 Subject: [PATCH] alle docstrings toegevoegd en correcte apidog link gemaakt --- .../controllers/ClusterController.java | 19 +++++-- .../pidgeon/controllers/CourseController.java | 27 +++++++++- .../pidgeon/controllers/GroupController.java | 16 +++--- .../controllers/GroupFeedbackController.java | 44 +++++++++++++-- .../controllers/GroupMemberController.java | 4 +- .../controllers/ProjectController.java | 6 +-- .../pidgeon/controllers/TestController.java | 53 ++++++++++++++++++- .../pidgeon/controllers/UserController.java | 23 +++++++- 8 files changed, 169 insertions(+), 23 deletions(-) diff --git a/backend/app/src/main/java/com/ugent/pidgeon/controllers/ClusterController.java b/backend/app/src/main/java/com/ugent/pidgeon/controllers/ClusterController.java index ebc911bd..36a42280 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/controllers/ClusterController.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/controllers/ClusterController.java @@ -126,7 +126,7 @@ public ResponseEntity createClusterForCourse(@PathVariable("courseid") Long c } /** - * Returns all groups for a cluster + * Get cluster by ID * * @param clusterid identifier of a cluster * @param auth authentication object of the requesting user @@ -193,9 +193,9 @@ public ResponseEntity doGroupClusterUpdate(GroupClusterEntity clusterEntity, * * @param clusterid identifier of a cluster * @param auth authentication object of the requesting user - * @param clusterFillMap Map object containing a map of all groups and their - * members of that cluster + * @param clusterFillMap Map object containing a map of all groups and their members of that cluster * @return ResponseEntity + * @ApiDog apiDog documentation * @HttpMethod PUT * @ApiPath /api/clusters/{clusterid}/fill * @AllowedRoles student, teacher @@ -243,7 +243,18 @@ public ResponseEntity fillCluster(@PathVariable("clusterid") Long clusterid, } } - + /** + * Updates a cluster + * + * @param clusterid identifier of a cluster + * @param auth authentication object of the requesting user + * @param clusterJson ClusterJson object containing the cluster data + * @return ResponseEntity + * @ApiDog apiDog documentation + * @HttpMethod PATCH + * @ApiPath /api/clusters/{clusterid} + * @AllowedRoles student, teacher + */ @PatchMapping(ApiRoutes.CLUSTER_BASE_PATH + "/{clusterid}") @Roles({UserRole.teacher, UserRole.student}) public ResponseEntity patchCluster(@PathVariable("clusterid") Long clusterid, Auth auth, @RequestBody GroupClusterUpdateJson clusterJson) { diff --git a/backend/app/src/main/java/com/ugent/pidgeon/controllers/CourseController.java b/backend/app/src/main/java/com/ugent/pidgeon/controllers/CourseController.java index 8dfc5072..4c61cd39 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/controllers/CourseController.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/controllers/CourseController.java @@ -185,6 +185,18 @@ public ResponseEntity updateCourse(@RequestBody CourseJson courseJson, @PathV } } + /** + * Function to update a course + * + * @param courseJson JSON object containing the course name and description + * @param courseId ID of the course to update + * @param auth authentication object of the requesting user + * @return ResponseEntity with the updated course entity + * @ApiDog apiDog documentation + * @HttpMethod PATCH + * @AllowedRoles teacher, student + * @ApiPath /api/courses/{courseId} + */ @PatchMapping(ApiRoutes.COURSE_BASE_PATH + "/{courseId}") @Roles({UserRole.teacher, UserRole.student}) public ResponseEntity patchCourse(@RequestBody CourseJson courseJson, @PathVariable long courseId, Auth auth) { @@ -417,7 +429,7 @@ public ResponseEntity joinCourse(Auth auth, @PathVariable Long courseId) { * @param auth authentication object of the requesting user * @param courseId ID of the course to get the join key from * @return ResponseEntity with a statuscode and a JSON object containing the course information - * @ApiDog apiDog documentation + * @ApiDog apiDog documentation * @HttpMethod GET * @AllowedRoles teacher, student * @ApiPath /api/courses/{courseId}/join @@ -496,7 +508,7 @@ private ResponseEntity doRemoveFromCourse( * @param courseId ID of the course to add the user to * @param request JSON object containing the user id and relation * @return ResponseEntity with a statuscode and no body - * @ApiDog apiDog documentation + * @ApiDog apiDog documentation * @HttpMethod POST * @AllowedRoles teacher, admin, student * @ApiPath /api/courses/{courseId}/members @@ -680,6 +692,17 @@ public ResponseEntity deleteCourseKey(Auth auth, @PathVariable Long cour return ResponseEntity.ok(""); } + /** + * Function to copy a course + * + * @param courseId ID of the course to copy + * @param auth authentication object of the requesting user + * @return ResponseEntity with the copied course entity + * @ApiDog apiDog documentation + * @HttpMethod POST + * @AllowedRoles teacher + * @ApiPath /api/courses/{courseId}/copy + */ @PostMapping(ApiRoutes.COURSE_BASE_PATH + "/{courseId}/copy") @Roles({UserRole.teacher}) @Transactional diff --git a/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupController.java b/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupController.java index bd579216..141fb9ff 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupController.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupController.java @@ -38,9 +38,13 @@ public class GroupController { /** * Function to get a group by its identifier - * @param groupid - * @param auth - * @return + * @param groupid identifier of a group + * @param auth authentication object of the requesting user + * @return ResponseEntity + * @ApiDog apiDog documentation + * @HttpMethod GET + * @AllowedRoles student, teacher + * @ApiPath /api/groups/{groupid} */ @GetMapping(ApiRoutes.GROUP_BASE_PATH + "/{groupid}") @Roles({UserRole.student, UserRole.teacher}) @@ -75,7 +79,7 @@ public ResponseEntity getGroupById(@PathVariable("groupid") Long groupid, Aut * @param auth authentication object of the requesting user * @return ResponseEntity * @ApiDog apiDog documentation - * @HttpMethod Put + * @HttpMethod PUT * @AllowedRoles teacher * @ApiPath /api/groups/{groupid} */ @@ -93,7 +97,7 @@ public ResponseEntity updateGroupName(@PathVariable("groupid") Long groupid, * @param auth authentication object of the requesting user * @return ResponseEntity * @ApiDog apiDog documentation - * @HttpMethod Patch + * @HttpMethod PATCH * @AllowedRoles teacher * @ApiPath /api/groups/{groupid} */ @@ -136,7 +140,7 @@ private ResponseEntity doGroupNameUpdate(Long groupid, NameRequest nameReques * @param auth authentication object of the requesting user * @return ResponseEntity * @ApiDog apiDog documentation - * @HttpMethod Delete + * @HttpMethod DELETE * @AllowedRoles teacher, student * @ApiPath /api/groups/{groupid} */ diff --git a/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupFeedbackController.java b/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupFeedbackController.java index 49318700..54a52098 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupFeedbackController.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupFeedbackController.java @@ -52,7 +52,7 @@ public class GroupFeedbackController { * @param auth authentication object of the requesting user * @return ResponseEntity * @ApiDog apiDog documentation - * @HttpMethod Patch + * @HttpMethod PATCH * @AllowedRoles teacher, student * @ApiPath /api/projects/{projectid}/groups/{groupid}/score */ @@ -83,6 +83,18 @@ public ResponseEntity updateGroupScore(@PathVariable("groupid") long groupId, return doGroupFeedbackUpdate(groupFeedbackEntity, request); } + /** + * Function to delete the score of a group + * + * @param groupId identifier of a group + * @param projectId identifier of a project + * @param auth authentication object of the requesting user + * @return ResponseEntity + * @ApiDog apiDog documentation + * @HttpMethod Delete + * @AllowedRoles teacher, student + * @ApiPath /api/projects/{projectid}/groups/{groupid}/score + */ @DeleteMapping(ApiRoutes.GROUP_FEEDBACK_PATH) @Roles({UserRole.teacher, UserRole.student}) public ResponseEntity deleteGroupScore(@PathVariable("groupid") long groupId, @PathVariable("projectid") long projectId, Auth auth) { @@ -99,6 +111,19 @@ public ResponseEntity deleteGroupScore(@PathVariable("groupid") long groupId, } } + /** + * Function to update the score of a group + * + * @param groupId identifier of a group + * @param projectId identifier of a project + * @param request request object containing the new score + * @param auth authentication object of the requesting user + * @return ResponseEntity + * @ApiDog apiDog documentation + * @HttpMethod PUT + * @AllowedRoles teacher, student + * @ApiPath /api/projects/{projectid}/groups/{groupid}/score + */ @PutMapping(ApiRoutes.GROUP_FEEDBACK_PATH) @Roles({UserRole.teacher, UserRole.student}) public ResponseEntity updateGroupScorePut(@PathVariable("groupid") long groupId, @PathVariable("projectid") long projectId, @RequestBody UpdateGroupScoreRequest request, Auth auth) { @@ -136,8 +161,8 @@ public ResponseEntity doGroupFeedbackUpdate(GroupFeedbackEntity groupFeedback * @param request request object containing the new score * @param auth authentication object of the requesting user * @return ResponseEntity - * @ApiDog apiDog documentation - * @HttpMethod Post + * @ApiDog apiDog documentation + * @HttpMethod POST * @AllowedRoles teacher, student * @ApiPath /api/groups/{groupid}/projects/{projectid}/feedback */ @@ -174,7 +199,7 @@ public ResponseEntity addGroupScore(@PathVariable("groupid") long groupId, @P * @param projectId identifier of a project * @param auth authentication object of the requesting user * @return ResponseEntity - * @ApiDog apiDog documentation + * @ApiDog apiDog documentation * @HttpMethod Get * @AllowedRoles teacher, student * @ApiPath /api/projects/{projectid}/groups/{groupid}/score @@ -203,6 +228,17 @@ public ResponseEntity getGroupScore(@PathVariable("groupid") long groupI return ResponseEntity.ok(entityToJsonConverter.groupFeedbackEntityToJson(groupFeedbackEntity)); } + /** + * Function to get the grades of a course + * + * @param courseId identifier of a course + * @param auth authentication object of the requesting user + * @return ResponseEntity + * @ApiDog apiDog documentation + * @HttpMethod Get + * @AllowedRoles teacher, student + * @ApiPath /api/courses/{courseId}/grades + */ @GetMapping(ApiRoutes.COURSE_BASE_PATH + "/{courseId}/grades") @Roles({UserRole.teacher, UserRole.student}) public ResponseEntity getCourseGrades(@PathVariable("courseId") long courseId, Auth auth) { diff --git a/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupMemberController.java b/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupMemberController.java index e7e9397c..97d759ee 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupMemberController.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/controllers/GroupMemberController.java @@ -66,7 +66,7 @@ public ResponseEntity removeMemberFromGroup(@PathVariable("groupid") lon * @param groupId ID of the group to remove the member from * @param auth authentication object of the requesting user * @return ResponseEntity with a string message about the operation result - * @ApiDog apiDog documentation + * @ApiDog apiDog documentation * @HttpMethod DELETE * @AllowedRoles teacher, student * @ApiPath /api/groups/{groupid}/members @@ -128,7 +128,7 @@ public ResponseEntity addMemberToGroup(@PathVariable("groupid") long gro * @param groupId ID of the group to add the member to * @param auth authentication object of the requesting user * @return ResponseEntity with a list of UserJson objects containing the members of the group - * @ApiDog apiDog documentation + * @ApiDog apiDog documentation * @HttpMethod POST * @AllowedRoles teacher, student * @ApiPath /api/groups/{groupid}/members diff --git a/backend/app/src/main/java/com/ugent/pidgeon/controllers/ProjectController.java b/backend/app/src/main/java/com/ugent/pidgeon/controllers/ProjectController.java index 3e68a627..0193a4fe 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/controllers/ProjectController.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/controllers/ProjectController.java @@ -50,7 +50,7 @@ public class ProjectController { /** * Function to get all projects of a user * @param auth authentication object of the requesting user - * @ApiDog apiDog documentation + * @ApiDog apiDog documentation * @HttpMethod GET * @AllowedRoles teacher, student * @ApiPath /api/projects @@ -206,7 +206,7 @@ private ResponseEntity doProjectUpdate(ProjectEntity project, ProjectJson pro * @param projectJson ProjectUpdateDTO object containing the new project's information * @param auth authentication object of the requesting user * @ApiDog apiDog documentation - * @HttpMethod Put + * @HttpMethod PUT * @AllowedRoles teacher * @ApiPath /api/projects/{projectId} * @return ResponseEntity with the created project @@ -243,7 +243,7 @@ public ResponseEntity putProjectById(@PathVariable Long projectId, @RequestBo * @param projectJson ProjectUpdateDTO object containing the new project's information * @param auth authentication object of the requesting user * @ApiDog apiDog documentation - * @HttpMethod Patch + * @HttpMethod PATCH * @AllowedRoles teacher * @ApiPath /api/projects/{projectId} * @return ResponseEntity with the created project diff --git a/backend/app/src/main/java/com/ugent/pidgeon/controllers/TestController.java b/backend/app/src/main/java/com/ugent/pidgeon/controllers/TestController.java index e614fc5b..e178d277 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/controllers/TestController.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/controllers/TestController.java @@ -44,7 +44,7 @@ public class TestController { * @param projectId the id of the project to update the tests for * @param auth the authentication object of the requesting user * @HttpMethod POST - * @ApiDog apiDog documentation + * @ApiDog apiDog documentation * @AllowedRoles teacher * @ApiPath /api/projects/{projectid}/tests * @return ResponseEntity with the updated tests @@ -60,6 +60,16 @@ public ResponseEntity updateTests( testJson.getDockerTemplate(), testJson.getStructureTest(), HttpMethod.POST); } + /** + * Function to update the tests of a project + * @param projectId the id of the project to update the tests for + * @param auth the authentication object of the requesting user + * @HttpMethod PATCH + * @ApiDog apiDog documentation + * @AllowedRoles teacher + * @ApiPath /api/projects/{projectid}/tests + * @return ResponseEntity with the updated tests + */ @PatchMapping(ApiRoutes.PROJECT_BASE_PATH + "/{projectid}/tests") @Roles({UserRole.teacher, UserRole.student}) public ResponseEntity patchTests( @@ -71,6 +81,16 @@ public ResponseEntity patchTests( testJson.getDockerTemplate(), testJson.getStructureTest(), HttpMethod.PATCH); } + /** + * Function to update the tests of a project + * @param projectId the id of the project to update the tests for + * @param auth the authentication object of the requesting user + * @HttpMethod PUT + * @ApiDog apiDog documentation + * @AllowedRoles teacher + * @ApiPath /api/projects/{projectid}/tests + * @return ResponseEntity with the updated tests + */ @PutMapping(ApiRoutes.PROJECT_BASE_PATH + "/{projectid}/tests") @Roles({UserRole.teacher, UserRole.student}) public ResponseEntity putTests( @@ -235,6 +255,17 @@ public ResponseEntity deleteTestById(@PathVariable("projectid") long projectI return ResponseEntity.ok().build(); } + /** + * Function to upload extra files for a test + * @param projectId the id of the project to upload the files for + * @param file the file to upload + * @param auth the authentication object of the requesting user + * @HttpMethod PUT + * @ApiDog apiDog documentation + * @AllowedRoles teacher, student + * @ApiPath /api/projects/{projectid}/tests/extrafiles + * @return ResponseEntity with the updated tests + */ @PutMapping(ApiRoutes.PROJECT_BASE_PATH + "/{projectid}/tests/extrafiles") @Roles({UserRole.teacher, UserRole.student}) public ResponseEntity uploadExtraTestFiles( @@ -268,6 +299,16 @@ public ResponseEntity uploadExtraTestFiles( } } + /** + * Function to delete extra files for a test + * @param projectId the id of the project to delete the files for + * @param auth the authentication object of the requesting user + * @HttpMethod DELETE + * @ApiDog apiDog documentation + * @AllowedRoles teacher, student + * @ApiPath /api/projects/{projectid}/tests/extrafiles + * @return ResponseEntity with the updated tests + */ @DeleteMapping(ApiRoutes.PROJECT_BASE_PATH + "/{projectid}/tests/extrafiles") @Roles({UserRole.teacher, UserRole.student}) public ResponseEntity deleteExtraTestFiles( @@ -303,6 +344,16 @@ public ResponseEntity deleteExtraTestFiles( } } + /** + * Function to get extra files for a test + * @param projectId the id of the project to get the files for + * @param auth the authentication object of the requesting user + * @HttpMethod GET + * @ApiDog apiDog documentation + * @AllowedRoles teacher, student + * @ApiPath /api/projects/{projectid}/tests/extrafiles + * @return ResponseEntity with the updated tests + */ @GetMapping(ApiRoutes.PROJECT_BASE_PATH + "/{projectid}/tests/extrafiles") @Roles({UserRole.teacher, UserRole.student}) public ResponseEntity getExtraTestFiles( diff --git a/backend/app/src/main/java/com/ugent/pidgeon/controllers/UserController.java b/backend/app/src/main/java/com/ugent/pidgeon/controllers/UserController.java index 7351275b..566c2407 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/controllers/UserController.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/controllers/UserController.java @@ -56,6 +56,18 @@ public ResponseEntity getUserById(@PathVariable("userid") Long userid,Au return ResponseEntity.ok().body(res); } + /** + * Function to search users by email, name and surname + * + * @param email email of a user + * @param name name of a user + * @param surname surname of a user + * @HttpMethod GET + * @ApiPath /api/user + * @AllowedRoles admin + * @ApiDog apiDog documentation + * @return user object + */ @GetMapping(ApiRoutes.USERS_BASE_PATH) @Roles({UserRole.admin}) public ResponseEntity getUsersByNameOrSurname( @@ -91,7 +103,16 @@ public ResponseEntity getUsersByNameOrSurname( return ResponseEntity.ok().body(usersByName.stream().map(UserJson::new).toList()); } - + /** + * Function to get the logged in user + * + * @param auth authentication object + * @HttpMethod GET + * @ApiPath /api/user + * @AllowedRoles student + * @ApiDog apiDog documentation + * @return user object + */ @GetMapping(ApiRoutes.LOGGEDIN_USER_PATH) @Roles({UserRole.student, UserRole.teacher}) public ResponseEntity getLoggedInUser(Auth auth) {