From 1ae569ad25f974157910ea7031289e8816d680b8 Mon Sep 17 00:00:00 2001 From: Aqua-sc <108478185+Aqua-sc@users.noreply.github.com> Date: Wed, 22 May 2024 09:29:50 +0200 Subject: [PATCH] Fix for sturcturefeedback + admin submit after deadline --- .gitignore | 1 + .../SubmissionTemplateModel.java | 12 ++++++------ .../com/ugent/pidgeon/util/SubmissionUtil.java | 2 +- .../GroupFeedbackControllerTest.java | 4 ++-- .../ugent/pidgeon/util/SubmissionUtilTest.java | 6 ++++++ .../DockerSubmissionTestTest/d__test.zip | Bin 162 -> 162 bytes 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 9a182e36..87feac74 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,4 @@ docker.env startBackend.sh /.env +backend/web-bff/App/.env diff --git a/backend/app/src/main/java/com/ugent/pidgeon/model/submissionTesting/SubmissionTemplateModel.java b/backend/app/src/main/java/com/ugent/pidgeon/model/submissionTesting/SubmissionTemplateModel.java index 13bdd40b..7f7bd347 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/model/submissionTesting/SubmissionTemplateModel.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/model/submissionTesting/SubmissionTemplateModel.java @@ -151,16 +151,16 @@ public SubmissionResult checkSubmission(ZipFile file) throws IOException { boolean passed = (filesMissing.size() + filesUnrequested.size() + filesDenied.size()) == 0; String feedback = passed ? "File structure is correct" : "File structure failed to pass the template, because: \n "; if (!filesMissing.isEmpty()) { - feedback += " -The following files are required from the template and are not found in the project: \n -"; - feedback += String.join("\n -", filesMissing); + feedback += "- The following files are required from the template and are not found in the project: \n - "; + feedback += String.join("\n - ", filesMissing); } if (!filesUnrequested.isEmpty()) { - feedback += "\n -The following files are not requested in the template: \n -"; - feedback += String.join("\n -", filesUnrequested); + feedback += "\n - The following files are not requested in the template: \n - "; + feedback += String.join("\n - ", filesUnrequested); } if (!filesDenied.isEmpty()) { - feedback += "\n -The following files are not allowed in the project: \n -"; - feedback += String.join("\n -", filesDenied); + feedback += "\n - The following files are not allowed in the project: \n - "; + feedback += String.join("\n - ", filesDenied); } return new SubmissionResult(passed, feedback); diff --git a/backend/app/src/main/java/com/ugent/pidgeon/util/SubmissionUtil.java b/backend/app/src/main/java/com/ugent/pidgeon/util/SubmissionUtil.java index 866eed19..b7d996ee 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/util/SubmissionUtil.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/util/SubmissionUtil.java @@ -105,7 +105,7 @@ public CheckResult checkOnSubmit(long projectId, UserEntity user) { OffsetDateTime time = OffsetDateTime.now(); Logger.getGlobal().info("Time: " + time + " Deadline: " + project.getDeadline()); - if (time.isAfter(project.getDeadline())) { + if (time.isAfter(project.getDeadline()) && groupId != null) { return new CheckResult<>(HttpStatus.FORBIDDEN, "Project deadline has passed", null); } return new CheckResult<>(HttpStatus.OK, "", groupId); diff --git a/backend/app/src/test/java/com/ugent/pidgeon/controllers/GroupFeedbackControllerTest.java b/backend/app/src/test/java/com/ugent/pidgeon/controllers/GroupFeedbackControllerTest.java index df28a51d..dce45290 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/controllers/GroupFeedbackControllerTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/controllers/GroupFeedbackControllerTest.java @@ -281,7 +281,7 @@ public void testAddGroupScore() throws Exception { when(groupFeedbackUtil.checkGroupFeedbackUpdate(groupFeedbackEntity.getGroupId(), groupFeedbackEntity.getProjectId(), getMockUser(), HttpMethod.POST)) .thenReturn(new CheckResult<>(HttpStatus.OK, "", null)); when(groupFeedbackUtil.checkGroupFeedbackUpdateJson(argThat( - json -> json.getScore() == groupFeedbackEntity.getScore() && json.getFeedback().equals(groupFeedbackEntity.getFeedback())), eq(groupFeedbackEntity.getProjectId()))) + json -> Objects.equals(json.getScore(), groupFeedbackEntity.getScore()) && json.getFeedback().equals(groupFeedbackEntity.getFeedback())), eq(groupFeedbackEntity.getProjectId()))) .thenReturn(new CheckResult<>(HttpStatus.OK, "", null)); when(groupFeedbackRepository.save(any())).thenReturn(groupFeedbackEntity); when(entityToJsonConverter.groupFeedbackEntityToJson(groupFeedbackEntity)).thenReturn(groupFeedbackJson); @@ -292,7 +292,7 @@ public void testAddGroupScore() throws Exception { .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(content().json(objectMapper.writeValueAsString(groupFeedbackJson))); verify(groupFeedbackRepository, times(1)).save(argThat( - groupFeedback -> groupFeedback.getScore() == groupFeedbackEntity.getScore() && + groupFeedback -> Objects.equals(groupFeedback.getScore(), groupFeedbackEntity.getScore()) && groupFeedback.getFeedback().equals(groupFeedbackEntity.getFeedback()) && groupFeedback.getGroupId() == groupFeedbackEntity.getGroupId() && groupFeedback.getProjectId() == groupFeedbackEntity.getProjectId())); diff --git a/backend/app/src/test/java/com/ugent/pidgeon/util/SubmissionUtilTest.java b/backend/app/src/test/java/com/ugent/pidgeon/util/SubmissionUtilTest.java index a30b71a6..1ca4fe30 100644 --- a/backend/app/src/test/java/com/ugent/pidgeon/util/SubmissionUtilTest.java +++ b/backend/app/src/test/java/com/ugent/pidgeon/util/SubmissionUtilTest.java @@ -157,6 +157,11 @@ public void testCheckOnSubmit() { result = submissionUtil.checkOnSubmit(projectEntity.getId(), userEntity); assertEquals(HttpStatus.OK, result.getStatus()); assertNull(result.getData()); + + /* Deadline passed when user is admin, should still be allowed */ + projectEntity.setDeadline(OffsetDateTime.now().minusDays(1)); + result = submissionUtil.checkOnSubmit(projectEntity.getId(), userEntity); + assertEquals(HttpStatus.OK, result.getStatus()); /* User not part of group and not admin */ when(projectUtil.isProjectAdmin(projectEntity.getId(), userEntity)) @@ -171,6 +176,7 @@ public void testCheckOnSubmit() { result = submissionUtil.checkOnSubmit(projectEntity.getId(), userEntity); assertEquals(HttpStatus.FORBIDDEN, result.getStatus()); + /* GroupCluster in archived course */ when(groupClusterRepository.inArchivedCourse(groupEntity.getClusterId())).thenReturn(true); result = submissionUtil.checkOnSubmit(projectEntity.getId(), userEntity); diff --git a/backend/app/src/test/test-cases/DockerSubmissionTestTest/d__test.zip b/backend/app/src/test/test-cases/DockerSubmissionTestTest/d__test.zip index 00b2b6bfdef119624eab2ce0a67bdbe128332895..b95a278278710c6170339ed58ff8cb9f4adfd3ed 100644 GIT binary patch delta 28 hcmZ3)xQLNAz?+#xgn@&DgW;>!wu!v{%pfY>831Ag2rmEt delta 28 hcmZ3)xQLNAz?+#xgn@&DgJDkd=83%i%pfY>8311e2k8I+