diff --git a/src/main/java/de/tum/cit/aet/artemis/core/config/ArtemisConfigHelper.java b/src/main/java/de/tum/cit/aet/artemis/core/config/ArtemisConfigHelper.java index d8fb8d97e77a..84f50c90ace1 100644 --- a/src/main/java/de/tum/cit/aet/artemis/core/config/ArtemisConfigHelper.java +++ b/src/main/java/de/tum/cit/aet/artemis/core/config/ArtemisConfigHelper.java @@ -2,6 +2,7 @@ import static de.tum.cit.aet.artemis.core.config.Constants.ATLAS_ENABLED_PROPERTY_NAME; import static de.tum.cit.aet.artemis.core.config.Constants.EXAM_ENABLED_PROPERTY_NAME; +import static de.tum.cit.aet.artemis.core.config.Constants.LECTURE_ENABLED_PROPERTY_NAME; import static de.tum.cit.aet.artemis.core.config.Constants.PASSKEY_ENABLED_PROPERTY_NAME; import org.springframework.core.env.Environment; @@ -43,6 +44,16 @@ public boolean isExamEnabled(Environment environment) { return getPropertyOrExitArtemis(EXAM_ENABLED_PROPERTY_NAME, environment); } + /** + * Check if the lecture module is enabled. + * + * @param environment the Spring environment + * @return true if the lecture module is enabled, false otherwise + */ + public boolean isLectureEnabled(Environment environment) { + return getPropertyOrExitArtemis(LECTURE_ENABLED_PROPERTY_NAME, environment); + } + /** * Check if the Plagiarism module is enabled. * diff --git a/src/main/java/de/tum/cit/aet/artemis/core/config/Constants.java b/src/main/java/de/tum/cit/aet/artemis/core/config/Constants.java index dbb49f1395e6..500e7825c4e4 100644 --- a/src/main/java/de/tum/cit/aet/artemis/core/config/Constants.java +++ b/src/main/java/de/tum/cit/aet/artemis/core/config/Constants.java @@ -389,6 +389,11 @@ public final class Constants { */ public static final String MODULE_FEATURE_EXAM = "exam"; + /** + * The name of the module feature used for Lecture functionality. + */ + public static final String MODULE_FEATURE_LECTURE = "lecture"; + /** * The name of the module feature used for plagiarism functionality. */ @@ -414,6 +419,11 @@ public final class Constants { */ public static final String EXAM_ENABLED_PROPERTY_NAME = "artemis.exam.enabled"; + /** + * The name of the property used to enable or disable Lecture functionality. + */ + public static final String LECTURE_ENABLED_PROPERTY_NAME = "artemis.lecture.enabled"; + /** * The name of the property used to enable or disable plagiarism functionality. */ diff --git a/src/main/java/de/tum/cit/aet/artemis/core/config/ModuleFeatureInfoContributor.java b/src/main/java/de/tum/cit/aet/artemis/core/config/ModuleFeatureInfoContributor.java index e8351ca7ecde..5954d0b9c272 100644 --- a/src/main/java/de/tum/cit/aet/artemis/core/config/ModuleFeatureInfoContributor.java +++ b/src/main/java/de/tum/cit/aet/artemis/core/config/ModuleFeatureInfoContributor.java @@ -42,6 +42,9 @@ public void contribute(Info.Builder builder) { if (artemisConfigHelper.isExamEnabled(environment)) { enabledArtemisFeatures.add(Constants.MODULE_FEATURE_EXAM); } + if (artemisConfigHelper.isLectureEnabled(environment)) { + enabledArtemisFeatures.add(Constants.MODULE_FEATURE_LECTURE); + } if (artemisConfigHelper.isPlagiarismEnabled(environment)) { enabledArtemisFeatures.add(Constants.MODULE_FEATURE_PLAGIARISM); } diff --git a/src/main/java/de/tum/cit/aet/artemis/core/service/messaging/InstanceMessageReceiveService.java b/src/main/java/de/tum/cit/aet/artemis/core/service/messaging/InstanceMessageReceiveService.java index e6d38e2350ac..54dafb9ed758 100644 --- a/src/main/java/de/tum/cit/aet/artemis/core/service/messaging/InstanceMessageReceiveService.java +++ b/src/main/java/de/tum/cit/aet/artemis/core/service/messaging/InstanceMessageReceiveService.java @@ -55,7 +55,7 @@ public class InstanceMessageReceiveService { private final UserRepository userRepository; - private final SlideUnhideScheduleService slideUnhideScheduleService; + private final Optional slideUnhideScheduleService; private final HazelcastInstance hazelcastInstance; @@ -64,7 +64,8 @@ public class InstanceMessageReceiveService { public InstanceMessageReceiveService(ProgrammingExerciseRepository programmingExerciseRepository, ProgrammingExerciseScheduleService programmingExerciseScheduleService, ExerciseRepository exerciseRepository, Optional athenaApi, @Qualifier("hazelcastInstance") HazelcastInstance hazelcastInstance, UserRepository userRepository, UserScheduleService userScheduleService, NotificationScheduleService notificationScheduleService, - ParticipantScoreScheduleService participantScoreScheduleService, QuizScheduleService quizScheduleService, SlideUnhideScheduleService slideUnhideScheduleService) { + ParticipantScoreScheduleService participantScoreScheduleService, QuizScheduleService quizScheduleService, + Optional slideUnhideScheduleService) { this.programmingExerciseRepository = programmingExerciseRepository; this.programmingExerciseScheduleService = programmingExerciseScheduleService; this.athenaApi = athenaApi; @@ -206,11 +207,13 @@ public void processCancelQuizStart(Long exerciseId) { public void processScheduleSlideUnhide(Long slideId) { log.info("Received schedule update for slide unhiding {}", slideId); - slideUnhideScheduleService.scheduleSlideUnhiding(slideId); + slideUnhideScheduleService.ifPresentOrElse(service -> service.scheduleSlideUnhiding(slideId), + () -> log.warn("Slide unhide schedule service is not available when lecture.enabled=false, unable to schedule slide unhiding for slide {}", slideId)); } public void processCancelSlideUnhide(Long slideId) { log.info("Received schedule cancel for slide unhiding {}", slideId); - slideUnhideScheduleService.cancelScheduledUnhiding(slideId); + slideUnhideScheduleService.ifPresentOrElse(service -> service.cancelScheduledUnhiding(slideId), + () -> log.warn("Slide unhide schedule service is not available when lecture.enabled=false, unable to cancel slide unhiding for slide {}", slideId)); } } diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/api/LectureApi.java b/src/main/java/de/tum/cit/aet/artemis/lecture/api/LectureApi.java index 423f44534ce6..30722e8f0270 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/api/LectureApi.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/api/LectureApi.java @@ -1,14 +1,13 @@ package de.tum.cit.aet.artemis.lecture.api; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.util.Set; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Controller; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.service.LectureImportService; import de.tum.cit.aet.artemis.lecture.service.LectureService; @@ -16,7 +15,7 @@ /** * API for managing lectures. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Controller public class LectureApi extends AbstractLectureApi { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/api/LectureAttachmentApi.java b/src/main/java/de/tum/cit/aet/artemis/lecture/api/LectureAttachmentApi.java index 4f955069e9ee..bfefba4b7679 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/api/LectureAttachmentApi.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/api/LectureAttachmentApi.java @@ -1,12 +1,11 @@ package de.tum.cit.aet.artemis.lecture.api; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.util.List; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Controller; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Attachment; import de.tum.cit.aet.artemis.lecture.domain.AttachmentType; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; @@ -16,7 +15,7 @@ /** * API for managing lecture attachments. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Controller public class LectureAttachmentApi extends AbstractLectureApi { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/api/LectureRepositoryApi.java b/src/main/java/de/tum/cit/aet/artemis/lecture/api/LectureRepositoryApi.java index 11f0e4fee23a..7aceacc24111 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/api/LectureRepositoryApi.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/api/LectureRepositoryApi.java @@ -1,25 +1,24 @@ package de.tum.cit.aet.artemis.lecture.api; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.time.ZonedDateTime; import java.util.Collection; import java.util.List; import java.util.Optional; import java.util.Set; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Controller; import de.tum.cit.aet.artemis.core.dto.CourseContentCountDTO; import de.tum.cit.aet.artemis.core.exception.NoUniqueQueryException; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; /** * API for managing lectures. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Controller public class LectureRepositoryApi extends AbstractLectureApi { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/api/LectureUnitApi.java b/src/main/java/de/tum/cit/aet/artemis/lecture/api/LectureUnitApi.java index 5aa70444f4d9..3022224ecc63 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/api/LectureUnitApi.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/api/LectureUnitApi.java @@ -1,15 +1,14 @@ package de.tum.cit.aet.artemis.lecture.api; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.util.List; import jakarta.validation.constraints.NotNull; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Controller; import de.tum.cit.aet.artemis.core.domain.User; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.ExerciseUnit; import de.tum.cit.aet.artemis.lecture.domain.LectureUnit; import de.tum.cit.aet.artemis.lecture.repository.ExerciseUnitRepository; @@ -21,7 +20,7 @@ /** * API for managing lecture/exercise units. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Controller public class LectureUnitApi extends AbstractLectureApi { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/api/LectureUnitRepositoryApi.java b/src/main/java/de/tum/cit/aet/artemis/lecture/api/LectureUnitRepositoryApi.java index de3726ceef1b..5d3555592156 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/api/LectureUnitRepositoryApi.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/api/LectureUnitRepositoryApi.java @@ -1,17 +1,16 @@ package de.tum.cit.aet.artemis.lecture.api; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.util.Collection; import java.util.Optional; import java.util.Set; import org.hibernate.NonUniqueResultException; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Controller; import de.tum.cit.aet.artemis.atlas.dto.metrics.LectureUnitInformationDTO; import de.tum.cit.aet.artemis.core.domain.User; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.LectureUnit; import de.tum.cit.aet.artemis.lecture.domain.LectureUnitCompletion; import de.tum.cit.aet.artemis.lecture.repository.LectureUnitCompletionRepository; @@ -21,7 +20,7 @@ /** * API for managing lecture units. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Controller public class LectureUnitRepositoryApi extends AbstractLectureApi { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/api/SlideApi.java b/src/main/java/de/tum/cit/aet/artemis/lecture/api/SlideApi.java index 80a461192bed..e342355a2ba4 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/api/SlideApi.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/api/SlideApi.java @@ -1,11 +1,10 @@ package de.tum.cit.aet.artemis.lecture.api; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Controller; import de.tum.cit.aet.artemis.exercise.domain.Exercise; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Slide; import de.tum.cit.aet.artemis.lecture.repository.SlideRepository; import de.tum.cit.aet.artemis.lecture.service.SlideService; @@ -13,7 +12,7 @@ /** * API for managing slides. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Controller public class SlideApi extends AbstractLectureApi { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/config/LectureEnabled.java b/src/main/java/de/tum/cit/aet/artemis/lecture/config/LectureEnabled.java new file mode 100644 index 000000000000..25bccdf8e6a8 --- /dev/null +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/config/LectureEnabled.java @@ -0,0 +1,25 @@ +package de.tum.cit.aet.artemis.lecture.config; + +import org.springframework.context.annotation.Condition; +import org.springframework.context.annotation.ConditionContext; +import org.springframework.core.type.AnnotatedTypeMetadata; + +import de.tum.cit.aet.artemis.core.config.ArtemisConfigHelper; + +/** + * Condition to check if the Lecture module is enabled. + * Based on this condition, Spring components concerning atlas functionality can be enabled or disabled. + */ +public class LectureEnabled implements Condition { + + private final ArtemisConfigHelper artemisConfigHelper; + + public LectureEnabled() { + this.artemisConfigHelper = new ArtemisConfigHelper(); + } + + @Override + public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { + return artemisConfigHelper.isLectureEnabled(context.getEnvironment()); + } +} diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/AttachmentRepository.java b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/AttachmentRepository.java index 30b1068ed687..7fe0597fef3c 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/AttachmentRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/AttachmentRepository.java @@ -1,21 +1,20 @@ package de.tum.cit.aet.artemis.lecture.repository; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.util.List; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Attachment; /** * Spring Data repository for the Attachment entity. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Repository public interface AttachmentRepository extends ArtemisJpaRepository { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/AttachmentUnitRepository.java b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/AttachmentUnitRepository.java index f43d8a101af5..f9aff669f069 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/AttachmentUnitRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/AttachmentUnitRepository.java @@ -1,26 +1,25 @@ package de.tum.cit.aet.artemis.lecture.repository; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.util.List; import java.util.Optional; import jakarta.validation.constraints.NotNull; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.AttachmentType; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; /** * Spring Data JPA repository for the Attachment Unit entity. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Repository public interface AttachmentUnitRepository extends ArtemisJpaRepository { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/ExerciseUnitRepository.java b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/ExerciseUnitRepository.java index b4858f3dd095..6d73c9533d67 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/ExerciseUnitRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/ExerciseUnitRepository.java @@ -1,21 +1,20 @@ package de.tum.cit.aet.artemis.lecture.repository; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.util.List; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.ExerciseUnit; /** * Spring Data JPA repository for the Exercise Unit entity. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Repository public interface ExerciseUnitRepository extends ArtemisJpaRepository { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/LectureRepository.java b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/LectureRepository.java index 892d195f4061..6c6c19bd37f2 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/LectureRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/LectureRepository.java @@ -1,7 +1,5 @@ package de.tum.cit.aet.artemis.lecture.repository; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.time.ZonedDateTime; import java.util.Optional; import java.util.Set; @@ -9,7 +7,7 @@ import jakarta.validation.constraints.NotNull; import org.springframework.cache.annotation.Cacheable; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.Query; @@ -19,12 +17,13 @@ import de.tum.cit.aet.artemis.core.dto.CourseContentCountDTO; import de.tum.cit.aet.artemis.core.exception.NoUniqueQueryException; import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Lecture; /** * Spring Data repository for the Lecture entity. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Repository public interface LectureRepository extends ArtemisJpaRepository { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/LectureTranscriptionRepository.java b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/LectureTranscriptionRepository.java index bce042230353..17545f6b2c44 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/LectureTranscriptionRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/LectureTranscriptionRepository.java @@ -1,19 +1,18 @@ package de.tum.cit.aet.artemis.lecture.repository; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.util.Optional; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Repository; import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.LectureTranscription; /** * Spring Data JPA repository for the Transcription of a lecture video entity. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Repository public interface LectureTranscriptionRepository extends ArtemisJpaRepository { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/LectureUnitCompletionRepository.java b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/LectureUnitCompletionRepository.java index c45408c2004a..050672287d71 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/LectureUnitCompletionRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/LectureUnitCompletionRepository.java @@ -1,22 +1,21 @@ package de.tum.cit.aet.artemis.lecture.repository; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.util.Collection; import java.util.Optional; import java.util.Set; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.LectureUnit; import de.tum.cit.aet.artemis.lecture.domain.LectureUnitCompletion; -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Repository public interface LectureUnitCompletionRepository extends ArtemisJpaRepository { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/LectureUnitMetricsRepository.java b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/LectureUnitMetricsRepository.java index 588554e3c4f1..d98b510887f4 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/LectureUnitMetricsRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/LectureUnitMetricsRepository.java @@ -1,22 +1,21 @@ package de.tum.cit.aet.artemis.lecture.repository; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.util.Set; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import de.tum.cit.aet.artemis.atlas.dto.metrics.LectureUnitInformationDTO; import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.LectureUnit; /** * Spring Data JPA repository to fetch lecture unit related metrics. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Repository public interface LectureUnitMetricsRepository extends ArtemisJpaRepository { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/LectureUnitRepository.java b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/LectureUnitRepository.java index 42807551d308..ae65bcb51660 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/LectureUnitRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/LectureUnitRepository.java @@ -1,23 +1,22 @@ package de.tum.cit.aet.artemis.lecture.repository; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.util.Optional; import java.util.Set; import org.hibernate.NonUniqueResultException; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.LectureUnit; /** * Spring Data JPA repository for the Lecture Unit entity. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Repository public interface LectureUnitRepository extends ArtemisJpaRepository { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/OnlineUnitRepository.java b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/OnlineUnitRepository.java index b81d768df168..593766fcf42b 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/OnlineUnitRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/OnlineUnitRepository.java @@ -1,23 +1,22 @@ package de.tum.cit.aet.artemis.lecture.repository; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.util.Optional; import jakarta.validation.constraints.NotNull; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.OnlineUnit; /** * Spring Data JPA repository for the Online Unit entity. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Repository public interface OnlineUnitRepository extends ArtemisJpaRepository { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/SlideRepository.java b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/SlideRepository.java index cee874fa0c8f..28fb2be6e1eb 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/SlideRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/SlideRepository.java @@ -1,11 +1,9 @@ package de.tum.cit.aet.artemis.lecture.repository; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.util.List; import java.util.Set; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; @@ -13,6 +11,7 @@ import org.springframework.transaction.annotation.Transactional; import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Slide; import de.tum.cit.aet.artemis.lecture.dto.SlideDTO; import de.tum.cit.aet.artemis.lecture.dto.SlideUnhideDTO; @@ -20,7 +19,7 @@ /** * Spring Data JPA repository for the Attachment Unit entity. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Repository public interface SlideRepository extends ArtemisJpaRepository { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/TextUnitRepository.java b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/TextUnitRepository.java index 3cbcd78236ad..f4aab7992fac 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/TextUnitRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/TextUnitRepository.java @@ -1,21 +1,20 @@ package de.tum.cit.aet.artemis.lecture.repository; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.util.Optional; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.TextUnit; /** * Spring Data JPA repository for the Text Unit entity. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Repository public interface TextUnitRepository extends ArtemisJpaRepository { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/VideoUnitRepository.java b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/VideoUnitRepository.java index 1435525961a5..3995a7c14777 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/VideoUnitRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/VideoUnitRepository.java @@ -1,23 +1,22 @@ package de.tum.cit.aet.artemis.lecture.repository; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.util.Optional; import jakarta.validation.constraints.NotNull; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.VideoUnit; /** * Spring Data JPA repository for the Video Unit entity. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Repository public interface VideoUnitRepository extends ArtemisJpaRepository { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/service/AttachmentService.java b/src/main/java/de/tum/cit/aet/artemis/lecture/service/AttachmentService.java index d45a4c26250a..ce426cbd17d9 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/service/AttachmentService.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/service/AttachmentService.java @@ -1,7 +1,5 @@ package de.tum.cit.aet.artemis.lecture.service; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; @@ -14,12 +12,13 @@ import org.apache.commons.io.FileUtils; import org.apache.pdfbox.Loader; import org.apache.pdfbox.pdmodel.PDDocument; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Service; import de.tum.cit.aet.artemis.core.exception.InternalServerErrorException; import de.tum.cit.aet.artemis.core.service.FilePathService; import de.tum.cit.aet.artemis.core.service.FileService; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Attachment; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; import de.tum.cit.aet.artemis.lecture.domain.Slide; @@ -27,7 +26,7 @@ import de.tum.cit.aet.artemis.lecture.repository.SlideRepository; @Service -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) public class AttachmentService { private final AttachmentRepository attachmentRepository; diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/service/AttachmentUnitService.java b/src/main/java/de/tum/cit/aet/artemis/lecture/service/AttachmentUnitService.java index 89f4c2a1f187..3773a185b760 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/service/AttachmentUnitService.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/service/AttachmentUnitService.java @@ -1,7 +1,5 @@ package de.tum.cit.aet.artemis.lecture.service; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.net.URI; import java.nio.file.Path; import java.time.ZonedDateTime; @@ -12,7 +10,7 @@ import java.util.Set; import org.apache.commons.io.FilenameUtils; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; @@ -22,13 +20,14 @@ import de.tum.cit.aet.artemis.core.service.FilePathService; import de.tum.cit.aet.artemis.core.service.FileService; import de.tum.cit.aet.artemis.iris.api.IrisLectureApi; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Attachment; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.repository.AttachmentRepository; import de.tum.cit.aet.artemis.lecture.repository.AttachmentUnitRepository; -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Service public class AttachmentUnitService { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/service/LectureImportService.java b/src/main/java/de/tum/cit/aet/artemis/lecture/service/LectureImportService.java index 042f30681855..10b66d52a136 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/service/LectureImportService.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/service/LectureImportService.java @@ -1,7 +1,5 @@ package de.tum.cit.aet.artemis.lecture.service; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.util.ArrayList; import java.util.HashSet; import java.util.Optional; @@ -9,18 +7,19 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import de.tum.cit.aet.artemis.communication.service.conversation.ChannelService; import de.tum.cit.aet.artemis.core.domain.Course; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Attachment; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.repository.AttachmentRepository; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Service public class LectureImportService { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/service/LectureService.java b/src/main/java/de/tum/cit/aet/artemis/lecture/service/LectureService.java index f400b677bb82..776ff0f40d6e 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/service/LectureService.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/service/LectureService.java @@ -1,7 +1,5 @@ package de.tum.cit.aet.artemis.lecture.service; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.HashSet; @@ -9,7 +7,7 @@ import java.util.Optional; import java.util.Set; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.data.domain.Page; import org.springframework.stereotype.Service; @@ -25,6 +23,7 @@ import de.tum.cit.aet.artemis.core.service.AuthorizationCheckService; import de.tum.cit.aet.artemis.core.util.PageUtil; import de.tum.cit.aet.artemis.iris.api.IrisLectureApi; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Attachment; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; import de.tum.cit.aet.artemis.lecture.domain.ExerciseUnit; @@ -34,7 +33,7 @@ import de.tum.cit.aet.artemis.lecture.domain.VideoUnit; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Service public class LectureService { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/service/LectureUnitImportService.java b/src/main/java/de/tum/cit/aet/artemis/lecture/service/LectureUnitImportService.java index 5b2c882c81d9..f5622358e7a9 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/service/LectureUnitImportService.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/service/LectureUnitImportService.java @@ -1,7 +1,5 @@ package de.tum.cit.aet.artemis.lecture.service; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.net.URI; import java.nio.file.Path; import java.util.ArrayList; @@ -10,12 +8,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Service; import de.tum.cit.aet.artemis.core.service.FilePathService; import de.tum.cit.aet.artemis.core.service.FileService; import de.tum.cit.aet.artemis.iris.api.IrisLectureApi; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Attachment; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; import de.tum.cit.aet.artemis.lecture.domain.ExerciseUnit; @@ -27,7 +26,7 @@ import de.tum.cit.aet.artemis.lecture.repository.AttachmentRepository; import de.tum.cit.aet.artemis.lecture.repository.LectureUnitRepository; -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Service public class LectureUnitImportService { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/service/LectureUnitProcessingService.java b/src/main/java/de/tum/cit/aet/artemis/lecture/service/LectureUnitProcessingService.java index 602106099847..75ac039d096e 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/service/LectureUnitProcessingService.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/service/LectureUnitProcessingService.java @@ -1,7 +1,5 @@ package de.tum.cit.aet.artemis.lecture.service; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.file.Path; @@ -24,13 +22,14 @@ import org.apache.pdfbox.text.PDFTextStripper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import de.tum.cit.aet.artemis.core.exception.InternalServerErrorException; import de.tum.cit.aet.artemis.core.service.FilePathService; import de.tum.cit.aet.artemis.core.service.FileService; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Attachment; import de.tum.cit.aet.artemis.lecture.domain.AttachmentType; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; @@ -39,7 +38,7 @@ import de.tum.cit.aet.artemis.lecture.dto.LectureUnitSplitInformationDTO; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Service public class LectureUnitProcessingService { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/service/LectureUnitService.java b/src/main/java/de/tum/cit/aet/artemis/lecture/service/LectureUnitService.java index 8a908bd8150b..4a42cb5e5651 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/service/LectureUnitService.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/service/LectureUnitService.java @@ -1,7 +1,5 @@ package de.tum.cit.aet.artemis.lecture.service; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; @@ -21,7 +19,7 @@ import org.hibernate.Hibernate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -36,6 +34,7 @@ import de.tum.cit.aet.artemis.core.service.FilePathService; import de.tum.cit.aet.artemis.core.service.FileService; import de.tum.cit.aet.artemis.iris.api.IrisLectureApi; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; import de.tum.cit.aet.artemis.lecture.domain.ExerciseUnit; import de.tum.cit.aet.artemis.lecture.domain.Lecture; @@ -45,7 +44,7 @@ import de.tum.cit.aet.artemis.lecture.repository.LectureUnitCompletionRepository; import de.tum.cit.aet.artemis.lecture.repository.LectureUnitRepository; -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Service public class LectureUnitService { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/service/SlideService.java b/src/main/java/de/tum/cit/aet/artemis/lecture/service/SlideService.java index 68e4f1c094fd..85940b48f548 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/service/SlideService.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/service/SlideService.java @@ -1,20 +1,19 @@ package de.tum.cit.aet.artemis.lecture.service; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.time.ZonedDateTime; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Service; import de.tum.cit.aet.artemis.exercise.domain.Exercise; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Slide; import de.tum.cit.aet.artemis.lecture.repository.SlideRepository; -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Service public class SlideService { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/service/SlideSplitterService.java b/src/main/java/de/tum/cit/aet/artemis/lecture/service/SlideSplitterService.java index 082dbb62730a..9563c06264e7 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/service/SlideSplitterService.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/service/SlideSplitterService.java @@ -1,7 +1,5 @@ package de.tum.cit.aet.artemis.lecture.service; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.io.File; @@ -25,7 +23,7 @@ import org.apache.pdfbox.rendering.PDFRenderer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; @@ -38,6 +36,7 @@ import de.tum.cit.aet.artemis.core.service.FileService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; import de.tum.cit.aet.artemis.lecture.domain.HiddenPageInfo; import de.tum.cit.aet.artemis.lecture.domain.HiddenPagesData; @@ -47,7 +46,7 @@ /** * Service Implementation for managing the split of AttachmentUnit into single slides and save them as PNG. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Service public class SlideSplitterService { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/service/SlideUnhideExecutionService.java b/src/main/java/de/tum/cit/aet/artemis/lecture/service/SlideUnhideExecutionService.java index 1ac3d055916b..3a38795bad43 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/service/SlideUnhideExecutionService.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/service/SlideUnhideExecutionService.java @@ -1,12 +1,11 @@ package de.tum.cit.aet.artemis.lecture.service; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Service; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Attachment; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; import de.tum.cit.aet.artemis.lecture.repository.SlideRepository; @@ -16,7 +15,7 @@ * This is used by both SlideUnhideService and SlideUnhideScheduleService * to avoid circular dependencies. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Service public class SlideUnhideExecutionService { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/service/SlideUnhideScheduleService.java b/src/main/java/de/tum/cit/aet/artemis/lecture/service/SlideUnhideScheduleService.java index e762a58268d4..1b9f13af1108 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/service/SlideUnhideScheduleService.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/service/SlideUnhideScheduleService.java @@ -12,11 +12,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Profile; import org.springframework.context.event.EventListener; import org.springframework.scheduling.TaskScheduler; import org.springframework.stereotype.Service; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.dto.SlideUnhideDTO; import de.tum.cit.aet.artemis.lecture.repository.SlideRepository; @@ -25,6 +27,7 @@ * This handles the actual scheduling of tasks. */ @Profile(PROFILE_CORE_AND_SCHEDULING) +@Conditional(LectureEnabled.class) @Service public class SlideUnhideScheduleService { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/service/SlideUnhideService.java b/src/main/java/de/tum/cit/aet/artemis/lecture/service/SlideUnhideService.java index b91bc4265995..3c4ea18f0143 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/service/SlideUnhideService.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/service/SlideUnhideService.java @@ -1,20 +1,19 @@ package de.tum.cit.aet.artemis.lecture.service; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Service; import de.tum.cit.aet.artemis.core.service.messaging.InstanceMessageSendService; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Slide; /** * Service for managing slide unhiding operations in a multi-node environment. * This service handles the messaging aspects. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @Service public class SlideUnhideService { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/web/AttachmentResource.java b/src/main/java/de/tum/cit/aet/artemis/lecture/web/AttachmentResource.java index cfc5a1c5a2b0..2f71b9cc7de5 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/web/AttachmentResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/web/AttachmentResource.java @@ -1,6 +1,5 @@ package de.tum.cit.aet.artemis.lecture.web; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; import static de.tum.cit.aet.artemis.core.service.FilePathService.actualPathForPublicPath; import java.net.URI; @@ -11,7 +10,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -36,6 +35,7 @@ import de.tum.cit.aet.artemis.core.service.FilePathService; import de.tum.cit.aet.artemis.core.service.FileService; import de.tum.cit.aet.artemis.core.util.HeaderUtil; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Attachment; import de.tum.cit.aet.artemis.lecture.domain.AttachmentType; import de.tum.cit.aet.artemis.lecture.repository.AttachmentRepository; @@ -44,7 +44,7 @@ /** * REST controller for managing Attachment. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @RestController @RequestMapping("api/lecture/") public class AttachmentResource { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/web/AttachmentUnitResource.java b/src/main/java/de/tum/cit/aet/artemis/lecture/web/AttachmentUnitResource.java index 9f43c5a0e94d..ba414a8706e4 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/web/AttachmentUnitResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/web/AttachmentUnitResource.java @@ -1,7 +1,5 @@ package de.tum.cit.aet.artemis.lecture.web; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; @@ -16,7 +14,7 @@ import org.apache.commons.io.FilenameUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -42,6 +40,7 @@ import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastEditor; import de.tum.cit.aet.artemis.core.service.AuthorizationCheckService; import de.tum.cit.aet.artemis.core.service.FileService; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Attachment; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; import de.tum.cit.aet.artemis.lecture.domain.Lecture; @@ -52,7 +51,7 @@ import de.tum.cit.aet.artemis.lecture.service.LectureUnitProcessingService; import de.tum.cit.aet.artemis.lecture.service.SlideSplitterService; -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @RestController @RequestMapping("api/lecture/") public class AttachmentUnitResource { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/web/ExerciseUnitResource.java b/src/main/java/de/tum/cit/aet/artemis/lecture/web/ExerciseUnitResource.java index 0cf23af1896c..04bf692a198e 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/web/ExerciseUnitResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/web/ExerciseUnitResource.java @@ -1,7 +1,5 @@ package de.tum.cit.aet.artemis.lecture.web; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.net.URI; import java.net.URISyntaxException; import java.util.List; @@ -10,7 +8,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -23,12 +21,13 @@ import de.tum.cit.aet.artemis.core.security.Role; import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastEditor; import de.tum.cit.aet.artemis.core.service.AuthorizationCheckService; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.ExerciseUnit; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.repository.ExerciseUnitRepository; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @RestController @RequestMapping("api/lecture/") public class ExerciseUnitResource { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/web/LectureResource.java b/src/main/java/de/tum/cit/aet/artemis/lecture/web/LectureResource.java index b122b623e5a1..62d331d31a53 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/web/LectureResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/web/LectureResource.java @@ -1,6 +1,5 @@ package de.tum.cit.aet.artemis.lecture.web; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_IRIS; import java.net.URI; @@ -19,6 +18,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Profile; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -55,6 +55,7 @@ import de.tum.cit.aet.artemis.core.util.HeaderUtil; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.service.ExerciseService; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Attachment; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; import de.tum.cit.aet.artemis.lecture.domain.ExerciseUnit; @@ -69,7 +70,7 @@ /** * REST controller for managing Lecture. */ -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @RestController @RequestMapping("api/lecture/") public class LectureResource { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/web/LectureTranscriptionResource.java b/src/main/java/de/tum/cit/aet/artemis/lecture/web/LectureTranscriptionResource.java index 2c627a75da84..5a11c11559de 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/web/LectureTranscriptionResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/web/LectureTranscriptionResource.java @@ -1,6 +1,5 @@ package de.tum.cit.aet.artemis.lecture.web; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_IRIS; import java.net.URI; @@ -12,6 +11,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Profile; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -31,6 +31,7 @@ import de.tum.cit.aet.artemis.core.security.annotations.ManualConfig; import de.tum.cit.aet.artemis.core.service.AuthorizationCheckService; import de.tum.cit.aet.artemis.core.util.HeaderUtil; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.domain.LectureTranscription; import de.tum.cit.aet.artemis.lecture.domain.LectureUnit; @@ -41,7 +42,7 @@ import de.tum.cit.aet.artemis.lecture.repository.LectureUnitRepository; import de.tum.cit.aet.artemis.lecture.service.LectureService; -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @RestController @RequestMapping("api/lecture/") public class LectureTranscriptionResource { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/web/LectureUnitResource.java b/src/main/java/de/tum/cit/aet/artemis/lecture/web/LectureUnitResource.java index b7f02fac45bd..ef0c8dc59f25 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/web/LectureUnitResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/web/LectureUnitResource.java @@ -1,7 +1,5 @@ package de.tum.cit.aet.artemis.lecture.web; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.util.Comparator; import java.util.List; import java.util.Optional; @@ -11,7 +9,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -35,6 +33,7 @@ import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastStudent; import de.tum.cit.aet.artemis.core.service.AuthorizationCheckService; import de.tum.cit.aet.artemis.core.util.HeaderUtil; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.domain.LectureUnit; import de.tum.cit.aet.artemis.lecture.dto.LectureUnitForLearningPathNodeDetailsDTO; @@ -42,7 +41,7 @@ import de.tum.cit.aet.artemis.lecture.repository.LectureUnitRepository; import de.tum.cit.aet.artemis.lecture.service.LectureUnitService; -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @RestController @RequestMapping("api/lecture/") public class LectureUnitResource { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/web/OnlineUnitResource.java b/src/main/java/de/tum/cit/aet/artemis/lecture/web/OnlineUnitResource.java index f535e1b71ba7..88ea17d22215 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/web/OnlineUnitResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/web/OnlineUnitResource.java @@ -1,7 +1,5 @@ package de.tum.cit.aet.artemis.lecture.web; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; @@ -15,7 +13,7 @@ import org.jsoup.nodes.Element; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -35,13 +33,14 @@ import de.tum.cit.aet.artemis.core.security.Role; import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastEditor; import de.tum.cit.aet.artemis.core.service.AuthorizationCheckService; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.domain.OnlineUnit; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; import de.tum.cit.aet.artemis.lecture.repository.OnlineUnitRepository; import de.tum.cit.aet.artemis.lecture.service.LectureUnitService; -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @RestController @RequestMapping("api/lecture/") public class OnlineUnitResource { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/web/TextUnitResource.java b/src/main/java/de/tum/cit/aet/artemis/lecture/web/TextUnitResource.java index 6d8db7b1d650..3f087df3a14b 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/web/TextUnitResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/web/TextUnitResource.java @@ -1,14 +1,12 @@ package de.tum.cit.aet.artemis.lecture.web; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.net.URI; import java.net.URISyntaxException; import java.util.Optional; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -24,13 +22,14 @@ import de.tum.cit.aet.artemis.core.security.Role; import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastEditor; import de.tum.cit.aet.artemis.core.service.AuthorizationCheckService; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.domain.TextUnit; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; import de.tum.cit.aet.artemis.lecture.repository.TextUnitRepository; import de.tum.cit.aet.artemis.lecture.service.LectureUnitService; -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @RestController @RequestMapping("api/lecture/") public class TextUnitResource { diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/web/VideoUnitResource.java b/src/main/java/de/tum/cit/aet/artemis/lecture/web/VideoUnitResource.java index 9396082718f3..18b5f23528b9 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/web/VideoUnitResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/web/VideoUnitResource.java @@ -1,7 +1,5 @@ package de.tum.cit.aet.artemis.lecture.web; -import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; - import java.net.URI; import java.net.URISyntaxException; import java.util.Optional; @@ -10,7 +8,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.Conditional; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -25,13 +23,14 @@ import de.tum.cit.aet.artemis.core.security.Role; import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastEditor; import de.tum.cit.aet.artemis.core.service.AuthorizationCheckService; +import de.tum.cit.aet.artemis.lecture.config.LectureEnabled; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.domain.VideoUnit; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; import de.tum.cit.aet.artemis.lecture.repository.VideoUnitRepository; import de.tum.cit.aet.artemis.lecture.service.LectureUnitService; -@Profile(PROFILE_CORE) +@Conditional(LectureEnabled.class) @RestController @RequestMapping("api/lecture/") public class VideoUnitResource { diff --git a/src/main/resources/config/application-buildagent.yml b/src/main/resources/config/application-buildagent.yml index 1d34a4bab56f..ff77cceb8e15 100644 --- a/src/main/resources/config/application-buildagent.yml +++ b/src/main/resources/config/application-buildagent.yml @@ -10,6 +10,8 @@ artemis: atlas: enabled: false + lecture: + enabled: false exam: enabled: false plagiarism: diff --git a/src/main/resources/config/application-core.yml b/src/main/resources/config/application-core.yml index 0e8cdaf74c3d..b87fd8f6e3d9 100644 --- a/src/main/resources/config/application-core.yml +++ b/src/main/resources/config/application-core.yml @@ -3,6 +3,8 @@ artemis: enabled: true exam: enabled: true + lecture: + enabled: true plagiarism: enabled: true text: diff --git a/src/main/webapp/app/app.constants.ts b/src/main/webapp/app/app.constants.ts index d464da065a50..5b801ee2363d 100644 --- a/src/main/webapp/app/app.constants.ts +++ b/src/main/webapp/app/app.constants.ts @@ -43,6 +43,8 @@ export const MODULE_FEATURE_ATLAS = 'atlas'; export const MODULE_FEATURE_EXAM = 'exam'; +export const MODULE_FEATURE_LECTURE = 'lecture'; + export const MODULE_FEATURE_PLAGIARISM = 'plagiarism'; export const MODULE_FEATURE_TEXT = 'text'; diff --git a/src/main/webapp/app/core/course/manage/course-management-container/course-management-container.component.spec.ts b/src/main/webapp/app/core/course/manage/course-management-container/course-management-container.component.spec.ts index 5bdb1f39af82..89470edbb179 100644 --- a/src/main/webapp/app/core/course/manage/course-management-container/course-management-container.component.spec.ts +++ b/src/main/webapp/app/core/course/manage/course-management-container/course-management-container.component.spec.ts @@ -41,7 +41,7 @@ import { ProfileInfo } from 'app/core/layouts/profiles/profile-info.model'; import { ProgrammingExercise } from 'app/programming/shared/entities/programming-exercise.model'; import { TextExercise } from 'app/text/shared/entities/text-exercise.model'; -import { MODULE_FEATURE_ATLAS, PROFILE_IRIS, PROFILE_LTI, PROFILE_PROD } from 'app/app.constants'; +import { MODULE_FEATURE_ATLAS, MODULE_FEATURE_LECTURE, PROFILE_IRIS, PROFILE_LTI, PROFILE_PROD } from 'app/app.constants'; import { MockFeatureToggleService } from 'test/helpers/mocks/service/mock-feature-toggle.service'; import { MockMetisConversationService } from 'test/helpers/mocks/service/mock-metis-conversation.service'; import { CourseConversationsComponent } from 'app/communication/shared/course-conversations/course-conversations.component'; @@ -268,7 +268,7 @@ describe('CourseManagementContainerComponent', () => { deleteSpy = jest.spyOn(courseAdminService, 'delete').mockReturnValue(of(new HttpResponse())); jest.spyOn(profileService, 'getProfileInfo').mockReturnValue({ - activeModuleFeatures: [MODULE_FEATURE_ATLAS], + activeModuleFeatures: [MODULE_FEATURE_ATLAS, MODULE_FEATURE_LECTURE], activeProfiles: [PROFILE_IRIS, PROFILE_LTI, PROFILE_PROD], } as unknown as ProfileInfo); diff --git a/src/main/webapp/app/core/course/manage/course-management-container/course-management-container.component.ts b/src/main/webapp/app/core/course/manage/course-management-container/course-management-container.component.ts index 1d3f38381a3f..ec9f715f0a19 100644 --- a/src/main/webapp/app/core/course/manage/course-management-container/course-management-container.component.ts +++ b/src/main/webapp/app/core/course/manage/course-management-container/course-management-container.component.ts @@ -52,6 +52,7 @@ import { CourseConversationsComponent } from 'app/communication/shared/course-co import { ButtonSize } from 'app/shared/components/button/button.component'; import { Course, isCommunicationEnabled } from 'app/core/course/shared/entities/course.model'; import { CourseDeletionSummaryDTO } from 'app/core/course/shared/entities/course-deletion-summary.model'; +import { MODULE_FEATURE_LECTURE } from 'app/app.constants'; @Component({ selector: 'jhi-course-management-container', @@ -279,7 +280,7 @@ export class CourseManagementContainerComponent extends BaseCourseContainerCompo sidebarItems.push(...this.sidebarItemService.getManagementDefaultItems(this.courseId())); - if (currentCourse.isAtLeastEditor) { + if (this.profileService.isModuleFeatureActive(MODULE_FEATURE_LECTURE) && currentCourse.isAtLeastEditor) { sidebarItems.splice(3, 0, this.sidebarItemService.getLecturesItem(this.courseId())); } const nonInstructorItems: SidebarItem[] = []; diff --git a/src/main/webapp/app/core/course/manage/course-management-tab-bar/course-management-tab-bar.component.html b/src/main/webapp/app/core/course/manage/course-management-tab-bar/course-management-tab-bar.component.html index 9b150015bda0..5f082b40419c 100644 --- a/src/main/webapp/app/core/course/manage/course-management-tab-bar/course-management-tab-bar.component.html +++ b/src/main/webapp/app/core/course/manage/course-management-tab-bar/course-management-tab-bar.component.html @@ -13,10 +13,12 @@ @if (course.isAtLeastEditor) { - - - - + + + + + + } diff --git a/src/main/webapp/app/core/course/manage/course-management-tab-bar/course-management-tab-bar.component.ts b/src/main/webapp/app/core/course/manage/course-management-tab-bar/course-management-tab-bar.component.ts index 707f157abaea..8c6addeb1611 100644 --- a/src/main/webapp/app/core/course/manage/course-management-tab-bar/course-management-tab-bar.component.ts +++ b/src/main/webapp/app/core/course/manage/course-management-tab-bar/course-management-tab-bar.component.ts @@ -31,7 +31,7 @@ import { import { FeatureToggle } from 'app/shared/feature-toggle/feature-toggle.service'; import { CourseAdminService } from 'app/core/course/manage/services/course-admin.service'; import { ProfileService } from 'app/core/layouts/profiles/shared/profile.service'; -import { MODULE_FEATURE_ATLAS, MODULE_FEATURE_EXAM, MODULE_FEATURE_TUTORIALGROUP, PROFILE_IRIS, PROFILE_LOCALCI, PROFILE_LTI } from 'app/app.constants'; +import { MODULE_FEATURE_ATLAS, MODULE_FEATURE_EXAM, MODULE_FEATURE_LECTURE, MODULE_FEATURE_TUTORIALGROUP, PROFILE_IRIS, PROFILE_LOCALCI, PROFILE_LTI } from 'app/app.constants'; import { scrollToTopOfPage } from 'app/shared/util/utils'; import { ExerciseType } from 'app/exercise/shared/entities/exercise/exercise.model'; import { EntitySummary } from 'app/shared/delete-dialog/delete-dialog.model'; @@ -114,6 +114,7 @@ export class CourseManagementTabBarComponent implements OnInit, OnDestroy, After tutorialGroupEnabled = false; irisEnabled = false; ltiEnabled = false; + lectureEnabled = false; /** * On init load the course information and subscribe to listen for changes in course. @@ -132,6 +133,7 @@ export class CourseManagementTabBarComponent implements OnInit, OnDestroy, After this.atlasEnabled = this.profileService.isModuleFeatureActive(MODULE_FEATURE_ATLAS); this.examEnabled = this.profileService.isModuleFeatureActive(MODULE_FEATURE_EXAM); + this.lectureEnabled = this.profileService.isModuleFeatureActive(MODULE_FEATURE_LECTURE); this.tutorialGroupEnabled = this.profileService.isModuleFeatureActive(MODULE_FEATURE_TUTORIALGROUP); this.irisEnabled = this.profileService.isProfileActive(PROFILE_IRIS); this.ltiEnabled = this.profileService.isProfileActive(PROFILE_LTI); diff --git a/src/main/webapp/app/core/course/manage/overview/course-management-card.component.html b/src/main/webapp/app/core/course/manage/overview/course-management-card.component.html index 3b125bf6ed8d..be1fcfedcf76 100644 --- a/src/main/webapp/app/core/course/manage/overview/course-management-card.component.html +++ b/src/main/webapp/app/core/course/manage/overview/course-management-card.component.html @@ -249,15 +249,17 @@

- - - + + + + + + } @if (course.isAtLeastTutor) { (); @@ -124,6 +125,7 @@ export class CourseManagementCardComponent implements OnInit, OnChanges { ngOnInit() { this.atlasEnabled = this.profileService.isModuleFeatureActive(MODULE_FEATURE_ATLAS); this.examEnabled = this.profileService.isModuleFeatureActive(MODULE_FEATURE_EXAM); + this.lectureEnabled = this.profileService.isModuleFeatureActive(MODULE_FEATURE_LECTURE); this.tutorialGroupEnabled = this.profileService.isModuleFeatureActive(MODULE_FEATURE_TUTORIALGROUP); } diff --git a/src/main/webapp/app/core/course/overview/course-overview/course-overview.component.spec.ts b/src/main/webapp/app/core/course/overview/course-overview/course-overview.component.spec.ts index 32d3c782953b..7ac8e15eb19a 100644 --- a/src/main/webapp/app/core/course/overview/course-overview/course-overview.component.spec.ts +++ b/src/main/webapp/app/core/course/overview/course-overview/course-overview.component.spec.ts @@ -34,7 +34,7 @@ import { DueDateStat } from 'app/assessment/shared/assessment-dashboard/due-date import { CourseExercisesComponent } from 'app/core/course/overview/course-exercises/course-exercises.component'; import { CourseRegistrationComponent } from 'app/core/course/overview/course-registration/course-registration.component'; import { ProfileInfo } from 'app/core/layouts/profiles/profile-info.model'; -import { MODULE_FEATURE_ATLAS, PROFILE_IRIS, PROFILE_LTI, PROFILE_PROD } from 'app/app.constants'; +import { MODULE_FEATURE_ATLAS, MODULE_FEATURE_LECTURE, PROFILE_IRIS, PROFILE_LTI, PROFILE_PROD } from 'app/app.constants'; import { Course, CourseInformationSharingConfiguration } from 'app/core/course/shared/entities/course.model'; import { CourseOverviewComponent } from 'app/core/course/overview/course-overview/course-overview.component'; import { CourseManagementService } from 'app/core/course/manage/services/course-management.service'; @@ -243,7 +243,7 @@ describe('CourseOverviewComponent', () => { .spyOn(courseService, 'findAllForDropdown') .mockReturnValue(of(new HttpResponse({ body: coursesDropdown, headers: new HttpHeaders() }))); jest.spyOn(profileService, 'getProfileInfo').mockReturnValue({ - activeModuleFeatures: [MODULE_FEATURE_ATLAS], + activeModuleFeatures: [MODULE_FEATURE_ATLAS, MODULE_FEATURE_LECTURE], activeProfiles: [PROFILE_IRIS, PROFILE_LTI, PROFILE_PROD], testServer: false, } as unknown as ProfileInfo); diff --git a/src/main/webapp/app/core/course/overview/course-overview/course-overview.component.ts b/src/main/webapp/app/core/course/overview/course-overview/course-overview.component.ts index fcfa762c8671..f7134334a038 100644 --- a/src/main/webapp/app/core/course/overview/course-overview/course-overview.component.ts +++ b/src/main/webapp/app/core/course/overview/course-overview/course-overview.component.ts @@ -31,6 +31,7 @@ import { CourseTutorialGroupsComponent } from 'app/tutorialgroup/shared/course-t import { CourseConversationsComponent } from 'app/communication/shared/course-conversations/course-conversations.component'; import { Course, isCommunicationEnabled } from 'app/core/course/shared/entities/course.model'; import { CourseUnenrollmentModalComponent } from 'app/core/course/overview/course-unenrollment-modal/course-unenrollment-modal.component'; +import { MODULE_FEATURE_LECTURE } from 'app/app.constants'; @Component({ selector: 'jhi-course-overview', @@ -237,7 +238,7 @@ export class CourseOverviewComponent extends BaseCourseContainerComponent implem const defaultItems = this.sidebarItemService.getStudentDefaultItems(currentCourse?.studentCourseAnalyticsDashboardEnabled); sidebarItems.push(...defaultItems); - if (currentCourse?.lectures) { + if (this.profileService.isModuleFeatureActive(MODULE_FEATURE_LECTURE) && currentCourse?.lectures) { const lecturesItem = this.sidebarItemService.getLecturesItem(); sidebarItems.splice(-1, 0, lecturesItem); } diff --git a/src/test/java/de/tum/cit/aet/artemis/core/config/ModuleFeatureInfoContributorTest.java b/src/test/java/de/tum/cit/aet/artemis/core/config/ModuleFeatureInfoContributorTest.java index 1331d9c10abd..568b7569f96b 100644 --- a/src/test/java/de/tum/cit/aet/artemis/core/config/ModuleFeatureInfoContributorTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/config/ModuleFeatureInfoContributorTest.java @@ -22,6 +22,7 @@ class ModuleFeatureInfoContributorTest { private static final List modulePropertyNames = List.of( Constants.ATLAS_ENABLED_PROPERTY_NAME, Constants.EXAM_ENABLED_PROPERTY_NAME, + Constants.LECTURE_ENABLED_PROPERTY_NAME, Constants.PLAGIARISM_ENABLED_PROPERTY_NAME, Constants.TEXT_ENABLED_PROPERTY_NAME, Constants.TUTORIAL_GROUP_ENABLED_PROPERTY_NAME, @@ -33,6 +34,7 @@ class ModuleFeatureInfoContributorTest { private static final List moduleFeatures = List.of( Constants.MODULE_FEATURE_ATLAS, Constants.MODULE_FEATURE_EXAM, + Constants.MODULE_FEATURE_LECTURE, Constants.MODULE_FEATURE_PLAGIARISM, Constants.MODULE_FEATURE_TEXT, Constants.MODULE_FEATURE_TUTORIALGROUP, diff --git a/src/test/java/de/tum/cit/aet/artemis/core/config/modules/ArtemisConfigHelperTest.java b/src/test/java/de/tum/cit/aet/artemis/core/config/modules/ArtemisConfigHelperTest.java index 2d6bde15e5e0..124a0bafd11f 100644 --- a/src/test/java/de/tum/cit/aet/artemis/core/config/modules/ArtemisConfigHelperTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/config/modules/ArtemisConfigHelperTest.java @@ -32,6 +32,11 @@ void testExamProperty() { testProperty(artemisConfigHelper::isExamEnabled, Constants.EXAM_ENABLED_PROPERTY_NAME); } + @Test + void testLectureProperty() { + testProperty(artemisConfigHelper::isLectureEnabled, Constants.LECTURE_ENABLED_PROPERTY_NAME); + } + @Test void testPlagiarismProperty() { testProperty(artemisConfigHelper::isPlagiarismEnabled, Constants.PLAGIARISM_ENABLED_PROPERTY_NAME);