diff --git a/src/main/java/de/tum/in/www1/artemis/domain/enumeration/CourseInformationSharingConfiguration.java b/src/main/java/de/tum/in/www1/artemis/domain/enumeration/CourseInformationSharingConfiguration.java index 90e36fd74a1f..4dbf3630385c 100644 --- a/src/main/java/de/tum/in/www1/artemis/domain/enumeration/CourseInformationSharingConfiguration.java +++ b/src/main/java/de/tum/in/www1/artemis/domain/enumeration/CourseInformationSharingConfiguration.java @@ -17,13 +17,9 @@ public enum CourseInformationSharingConfiguration { /** * Only Communication is enabled VALUE = 2 */ - COMMUNICATION_ONLY, - /** - * Only Messaging is enabled VALUE = 3 - */ - MESSAGING_ONLY; + COMMUNICATION_ONLY; public boolean isMessagingEnabled() { - return this == MESSAGING_ONLY || this == COMMUNICATION_AND_MESSAGING; + return this == COMMUNICATION_AND_MESSAGING; } } diff --git a/src/main/java/de/tum/in/www1/artemis/repository/CourseRepository.java b/src/main/java/de/tum/in/www1/artemis/repository/CourseRepository.java index 9e173ad9cd67..104d5f273632 100644 --- a/src/main/java/de/tum/in/www1/artemis/repository/CourseRepository.java +++ b/src/main/java/de/tum/in/www1/artemis/repository/CourseRepository.java @@ -503,8 +503,7 @@ default Course findWithEagerLearningPathsAndCompetenciesByIdElseThrow(long cours * @return true if the messaging feature is enabled for the course, false otherwise */ default boolean isMessagingEnabled(long courseId) { - return informationSharingConfigurationIsOneOf(courseId, - Set.of(CourseInformationSharingConfiguration.MESSAGING_ONLY, CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING)); + return informationSharingConfigurationIsOneOf(courseId, Set.of(CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING)); } /** @@ -514,8 +513,8 @@ default boolean isMessagingEnabled(long courseId) { * @return true if the communication feature is enabled for the course, false otherwise */ default boolean isMessagingOrCommunicationEnabled(long courseId) { - return informationSharingConfigurationIsOneOf(courseId, Set.of(CourseInformationSharingConfiguration.COMMUNICATION_ONLY, - CourseInformationSharingConfiguration.MESSAGING_ONLY, CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING)); + return informationSharingConfigurationIsOneOf(courseId, + Set.of(CourseInformationSharingConfiguration.COMMUNICATION_ONLY, CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING)); } /** diff --git a/src/main/java/de/tum/in/www1/artemis/web/rest/metis/conversation/ConversationManagementResource.java b/src/main/java/de/tum/in/www1/artemis/web/rest/metis/conversation/ConversationManagementResource.java index 05d8255c842b..7043fda37972 100644 --- a/src/main/java/de/tum/in/www1/artemis/web/rest/metis/conversation/ConversationManagementResource.java +++ b/src/main/java/de/tum/in/www1/artemis/web/rest/metis/conversation/ConversationManagementResource.java @@ -1,7 +1,5 @@ package de.tum.in.www1.artemis.web.rest.metis.conversation; -import java.util.Set; - import org.springframework.http.HttpStatus; import org.springframework.web.server.ResponseStatusException; @@ -36,8 +34,7 @@ void checkMessagingEnabledElseThrow(Long courseId) { * @param course the course to check */ void checkMessagingEnabledElseThrow(Course course) { - if (!Set.of(CourseInformationSharingConfiguration.MESSAGING_ONLY, CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING) - .contains(course.getCourseInformationSharingConfiguration())) { + if (course.getCourseInformationSharingConfiguration() != CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING) { throw new ResponseStatusException(HttpStatus.FORBIDDEN, "Messaging is not enabled for this course"); } } diff --git a/src/main/resources/config/liquibase/changelog/20240620150000_changelog.xml b/src/main/resources/config/liquibase/changelog/20240620150000_changelog.xml new file mode 100644 index 000000000000..72df2dc4f1b2 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20240620150000_changelog.xml @@ -0,0 +1,11 @@ + + + + + + info_sharing_config = 3 + + + diff --git a/src/main/resources/config/liquibase/master.xml b/src/main/resources/config/liquibase/master.xml index 51a0a0c8c997..93e647365228 100644 --- a/src/main/resources/config/liquibase/master.xml +++ b/src/main/resources/config/liquibase/master.xml @@ -13,6 +13,7 @@ + diff --git a/src/main/webapp/app/entities/course.model.ts b/src/main/webapp/app/entities/course.model.ts index f4323c822b1a..e65b11abc760 100644 --- a/src/main/webapp/app/entities/course.model.ts +++ b/src/main/webapp/app/entities/course.model.ts @@ -16,7 +16,6 @@ import { LearningPath } from 'app/entities/competency/learning-path.model'; export enum CourseInformationSharingConfiguration { COMMUNICATION_AND_MESSAGING = 'COMMUNICATION_AND_MESSAGING', COMMUNICATION_ONLY = 'COMMUNICATION_ONLY', - MESSAGING_ONLY = 'MESSAGING_ONLY', DISABLED = 'DISABLED', } @@ -33,7 +32,7 @@ export function isCommunicationEnabled(course: Course | undefined) { */ export function isMessagingEnabled(course: Course | undefined) { const config = course?.courseInformationSharingConfiguration; - return config === CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING || config === CourseInformationSharingConfiguration.MESSAGING_ONLY; + return config === CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING; } /** @@ -41,11 +40,7 @@ export function isMessagingEnabled(course: Course | undefined) { */ export function isMessagingOrCommunicationEnabled(course: Course | undefined) { const config = course?.courseInformationSharingConfiguration; - return ( - config === CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING || - config === CourseInformationSharingConfiguration.MESSAGING_ONLY || - config === CourseInformationSharingConfiguration.COMMUNICATION_ONLY - ); + return config === CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING || config === CourseInformationSharingConfiguration.COMMUNICATION_ONLY; } export const enum Language { diff --git a/src/test/cypress/support/artemis.ts b/src/test/cypress/support/artemis.ts index d2407d6b33b8..c23be9249317 100644 --- a/src/test/cypress/support/artemis.ts +++ b/src/test/cypress/support/artemis.ts @@ -23,7 +23,6 @@ export const courseList = pageObjects.course.list; export const courseOverview = pageObjects.course.overview; export const courseManagement = pageObjects.course.management; export const courseManagementExercises = pageObjects.course.managementExercises; -export const courseCommunication = pageObjects.course.communication; export const courseMessages = pageObjects.course.messages; export const courseAssessment = pageObjects.assessment.course; diff --git a/src/test/cypress/support/requests/CourseManagementAPIRequests.ts b/src/test/cypress/support/requests/CourseManagementAPIRequests.ts index 33af32d58fa1..60fc4002baed 100644 --- a/src/test/cypress/support/requests/CourseManagementAPIRequests.ts +++ b/src/test/cypress/support/requests/CourseManagementAPIRequests.ts @@ -62,9 +62,6 @@ export class CourseManagementAPIRequests { course.courseInformationSharingMessagingCodeOfConduct = 'Code of Conduct'; } else if (allowCommunication) { course.courseInformationSharingConfiguration = CourseInformationSharingConfiguration.COMMUNICATION_ONLY; - } else if (allowMessaging) { - course.courseInformationSharingConfiguration = CourseInformationSharingConfiguration.MESSAGING_ONLY; - course.courseInformationSharingMessagingCodeOfConduct = 'Code of Conduct'; } else { course.courseInformationSharingConfiguration = CourseInformationSharingConfiguration.DISABLED; } diff --git a/src/test/java/de/tum/in/www1/artemis/course/CourseFactory.java b/src/test/java/de/tum/in/www1/artemis/course/CourseFactory.java index c5f1bf0f8021..eaad8b2d11d9 100644 --- a/src/test/java/de/tum/in/www1/artemis/course/CourseFactory.java +++ b/src/test/java/de/tum/in/www1/artemis/course/CourseFactory.java @@ -145,9 +145,6 @@ public static Course generateCourse(Long id, String shortName, ZonedDateTime sta else if (communicationEnabled) { course.setCourseInformationSharingConfiguration(CourseInformationSharingConfiguration.COMMUNICATION_ONLY); } - else if (messagingEnabled) { - course.setCourseInformationSharingConfiguration(CourseInformationSharingConfiguration.MESSAGING_ONLY); - } else { course.setCourseInformationSharingConfiguration(CourseInformationSharingConfiguration.DISABLED); } diff --git a/src/test/java/de/tum/in/www1/artemis/course/CourseTestService.java b/src/test/java/de/tum/in/www1/artemis/course/CourseTestService.java index eb1745529535..50b135c9170f 100644 --- a/src/test/java/de/tum/in/www1/artemis/course/CourseTestService.java +++ b/src/test/java/de/tum/in/www1/artemis/course/CourseTestService.java @@ -480,7 +480,7 @@ public void testCreateCourseWithCustomNonExistingGroupNames() throws Exception { // Test public void testCreateCourseWithOptions() throws Exception { // Generate POST Request Body with maxComplaints = 5, maxComplaintTimeDays = 14, communication = false, messaging = true - Course course = CourseFactory.generateCourse(null, null, null, new HashSet<>(), null, null, null, null, 5, 5, 14, 2000, 2000, false, true, 0); + Course course = CourseFactory.generateCourse(null, null, null, new HashSet<>(), null, null, null, null, 5, 5, 14, 2000, 2000, false, false, 0); mockDelegate.mockCreateGroupInUserManagement(course.getDefaultStudentGroupName()); mockDelegate.mockCreateGroupInUserManagement(course.getDefaultTeachingAssistantGroupName()); @@ -493,7 +493,7 @@ public void testCreateCourseWithOptions() throws Exception { assertThat(getFromRepo.getMaxComplaints()).as("Course has right maxComplaints Value").isEqualTo(5); assertThat(getFromRepo.getMaxComplaintTimeDays()).as("Course has right maxComplaintTimeDays Value").isEqualTo(14); assertThat(getFromRepo.getCourseInformationSharingConfiguration()).as("Course has right information sharing config value") - .isEqualTo(CourseInformationSharingConfiguration.MESSAGING_ONLY); + .isEqualTo(CourseInformationSharingConfiguration.DISABLED); assertThat(getFromRepo.getRequestMoreFeedbackEnabled()).as("Course has right requestMoreFeedbackEnabled value").isFalse(); // Test edit course diff --git a/src/test/java/de/tum/in/www1/artemis/course/CourseUtilService.java b/src/test/java/de/tum/in/www1/artemis/course/CourseUtilService.java index 2bd7d6ae3498..2d1b3e063ddf 100644 --- a/src/test/java/de/tum/in/www1/artemis/course/CourseUtilService.java +++ b/src/test/java/de/tum/in/www1/artemis/course/CourseUtilService.java @@ -1029,11 +1029,7 @@ public void saveCourse(Course course) { public void enableMessagingForCourse(Course course) { CourseInformationSharingConfiguration currentConfig = course.getCourseInformationSharingConfiguration(); - if (currentConfig == CourseInformationSharingConfiguration.DISABLED) { - course.setCourseInformationSharingConfiguration(CourseInformationSharingConfiguration.MESSAGING_ONLY); - courseRepo.save(course); - } - else if (currentConfig == CourseInformationSharingConfiguration.COMMUNICATION_ONLY) { + if (currentConfig == CourseInformationSharingConfiguration.COMMUNICATION_ONLY) { course.setCourseInformationSharingConfiguration(CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING); courseRepo.save(course); } diff --git a/src/test/java/de/tum/in/www1/artemis/metis/AnswerMessageIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/metis/AnswerMessageIntegrationTest.java index aa2eeaf13953..e83a5999533f 100644 --- a/src/test/java/de/tum/in/www1/artemis/metis/AnswerMessageIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/metis/AnswerMessageIntegrationTest.java @@ -661,7 +661,6 @@ protected static List userMentionProvider() { } private static List courseInformationSharingConfigurationProvider() { - return List.of(CourseInformationSharingConfiguration.MESSAGING_ONLY, CourseInformationSharingConfiguration.COMMUNICATION_ONLY, - CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING); + return List.of(CourseInformationSharingConfiguration.COMMUNICATION_ONLY, CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING); } } diff --git a/src/test/java/de/tum/in/www1/artemis/metis/ConversationIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/metis/ConversationIntegrationTest.java index d2058a683ffd..f720f86c1c75 100644 --- a/src/test/java/de/tum/in/www1/artemis/metis/ConversationIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/metis/ConversationIntegrationTest.java @@ -624,7 +624,6 @@ private List createExerciseAndExamAndLectureChannels(Course course, ZonedD private static List courseConfigurationProvider() { return List.of(Arguments.of(CourseInformationSharingConfiguration.DISABLED, HttpStatus.FORBIDDEN), Arguments.of(CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING, HttpStatus.OK), - Arguments.of(CourseInformationSharingConfiguration.COMMUNICATION_ONLY, HttpStatus.OK), - Arguments.of(CourseInformationSharingConfiguration.MESSAGING_ONLY, HttpStatus.OK)); + Arguments.of(CourseInformationSharingConfiguration.COMMUNICATION_ONLY, HttpStatus.OK)); } } diff --git a/src/test/java/de/tum/in/www1/artemis/metis/MessageIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/metis/MessageIntegrationTest.java index 00771d66ad0e..bf97da425c93 100644 --- a/src/test/java/de/tum/in/www1/artemis/metis/MessageIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/metis/MessageIntegrationTest.java @@ -778,8 +778,7 @@ private Post createPostAndAwaitAsyncCode(Post postToSave) throws Exception { } private static List courseInformationSharingConfigurationProvider() { - return List.of(CourseInformationSharingConfiguration.MESSAGING_ONLY, CourseInformationSharingConfiguration.COMMUNICATION_ONLY, - CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING); + return List.of(CourseInformationSharingConfiguration.COMMUNICATION_ONLY, CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING); } @Test diff --git a/src/test/java/de/tum/in/www1/artemis/metis/ReactionIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/metis/ReactionIntegrationTest.java index 7fb4c16d90a4..b26d8c7cfd34 100644 --- a/src/test/java/de/tum/in/www1/artemis/metis/ReactionIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/metis/ReactionIntegrationTest.java @@ -558,6 +558,6 @@ private void checkCreatedReaction(Reaction expectedReaction, Reaction createdRea private static List courseConfigurationProvider() { return List.of(Arguments.of(CourseInformationSharingConfiguration.DISABLED, false), Arguments.of(CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING, true), - Arguments.of(CourseInformationSharingConfiguration.COMMUNICATION_ONLY, true), Arguments.of(CourseInformationSharingConfiguration.MESSAGING_ONLY, true)); + Arguments.of(CourseInformationSharingConfiguration.COMMUNICATION_ONLY, true)); } } diff --git a/src/test/java/de/tum/in/www1/artemis/plagiarism/PlagiarismAnswerPostIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/plagiarism/PlagiarismAnswerPostIntegrationTest.java index 31a32b532fd2..ca1b854b2317 100644 --- a/src/test/java/de/tum/in/www1/artemis/plagiarism/PlagiarismAnswerPostIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/plagiarism/PlagiarismAnswerPostIntegrationTest.java @@ -94,12 +94,6 @@ void testCreateAnswerPostWithUserMention(String userMention, boolean isUserMenti checkCreatedAnswerPost(answerPostToSave, createdAnswerPost); } - @Test - @WithMockUser(username = TEST_PREFIX + "student1", roles = "USER") - void testPostingAllowedIfMessagingOnlySetting() throws Exception { - messagingFeatureDisabledTest(CourseInformationSharingConfiguration.MESSAGING_ONLY); - } - @Test @WithMockUser(username = TEST_PREFIX + "student1", roles = "USER") void testPostingNotAllowedIfDisabledSetting() throws Exception { diff --git a/src/test/javascript/spec/service/metis/metis.service.spec.ts b/src/test/javascript/spec/service/metis/metis.service.spec.ts index 28c14e7c9a54..1dd33f85af55 100644 --- a/src/test/javascript/spec/service/metis/metis.service.spec.ts +++ b/src/test/javascript/spec/service/metis/metis.service.spec.ts @@ -309,7 +309,7 @@ describe('Metis Service', () => { it('should not fetch course post tags if communication is not enabled', () => { const updateCoursePostTagsSpy = jest.spyOn(metisService, 'updateCoursePostTags'); - course.courseInformationSharingConfiguration = CourseInformationSharingConfiguration.MESSAGING_ONLY; + course.courseInformationSharingConfiguration = CourseInformationSharingConfiguration.DISABLED; metisService.setCourse(course); const getCourseReturn = metisService.getCourse(); expect(getCourseReturn).toEqual(course); diff --git a/src/test/playwright/support/requests/CourseManagementAPIRequests.ts b/src/test/playwright/support/requests/CourseManagementAPIRequests.ts index d01e0696853a..3b04f8571785 100644 --- a/src/test/playwright/support/requests/CourseManagementAPIRequests.ts +++ b/src/test/playwright/support/requests/CourseManagementAPIRequests.ts @@ -71,9 +71,6 @@ export class CourseManagementAPIRequests { course.courseInformationSharingMessagingCodeOfConduct = 'Code of Conduct'; } else if (allowCommunication) { course.courseInformationSharingConfiguration = CourseInformationSharingConfiguration.COMMUNICATION_ONLY; - } else if (allowMessaging) { - course.courseInformationSharingConfiguration = CourseInformationSharingConfiguration.MESSAGING_ONLY; - course.courseInformationSharingMessagingCodeOfConduct = 'Code of Conduct'; } else { course.courseInformationSharingConfiguration = CourseInformationSharingConfiguration.DISABLED; }