diff --git a/src/main/java/teammates/common/datatransfer/attributes/FeedbackSessionAttributes.java b/src/main/java/teammates/common/datatransfer/attributes/FeedbackSessionAttributes.java index f794a4b490d..13686be3317 100644 --- a/src/main/java/teammates/common/datatransfer/attributes/FeedbackSessionAttributes.java +++ b/src/main/java/teammates/common/datatransfer/attributes/FeedbackSessionAttributes.java @@ -121,26 +121,26 @@ public FeedbackSessionAttributes getCopy() { * Creates a copy that uses the specific deadline for the given student. * * @param studentEmail The email address of the given student. - * @return The sanitized copy of this object for the given student. + * @return The copy of this object for the given student. */ - public FeedbackSessionAttributes sanitizeForStudent(String studentEmail) { - FeedbackSessionAttributes sanitizedCopy = getCopy(); - sanitizedCopy.deadlineSupplier = () -> sanitizedCopy.studentDeadlines.getOrDefault(studentEmail, endTime); - sanitizedCopy.userEmail = studentEmail; - return sanitizedCopy; + public FeedbackSessionAttributes getCopyForStudent(String studentEmail) { + FeedbackSessionAttributes copy = getCopy(); + copy.deadlineSupplier = () -> copy.studentDeadlines.getOrDefault(studentEmail, endTime); + copy.userEmail = studentEmail; + return copy; } /** * Creates a copy that uses the specific deadline for the given instructor. * * @param instructorEmail The email address of the given instructor. - * @return The sanitized copy of this object for the given instructor. + * @return The copy of this object for the given instructor. */ - public FeedbackSessionAttributes sanitizeForInstructor(String instructorEmail) { - FeedbackSessionAttributes sanitizedCopy = getCopy(); - sanitizedCopy.deadlineSupplier = () -> sanitizedCopy.instructorDeadlines.getOrDefault(instructorEmail, endTime); - sanitizedCopy.userEmail = instructorEmail; - return sanitizedCopy; + public FeedbackSessionAttributes getCopyForInstructor(String instructorEmail) { + FeedbackSessionAttributes copy = getCopy(); + copy.deadlineSupplier = () -> copy.instructorDeadlines.getOrDefault(instructorEmail, endTime); + copy.userEmail = instructorEmail; + return copy; } public String getCourseId() { diff --git a/src/main/java/teammates/ui/webapi/CreateFeedbackResponseCommentAction.java b/src/main/java/teammates/ui/webapi/CreateFeedbackResponseCommentAction.java index bc00360c004..7e4f9674745 100644 --- a/src/main/java/teammates/ui/webapi/CreateFeedbackResponseCommentAction.java +++ b/src/main/java/teammates/ui/webapi/CreateFeedbackResponseCommentAction.java @@ -54,7 +54,7 @@ void checkSpecificAccessControl() throws UnauthorizedAccessException { if (studentAttributes == null) { throw new EntityNotFoundException("Student does not exist."); } - session = session.sanitizeForStudent(studentAttributes.getEmail()); + session = session.getCopyForStudent(studentAttributes.getEmail()); gateKeeper.verifyAnswerableForStudent(question); verifySessionOpenExceptForModeration(session); @@ -71,7 +71,7 @@ void checkSpecificAccessControl() throws UnauthorizedAccessException { if (instructorAsFeedbackParticipant == null) { throw new EntityNotFoundException("Instructor does not exist."); } - session = session.sanitizeForInstructor(instructorAsFeedbackParticipant.getEmail()); + session = session.getCopyForInstructor(instructorAsFeedbackParticipant.getEmail()); gateKeeper.verifyAnswerableForInstructor(question); verifySessionOpenExceptForModeration(session); diff --git a/src/main/java/teammates/ui/webapi/DeleteFeedbackResponseCommentAction.java b/src/main/java/teammates/ui/webapi/DeleteFeedbackResponseCommentAction.java index 53c29614cc3..4ca87f786b1 100644 --- a/src/main/java/teammates/ui/webapi/DeleteFeedbackResponseCommentAction.java +++ b/src/main/java/teammates/ui/webapi/DeleteFeedbackResponseCommentAction.java @@ -42,7 +42,7 @@ void checkSpecificAccessControl() throws UnauthorizedAccessException { verifyNotPreview(); checkAccessControlForStudentFeedbackSubmission(student, session); - session = session.sanitizeForStudent(student.getEmail()); + session = session.getCopyForStudent(student.getEmail()); verifySessionOpenExceptForModeration(session); gateKeeper.verifyOwnership(frc, question.getGiverType() == FeedbackParticipantType.TEAMS @@ -56,7 +56,7 @@ void checkSpecificAccessControl() throws UnauthorizedAccessException { verifyNotPreview(); checkAccessControlForInstructorFeedbackSubmission(instructorAsFeedbackParticipant, session); - session = session.sanitizeForInstructor(instructorAsFeedbackParticipant.getEmail()); + session = session.getCopyForInstructor(instructorAsFeedbackParticipant.getEmail()); verifySessionOpenExceptForModeration(session); gateKeeper.verifyOwnership(frc, instructorAsFeedbackParticipant.getEmail()); break; diff --git a/src/main/java/teammates/ui/webapi/GetFeedbackSessionAction.java b/src/main/java/teammates/ui/webapi/GetFeedbackSessionAction.java index fa18401d611..34a847dc9ca 100644 --- a/src/main/java/teammates/ui/webapi/GetFeedbackSessionAction.java +++ b/src/main/java/teammates/ui/webapi/GetFeedbackSessionAction.java @@ -78,12 +78,12 @@ public JsonResult execute() { private FeedbackSessionData getStudentFeedbackSessionData(FeedbackSessionAttributes session) { StudentAttributes student = getStudentOfCourseFromRequest(session.getCourseId()); String email = student.getEmail(); - return new FeedbackSessionData(session.sanitizeForStudent(email)); + return new FeedbackSessionData(session.getCopyForStudent(email)); } private FeedbackSessionData getInstructorFeedbackSessionData(FeedbackSessionAttributes session) { InstructorAttributes instructor = getInstructorOfCourseFromRequest(session.getCourseId()); String email = instructor.getEmail(); - return new FeedbackSessionData(session.sanitizeForInstructor(email)); + return new FeedbackSessionData(session.getCopyForInstructor(email)); } } diff --git a/src/main/java/teammates/ui/webapi/GetFeedbackSessionsAction.java b/src/main/java/teammates/ui/webapi/GetFeedbackSessionsAction.java index bfc00eb4c61..6c37a525ebf 100644 --- a/src/main/java/teammates/ui/webapi/GetFeedbackSessionsAction.java +++ b/src/main/java/teammates/ui/webapi/GetFeedbackSessionsAction.java @@ -82,7 +82,7 @@ public JsonResult execute() { if (!userInfo.isAdmin) { sessions = sessions.stream() - .map(session -> session.sanitizeForStudent(emailAddress)) + .map(session -> session.getCopyForStudent(emailAddress)) .collect(Collectors.toList()); } @@ -108,7 +108,7 @@ public JsonResult execute() { assert student != null; String emailAddress = student.getEmail(); feedbackSessionAttributes = feedbackSessionAttributes.stream() - .map(instructorSession -> instructorSession.sanitizeForStudent(emailAddress)) + .map(instructorSession -> instructorSession.getCopyForStudent(emailAddress)) .collect(Collectors.toList()); } else if (entityType.equals(Const.EntityType.INSTRUCTOR)) { instructors = Collections.singletonList(logic.getInstructorForGoogleId(courseId, userInfo.getId())); diff --git a/src/main/java/teammates/ui/webapi/SubmitFeedbackResponsesAction.java b/src/main/java/teammates/ui/webapi/SubmitFeedbackResponsesAction.java index c93beda8737..287ac2f9b23 100644 --- a/src/main/java/teammates/ui/webapi/SubmitFeedbackResponsesAction.java +++ b/src/main/java/teammates/ui/webapi/SubmitFeedbackResponsesAction.java @@ -60,7 +60,7 @@ void checkSpecificAccessControl() throws UnauthorizedAccessException { if (studentAttributes == null) { throw new EntityNotFoundException("Student does not exist."); } - feedbackSession = feedbackSession.sanitizeForStudent(studentAttributes.getEmail()); + feedbackSession = feedbackSession.getCopyForStudent(studentAttributes.getEmail()); verifySessionOpenExceptForModeration(feedbackSession); checkAccessControlForStudentFeedbackSubmission(studentAttributes, feedbackSession); break; @@ -70,7 +70,7 @@ void checkSpecificAccessControl() throws UnauthorizedAccessException { if (instructorAttributes == null) { throw new EntityNotFoundException("Instructor does not exist."); } - feedbackSession = feedbackSession.sanitizeForInstructor(instructorAttributes.getEmail()); + feedbackSession = feedbackSession.getCopyForInstructor(instructorAttributes.getEmail()); verifySessionOpenExceptForModeration(feedbackSession); checkAccessControlForInstructorFeedbackSubmission(instructorAttributes, feedbackSession); break; diff --git a/src/main/java/teammates/ui/webapi/UpdateFeedbackResponseCommentAction.java b/src/main/java/teammates/ui/webapi/UpdateFeedbackResponseCommentAction.java index 9c3888d4f9a..7abaa00665d 100644 --- a/src/main/java/teammates/ui/webapi/UpdateFeedbackResponseCommentAction.java +++ b/src/main/java/teammates/ui/webapi/UpdateFeedbackResponseCommentAction.java @@ -53,7 +53,7 @@ void checkSpecificAccessControl() throws UnauthorizedAccessException { if (student == null) { throw new EntityNotFoundException("Student does not exist."); } - session = session.sanitizeForStudent(student.getEmail()); + session = session.getCopyForStudent(student.getEmail()); gateKeeper.verifyAnswerableForStudent(question); verifySessionOpenExceptForModeration(session); @@ -70,7 +70,7 @@ void checkSpecificAccessControl() throws UnauthorizedAccessException { if (instructorAsFeedbackParticipant == null) { throw new EntityNotFoundException("Instructor does not exist."); } - session = session.sanitizeForInstructor(instructorAsFeedbackParticipant.getEmail()); + session = session.getCopyForInstructor(instructorAsFeedbackParticipant.getEmail()); gateKeeper.verifyAnswerableForInstructor(question); verifySessionOpenExceptForModeration(session); diff --git a/src/test/java/teammates/common/datatransfer/attributes/FeedbackSessionAttributesTest.java b/src/test/java/teammates/common/datatransfer/attributes/FeedbackSessionAttributesTest.java index 607a271fc06..7644cdedb02 100644 --- a/src/test/java/teammates/common/datatransfer/attributes/FeedbackSessionAttributesTest.java +++ b/src/test/java/teammates/common/datatransfer/attributes/FeedbackSessionAttributesTest.java @@ -297,7 +297,7 @@ public void testGetCopy() { } @Test - public void testSanitizeForStudent() { + public void testGetCopyForStudent() { DataBundle typicalDataBundle = getTypicalDataBundle(); FeedbackSessionAttributes session1InCourse1 = typicalDataBundle.feedbackSessions .get("session1InCourse1"); @@ -305,12 +305,12 @@ public void testSanitizeForStudent() { StudentAttributes student1InCourse1 = typicalDataBundle.students.get("student1InCourse1"); StudentAttributes student3InCourse1 = typicalDataBundle.students.get("student3InCourse1"); - FeedbackSessionAttributes sanitizedSession1InCourse1 = session1InCourse1.sanitizeForStudent( + FeedbackSessionAttributes sanitizedSession1InCourse1 = session1InCourse1.getCopyForStudent( student1InCourse1.getEmail()); assertEquals(sanitizedSession1InCourse1.getEndTime(), sanitizedSession1InCourse1.getDeadline()); assertEquals(student1InCourse1.getEmail(), sanitizedSession1InCourse1.getUserEmail()); - sanitizedSession1InCourse1 = session1InCourse1.sanitizeForStudent(student3InCourse1.getEmail()); + sanitizedSession1InCourse1 = session1InCourse1.getCopyForStudent(student3InCourse1.getEmail()); assertEquals(sanitizedSession1InCourse1.getStudentDeadlines().get(student3InCourse1.getEmail()), sanitizedSession1InCourse1.getDeadline()); assertEquals(student3InCourse1.getEmail(), sanitizedSession1InCourse1.getUserEmail()); @@ -319,7 +319,7 @@ public void testSanitizeForStudent() { } @Test - public void testSanitizeForInstructor() { + public void testGetCopyForInstructor() { DataBundle typicalDataBundle = getTypicalDataBundle(); FeedbackSessionAttributes session1InCourse1 = typicalDataBundle.feedbackSessions .get("session1InCourse1"); @@ -327,12 +327,12 @@ public void testSanitizeForInstructor() { InstructorAttributes helperOfCourse1 = typicalDataBundle.instructors.get("helperOfCourse1"); InstructorAttributes instructor1OfCourse1 = typicalDataBundle.instructors.get("instructor1OfCourse1"); - FeedbackSessionAttributes sanitizedSession1InCourse1 = session1InCourse1.sanitizeForInstructor( + FeedbackSessionAttributes sanitizedSession1InCourse1 = session1InCourse1.getCopyForInstructor( helperOfCourse1.getEmail()); assertEquals(sanitizedSession1InCourse1.getEndTime(), sanitizedSession1InCourse1.getDeadline()); assertEquals(helperOfCourse1.getEmail(), sanitizedSession1InCourse1.getUserEmail()); - sanitizedSession1InCourse1 = session1InCourse1.sanitizeForInstructor(instructor1OfCourse1.getEmail()); + sanitizedSession1InCourse1 = session1InCourse1.getCopyForInstructor(instructor1OfCourse1.getEmail()); assertEquals(sanitizedSession1InCourse1.getInstructorDeadlines().get(instructor1OfCourse1.getEmail()), sanitizedSession1InCourse1.getDeadline()); assertEquals(instructor1OfCourse1.getEmail(), sanitizedSession1InCourse1.getUserEmail()); diff --git a/src/test/java/teammates/ui/webapi/GetFeedbackSessionsActionTest.java b/src/test/java/teammates/ui/webapi/GetFeedbackSessionsActionTest.java index 7f578f04e00..de075464973 100644 --- a/src/test/java/teammates/ui/webapi/GetFeedbackSessionsActionTest.java +++ b/src/test/java/teammates/ui/webapi/GetFeedbackSessionsActionTest.java @@ -219,7 +219,7 @@ protected void testExecute_asStudentWithDeadlines_shouldHaveCorrectSubmissionSta .withEndTime(newEndTime) .build()); List expectedSessions = sessionsInCourse1.stream() - .map(session -> session.sanitizeForStudent(emailAddress)) + .map(session -> session.getCopyForStudent(emailAddress)) .collect(Collectors.toList()); int expectedSession2InCourse1Index = expectedSessions.indexOf(session2InCourse1); FeedbackSessionAttributes expectedSession2InCourse1 = expectedSessions.get(expectedSession2InCourse1Index);