From 41cf988e11a1b9ba7f9ef92bc055576db1e1ee99 Mon Sep 17 00:00:00 2001 From: Ole Vester Date: Tue, 12 Nov 2024 11:10:07 +0100 Subject: [PATCH 01/11] Add Abstract Api interface --- .../java/de/tum/cit/aet/artemis/core/api/AbstractApi.java | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/main/java/de/tum/cit/aet/artemis/core/api/AbstractApi.java diff --git a/src/main/java/de/tum/cit/aet/artemis/core/api/AbstractApi.java b/src/main/java/de/tum/cit/aet/artemis/core/api/AbstractApi.java new file mode 100644 index 000000000000..8ca26f995aa0 --- /dev/null +++ b/src/main/java/de/tum/cit/aet/artemis/core/api/AbstractApi.java @@ -0,0 +1,4 @@ +package de.tum.cit.aet.artemis.core.api; + +public interface AbstractApi { +} From 1705315d2576e41967e522b28676b273926b5256 Mon Sep 17 00:00:00 2001 From: Ole Vester Date: Tue, 12 Nov 2024 11:10:31 +0100 Subject: [PATCH 02/11] Add Atlas abstract api --- .../de/tum/cit/aet/artemis/atlas/api/AbstractAtlasApi.java | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/main/java/de/tum/cit/aet/artemis/atlas/api/AbstractAtlasApi.java diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/api/AbstractAtlasApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/AbstractAtlasApi.java new file mode 100644 index 000000000000..41481096ac68 --- /dev/null +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/AbstractAtlasApi.java @@ -0,0 +1,6 @@ +package de.tum.cit.aet.artemis.atlas.api; + +import de.tum.cit.aet.artemis.core.api.AbstractApi; + +public abstract class AbstractAtlasApi implements AbstractApi { +} From 2be73971b48cab02353f3b3fd63d6d9eb356284b Mon Sep 17 00:00:00 2001 From: Ole Vester Date: Tue, 12 Nov 2024 11:11:28 +0100 Subject: [PATCH 03/11] Add atlas apis --- .../atlas/api/CompetencyMetricsApi.java | 45 ++++++++++++ .../atlas/api/CompetencyProgressApi.java | 72 +++++++++++++++++++ .../atlas/api/CompetencyRelationApi.java | 52 ++++++++++++++ .../atlas/api/CourseCompetencyApi.java | 20 ++++++ .../artemis/atlas/api/LearningPathApi.java | 27 +++++++ .../artemis/atlas/api/PrerequisitesApi.java | 25 +++++++ .../artemis/atlas/api/ScienceEventApi.java | 26 +++++++ 7 files changed, 267 insertions(+) create mode 100644 src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyMetricsApi.java create mode 100644 src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java create mode 100644 src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyRelationApi.java create mode 100644 src/main/java/de/tum/cit/aet/artemis/atlas/api/CourseCompetencyApi.java create mode 100644 src/main/java/de/tum/cit/aet/artemis/atlas/api/LearningPathApi.java create mode 100644 src/main/java/de/tum/cit/aet/artemis/atlas/api/PrerequisitesApi.java create mode 100644 src/main/java/de/tum/cit/aet/artemis/atlas/api/ScienceEventApi.java diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyMetricsApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyMetricsApi.java new file mode 100644 index 000000000000..c01ebecf0882 --- /dev/null +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyMetricsApi.java @@ -0,0 +1,45 @@ +package de.tum.cit.aet.artemis.atlas.api; + +import java.util.Set; + +import org.springframework.stereotype.Controller; + +import de.tum.cit.aet.artemis.atlas.dto.CompetencyJolDTO; +import de.tum.cit.aet.artemis.atlas.dto.metrics.CompetencyInformationDTO; +import de.tum.cit.aet.artemis.atlas.dto.metrics.CompetencyProgressDTO; +import de.tum.cit.aet.artemis.atlas.dto.metrics.MapEntryLongLong; +import de.tum.cit.aet.artemis.atlas.repository.CompetencyMetricsRepository; + +@Controller +public class CompetencyMetricsApi extends AbstractAtlasApi { + + private final CompetencyMetricsRepository competencyMetricsRepository; + + public CompetencyMetricsApi(CompetencyMetricsRepository competencyMetricsRepository) { + this.competencyMetricsRepository = competencyMetricsRepository; + } + + public Set findAllCompetencyInformationByCourseId(long courseId) { + return competencyMetricsRepository.findAllCompetencyInformationByCourseId(courseId); + } + + public Set findAllExerciseIdsByCompetencyIds(Set competencyIds) { + return competencyMetricsRepository.findAllExerciseIdsByCompetencyIds(competencyIds); + } + + public Set findAllLectureUnitIdsByCompetencyIds(Set competencyIds) { + return competencyMetricsRepository.findAllLectureUnitIdsByCompetencyIds(competencyIds); + } + + public Set findAllCompetencyProgressForUserByCompetencyIds(long userId, Set competencyIds) { + return competencyMetricsRepository.findAllCompetencyProgressForUserByCompetencyIds(userId, competencyIds); + } + + public Set findAllLatestCompetencyJolValuesForUserByCompetencyIds(long userId, Set competencyIds) { + return competencyMetricsRepository.findAllLatestCompetencyJolValuesForUserByCompetencyIds(userId, competencyIds); + } + + public Set findAllLatestCompetencyJolValuesForUserByCompetencyIdsExcludeJolIds(long userId, Set competencyIds, Set jolIdsToExclude) { + return competencyMetricsRepository.findAllLatestCompetencyJolValuesForUserByCompetencyIdsExcludeJolIds(userId, competencyIds, jolIdsToExclude); + } +} diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java new file mode 100644 index 000000000000..9d04bb3fc055 --- /dev/null +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java @@ -0,0 +1,72 @@ +package de.tum.cit.aet.artemis.atlas.api; + +import java.util.List; +import java.util.Optional; +import java.util.Set; + +import jakarta.validation.constraints.NotNull; + +import org.springframework.stereotype.Controller; + +import de.tum.cit.aet.artemis.atlas.domain.LearningObject; +import de.tum.cit.aet.artemis.atlas.domain.competency.Competency; +import de.tum.cit.aet.artemis.atlas.domain.competency.CourseCompetency; +import de.tum.cit.aet.artemis.atlas.repository.CompetencyRepository; +import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; +import de.tum.cit.aet.artemis.core.domain.Course; +import de.tum.cit.aet.artemis.core.domain.User; +import de.tum.cit.aet.artemis.exercise.domain.participation.Participant; + +@Controller +public class CompetencyProgressApi extends AbstractAtlasApi { + + private final CompetencyProgressService competencyProgressService; + + private final CompetencyRepository competencyRepository; + + public CompetencyProgressApi(CompetencyProgressService competencyProgressService, CompetencyRepository competencyRepository) { + this.competencyProgressService = competencyProgressService; + this.competencyRepository = competencyRepository; + } + + public void updateProgressByLearningObjectForParticipantAsync(LearningObject learningObject, @NotNull Participant participant) { + competencyProgressService.updateProgressByLearningObjectForParticipantAsync(learningObject, participant); + } + + public void updateProgressByLearningObjectAsync(LearningObject learningObject) { + competencyProgressService.updateProgressByLearningObjectAsync(learningObject); + } + + public void updateProgressByCompetencyAsync(CourseCompetency competency) { + competencyProgressService.updateProgressByCompetencyAsync(competency); + } + + public void updateProgressForUpdatedLearningObjectAsync(LearningObject originalLearningObject, Optional updatedLearningObject) { + competencyProgressService.updateProgressForUpdatedLearningObjectAsync(originalLearningObject, updatedLearningObject); + } + + public void updateProgressByLearningObjectSync(LearningObject learningObject, Set users) { + competencyProgressService.updateProgressByLearningObjectSync(learningObject, users); + } + + public long countByCourse(Course course) { + return competencyRepository.countByCourse(course); + } + + public void deleteAll(Set competencies) { + competencyRepository.deleteAll(competencies); + } + + /** + * Updates the progress for all competencies of the given courses. + * + * @param activeCourses the active courses + */ + public void updateProgressForCourses(List activeCourses) { + activeCourses.forEach(course -> { + List competencies = competencyRepository.findByCourseIdOrderById(course.getId()); + // Asynchronously update the progress for each competency + competencies.forEach(competencyProgressService::updateProgressByCompetencyAsync); + }); + } +} diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyRelationApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyRelationApi.java new file mode 100644 index 000000000000..f34d3bd0d6c1 --- /dev/null +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyRelationApi.java @@ -0,0 +1,52 @@ +package de.tum.cit.aet.artemis.atlas.api; + +import java.util.List; + +import org.springframework.stereotype.Controller; + +import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyExerciseLink; +import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyLectureUnitLink; +import de.tum.cit.aet.artemis.atlas.repository.CompetencyExerciseLinkRepository; +import de.tum.cit.aet.artemis.atlas.repository.CompetencyLectureUnitLinkRepository; +import de.tum.cit.aet.artemis.atlas.repository.CompetencyRelationRepository; + +@Controller +public class CompetencyRelationApi extends AbstractAtlasApi { + + private final CompetencyRelationRepository competencyRelationRepository; + + private final CompetencyExerciseLinkRepository competencyExerciseLinkRepository; + + private final CompetencyLectureUnitLinkRepository lectureUnitLinkRepository; + + public CompetencyRelationApi(CompetencyRelationRepository competencyRelationRepository, CompetencyExerciseLinkRepository competencyExerciseLinkRepository, + CompetencyLectureUnitLinkRepository lectureUnitLinkRepository) { + this.competencyRelationRepository = competencyRelationRepository; + this.competencyExerciseLinkRepository = competencyExerciseLinkRepository; + this.lectureUnitLinkRepository = lectureUnitLinkRepository; + } + + public void deleteAllByCourseId(Long courseId) { + competencyRelationRepository.deleteAllByCourseId(courseId); + } + + public void deleteAllExerciseLinks(Iterable competencyExerciseLinks) { + competencyExerciseLinkRepository.deleteAll(competencyExerciseLinks); + } + + public List saveAllExerciseLinks(Iterable competencyExerciseLinks) { + return competencyExerciseLinkRepository.saveAll(competencyExerciseLinks); + } + + public List saveAllLectureUnitLinks(Iterable lectureUnitLinks) { + return lectureUnitLinkRepository.saveAll(lectureUnitLinks); + } + + public void deleteAllLectureUnitLinks(Iterable lectureUnitLinks) { + lectureUnitLinkRepository.deleteAll(lectureUnitLinks); + } + + public void deleteAllLectureUnitLinksByLectureId(Long lectureId) { + lectureUnitLinkRepository.deleteAllByLectureId(lectureId); + } +} diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/api/CourseCompetencyApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CourseCompetencyApi.java new file mode 100644 index 000000000000..74bbbe6b8113 --- /dev/null +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CourseCompetencyApi.java @@ -0,0 +1,20 @@ +package de.tum.cit.aet.artemis.atlas.api; + +import org.springframework.stereotype.Controller; + +import de.tum.cit.aet.artemis.atlas.domain.competency.CourseCompetency; +import de.tum.cit.aet.artemis.atlas.repository.CourseCompetencyRepository; + +@Controller +public class CourseCompetencyApi extends AbstractAtlasApi { + + private final CourseCompetencyRepository courseCompetencyRepository; + + public CourseCompetencyApi(CourseCompetencyRepository courseCompetencyRepository) { + this.courseCompetencyRepository = courseCompetencyRepository; + } + + public void save(CourseCompetency courseCompetency) { + courseCompetencyRepository.save(courseCompetency); + } +} diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/api/LearningPathApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/LearningPathApi.java new file mode 100644 index 000000000000..3a876a0a373d --- /dev/null +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/LearningPathApi.java @@ -0,0 +1,27 @@ +package de.tum.cit.aet.artemis.atlas.api; + +import jakarta.validation.constraints.NotNull; + +import org.springframework.stereotype.Controller; + +import de.tum.cit.aet.artemis.atlas.service.learningpath.LearningPathService; +import de.tum.cit.aet.artemis.core.domain.Course; +import de.tum.cit.aet.artemis.core.domain.User; + +@Controller +public class LearningPathApi extends AbstractAtlasApi { + + private final LearningPathService learningPathService; + + public LearningPathApi(LearningPathService learningPathService) { + this.learningPathService = learningPathService; + } + + public void generateLearningPathForUser(@NotNull Course course, @NotNull User user) { + learningPathService.generateLearningPathForUser(course, user); + } + + public void generateLearningPaths(@NotNull Course course) { + learningPathService.generateLearningPaths(course); + } +} diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/api/PrerequisitesApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/PrerequisitesApi.java new file mode 100644 index 000000000000..83e67be2f7b4 --- /dev/null +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/PrerequisitesApi.java @@ -0,0 +1,25 @@ +package de.tum.cit.aet.artemis.atlas.api; + +import org.springframework.stereotype.Controller; + +import de.tum.cit.aet.artemis.atlas.domain.competency.Prerequisite; +import de.tum.cit.aet.artemis.atlas.repository.PrerequisiteRepository; +import de.tum.cit.aet.artemis.core.domain.Course; + +@Controller +public class PrerequisitesApi extends AbstractAtlasApi { + + private final PrerequisiteRepository prerequisiteRepository; + + public PrerequisitesApi(PrerequisiteRepository prerequisiteRepository) { + this.prerequisiteRepository = prerequisiteRepository; + } + + public long countByCourse(Course course) { + return prerequisiteRepository.countByCourse(course); + } + + public void deleteAll(Iterable prerequisites) { + prerequisiteRepository.deleteAll(prerequisites); + } +} diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/api/ScienceEventApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/ScienceEventApi.java new file mode 100644 index 000000000000..a77d450c0bd2 --- /dev/null +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/ScienceEventApi.java @@ -0,0 +1,26 @@ +package de.tum.cit.aet.artemis.atlas.api; + +import java.util.Set; + +import org.springframework.stereotype.Controller; + +import de.tum.cit.aet.artemis.atlas.domain.science.ScienceEvent; +import de.tum.cit.aet.artemis.atlas.repository.ScienceEventRepository; + +@Controller +public class ScienceEventApi extends AbstractAtlasApi { + + private final ScienceEventRepository scienceEventRepository; + + public ScienceEventApi(ScienceEventRepository scienceEventRepository) { + this.scienceEventRepository = scienceEventRepository; + } + + public Set findAllByIdentity(String login) { + return scienceEventRepository.findAllByIdentity(login); + } + + public void renameIdentity(String oldIdentity, String newIdentity) { + scienceEventRepository.renameIdentity(oldIdentity, newIdentity); + } +} From 21fd75591707a0644dc6481a7782b78ef9733aac Mon Sep 17 00:00:00 2001 From: Ole Vester Date: Tue, 12 Nov 2024 11:11:47 +0100 Subject: [PATCH 04/11] Use atlas apis in server prod code --- .../ParticipantScoreScheduleService.java | 10 ++-- .../MigrationEntry20240614_140000.java | 20 ++------ .../artemis/core/service/CourseService.java | 46 +++++++++---------- .../export/DataExportScienceEventService.java | 10 ++-- .../core/service/user/UserService.java | 10 ++-- .../aet/artemis/core/web/CourseResource.java | 12 ++--- .../service/ExerciseDeletionService.java | 15 ++---- .../exercise/service/ExerciseService.java | 12 ++--- .../service/LearningMetricsService.java | 20 ++++---- .../service/ParticipationService.java | 10 ++-- .../FileUploadExerciseImportService.java | 12 ++--- .../web/FileUploadExerciseResource.java | 12 ++--- .../service/AttachmentUnitService.java | 6 +-- .../lecture/service/LectureService.java | 19 ++++---- .../lecture/service/LectureUnitService.java | 30 ++++++------ .../lecture/web/AttachmentUnitResource.java | 12 ++--- .../lecture/web/LectureUnitResource.java | 10 ++-- .../lecture/web/OnlineUnitResource.java | 12 ++--- .../artemis/lecture/web/TextUnitResource.java | 12 ++--- .../lecture/web/VideoUnitResource.java | 12 ++--- .../ModelingExerciseImportService.java | 10 ++-- .../web/ModelingExerciseResource.java | 12 ++--- .../service/ProgrammingExerciseService.java | 12 ++--- ...ogrammingExerciseExportImportResource.java | 10 ++-- .../service/QuizExerciseImportService.java | 10 ++-- .../quiz/service/QuizExerciseService.java | 6 +-- .../quiz/web/QuizExerciseResource.java | 12 ++--- .../service/TextExerciseImportService.java | 10 ++-- .../text/web/TextExerciseResource.java | 14 +++--- 29 files changed, 189 insertions(+), 209 deletions(-) diff --git a/src/main/java/de/tum/cit/aet/artemis/assessment/service/ParticipantScoreScheduleService.java b/src/main/java/de/tum/cit/aet/artemis/assessment/service/ParticipantScoreScheduleService.java index fffd4957b5b2..a3b7521668f4 100644 --- a/src/main/java/de/tum/cit/aet/artemis/assessment/service/ParticipantScoreScheduleService.java +++ b/src/main/java/de/tum/cit/aet/artemis/assessment/service/ParticipantScoreScheduleService.java @@ -37,7 +37,7 @@ import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; import de.tum.cit.aet.artemis.assessment.repository.StudentScoreRepository; import de.tum.cit.aet.artemis.assessment.repository.TeamScoreRepository; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.repository.UserRepository; import de.tum.cit.aet.artemis.core.security.SecurityUtils; @@ -74,7 +74,7 @@ public class ParticipantScoreScheduleService { private Optional lastScheduledRun = Optional.empty(); - private final CompetencyProgressService competencyProgressService; + private final CompetencyProgressApi competencyProgressApi; private final ParticipantScoreRepository participantScoreRepository; @@ -96,11 +96,11 @@ public class ParticipantScoreScheduleService { */ private final AtomicBoolean isRunning = new AtomicBoolean(false); - public ParticipantScoreScheduleService(@Qualifier("taskScheduler") TaskScheduler scheduler, CompetencyProgressService competencyProgressService, + public ParticipantScoreScheduleService(@Qualifier("taskScheduler") TaskScheduler scheduler, CompetencyProgressApi competencyProgressApi, ParticipantScoreRepository participantScoreRepository, StudentScoreRepository studentScoreRepository, TeamScoreRepository teamScoreRepository, ExerciseRepository exerciseRepository, ResultRepository resultRepository, UserRepository userRepository, TeamRepository teamRepository) { this.scheduler = scheduler; - this.competencyProgressService = competencyProgressService; + this.competencyProgressApi = competencyProgressApi; this.participantScoreRepository = participantScoreRepository; this.studentScoreRepository = studentScoreRepository; this.teamScoreRepository = teamScoreRepository; @@ -336,7 +336,7 @@ private void executeTask(Long exerciseId, Long participantId, Instant resultLast if (scoreParticipant instanceof Team team && !Hibernate.isInitialized(team.getStudents())) { scoreParticipant = teamRepository.findWithStudentsByIdElseThrow(team.getId()); } - competencyProgressService.updateProgressByLearningObjectSync(score.getExercise(), scoreParticipant.getParticipants()); + competencyProgressApi.updateProgressByLearningObjectSync(score.getExercise(), scoreParticipant.getParticipants()); } catch (Exception e) { log.error("Exception while processing participant score for exercise {} and participant {} for participant scores:", exerciseId, participantId, e); diff --git a/src/main/java/de/tum/cit/aet/artemis/core/config/migration/entries/MigrationEntry20240614_140000.java b/src/main/java/de/tum/cit/aet/artemis/core/config/migration/entries/MigrationEntry20240614_140000.java index 7371408c2df6..2a10897a652a 100644 --- a/src/main/java/de/tum/cit/aet/artemis/core/config/migration/entries/MigrationEntry20240614_140000.java +++ b/src/main/java/de/tum/cit/aet/artemis/core/config/migration/entries/MigrationEntry20240614_140000.java @@ -6,9 +6,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import de.tum.cit.aet.artemis.atlas.domain.competency.Competency; -import de.tum.cit.aet.artemis.atlas.repository.CompetencyRepository; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; import de.tum.cit.aet.artemis.core.config.migration.MigrationEntry; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.repository.CourseRepository; @@ -19,14 +17,11 @@ public class MigrationEntry20240614_140000 extends MigrationEntry { private final CourseRepository courseRepository; - private final CompetencyRepository competencyRepository; + private final CompetencyProgressApi competencyProgressApi; - private final CompetencyProgressService competencyProgressService; - - public MigrationEntry20240614_140000(CourseRepository courseRepository, CompetencyRepository competencyRepository, CompetencyProgressService competencyProgressService) { + public MigrationEntry20240614_140000(CourseRepository courseRepository, CompetencyProgressApi competencyProgressApi) { this.courseRepository = courseRepository; - this.competencyRepository = competencyRepository; - this.competencyProgressService = competencyProgressService; + this.competencyProgressApi = competencyProgressApi; } @Override @@ -34,12 +29,7 @@ public void execute() { List activeCourses = courseRepository.findAllActiveWithoutTestCourses(ZonedDateTime.now()); log.info("Updating competency progress for {} active courses", activeCourses.size()); - - activeCourses.forEach(course -> { - List competencies = competencyRepository.findByCourseIdOrderById(course.getId()); - // Asynchronously update the progress for each competency - competencies.forEach(competencyProgressService::updateProgressByCompetencyAsync); - }); + competencyProgressApi.updateProgressForCourses(activeCourses); } @Override diff --git a/src/main/java/de/tum/cit/aet/artemis/core/service/CourseService.java b/src/main/java/de/tum/cit/aet/artemis/core/service/CourseService.java index a286744dbe8a..99025c8c236d 100644 --- a/src/main/java/de/tum/cit/aet/artemis/core/service/CourseService.java +++ b/src/main/java/de/tum/cit/aet/artemis/core/service/CourseService.java @@ -53,10 +53,10 @@ import de.tum.cit.aet.artemis.assessment.service.ComplaintService; import de.tum.cit.aet.artemis.assessment.service.PresentationPointsCalculationService; import de.tum.cit.aet.artemis.assessment.service.TutorLeaderboardService; -import de.tum.cit.aet.artemis.atlas.repository.CompetencyRelationRepository; -import de.tum.cit.aet.artemis.atlas.repository.CompetencyRepository; -import de.tum.cit.aet.artemis.atlas.repository.PrerequisiteRepository; -import de.tum.cit.aet.artemis.atlas.service.learningpath.LearningPathService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; +import de.tum.cit.aet.artemis.atlas.api.CompetencyRelationApi; +import de.tum.cit.aet.artemis.atlas.api.LearningPathApi; +import de.tum.cit.aet.artemis.atlas.api.PrerequisitesApi; import de.tum.cit.aet.artemis.communication.domain.NotificationType; import de.tum.cit.aet.artemis.communication.domain.Post; import de.tum.cit.aet.artemis.communication.domain.notification.GroupNotification; @@ -131,7 +131,7 @@ public class CourseService { private final TutorialGroupChannelManagementService tutorialGroupChannelManagementService; - private final CompetencyRelationRepository competencyRelationRepository; + private final CompetencyRelationApi competencyRelationApi; private final ExerciseService exerciseService; @@ -161,9 +161,9 @@ public class CourseService { private final AuditEventRepository auditEventRepository; - private final CompetencyRepository competencyRepository; + private final CompetencyProgressApi competencyProgressApi; - private final PrerequisiteRepository prerequisiteRepository; + private final PrerequisitesApi prerequisitesApi; private final GradingScaleRepository gradingScaleRepository; @@ -199,7 +199,7 @@ public class CourseService { private final ConversationRepository conversationRepository; - private final LearningPathService learningPathService; + private final LearningPathApi learningPathApi; private final Optional irisSettingsService; @@ -216,17 +216,17 @@ public class CourseService { public CourseService(CourseRepository courseRepository, ExerciseService exerciseService, ExerciseDeletionService exerciseDeletionService, AuthorizationCheckService authCheckService, UserRepository userRepository, LectureService lectureService, GroupNotificationRepository groupNotificationRepository, ExerciseGroupRepository exerciseGroupRepository, AuditEventRepository auditEventRepository, UserService userService, ExamDeletionService examDeletionService, - CompetencyRepository competencyRepository, GroupNotificationService groupNotificationService, ExamRepository examRepository, + CompetencyProgressApi competencyProgressApi, GroupNotificationService groupNotificationService, ExamRepository examRepository, CourseExamExportService courseExamExportService, GradingScaleRepository gradingScaleRepository, StatisticsRepository statisticsRepository, StudentParticipationRepository studentParticipationRepository, TutorLeaderboardService tutorLeaderboardService, RatingRepository ratingRepository, ComplaintService complaintService, ComplaintRepository complaintRepository, ResultRepository resultRepository, ComplaintResponseRepository complaintResponseRepository, SubmissionRepository submissionRepository, ProgrammingExerciseRepository programmingExerciseRepository, ExerciseRepository exerciseRepository, ParticipantScoreRepository participantScoreRepository, PresentationPointsCalculationService presentationPointsCalculationService, TutorialGroupRepository tutorialGroupRepository, PlagiarismCaseRepository plagiarismCaseRepository, ConversationRepository conversationRepository, - LearningPathService learningPathService, Optional irisSettingsService, LectureRepository lectureRepository, + LearningPathApi learningPathApi, Optional irisSettingsService, LectureRepository lectureRepository, TutorialGroupNotificationRepository tutorialGroupNotificationRepository, TutorialGroupChannelManagementService tutorialGroupChannelManagementService, - PrerequisiteRepository prerequisiteRepository, CompetencyRelationRepository competencyRelationRepository, PostRepository postRepository, - AnswerPostRepository answerPostRepository, BuildJobRepository buildJobRepository, FaqRepository faqRepository) { + PrerequisitesApi prerequisitesApi, CompetencyRelationApi competencyRelationApi, PostRepository postRepository, AnswerPostRepository answerPostRepository, + BuildJobRepository buildJobRepository, FaqRepository faqRepository) { this.courseRepository = courseRepository; this.exerciseService = exerciseService; this.exerciseDeletionService = exerciseDeletionService; @@ -238,7 +238,7 @@ public CourseService(CourseRepository courseRepository, ExerciseService exercise this.auditEventRepository = auditEventRepository; this.userService = userService; this.examDeletionService = examDeletionService; - this.competencyRepository = competencyRepository; + this.competencyProgressApi = competencyProgressApi; this.groupNotificationService = groupNotificationService; this.examRepository = examRepository; this.courseExamExportService = courseExamExportService; @@ -259,13 +259,13 @@ public CourseService(CourseRepository courseRepository, ExerciseService exercise this.tutorialGroupRepository = tutorialGroupRepository; this.plagiarismCaseRepository = plagiarismCaseRepository; this.conversationRepository = conversationRepository; - this.learningPathService = learningPathService; + this.learningPathApi = learningPathApi; this.irisSettingsService = irisSettingsService; this.lectureRepository = lectureRepository; this.tutorialGroupNotificationRepository = tutorialGroupNotificationRepository; this.tutorialGroupChannelManagementService = tutorialGroupChannelManagementService; - this.prerequisiteRepository = prerequisiteRepository; - this.competencyRelationRepository = competencyRelationRepository; + this.prerequisitesApi = prerequisitesApi; + this.competencyRelationApi = competencyRelationApi; this.buildJobRepository = buildJobRepository; this.postRepository = postRepository; this.answerPostRepository = answerPostRepository; @@ -353,9 +353,9 @@ public Course findOneWithExercisesAndLecturesAndExamsAndCompetenciesAndTutorialG // TODO: in the future, we only want to know if lectures exist, the actual lectures will be loaded when the user navigates into the lecture course.setLectures(lectureService.filterVisibleLecturesWithActiveAttachments(course, course.getLectures(), user)); // NOTE: in this call we only want to know if competencies exist in the course, we will load them when the user navigates into them - course.setNumberOfCompetencies(competencyRepository.countByCourse(course)); + course.setNumberOfCompetencies(competencyProgressApi.countByCourse(course)); // NOTE: in this call we only want to know if prerequisites exist in the course, we will load them when the user navigates into them - course.setNumberOfPrerequisites(prerequisiteRepository.countByCourse(course)); + course.setNumberOfPrerequisites(prerequisitesApi.countByCourse(course)); // NOTE: in this call we only want to know if tutorial groups exist in the course, we will load them when the user navigates into them course.setNumberOfTutorialGroups(tutorialGroupRepository.countByCourse(course)); if (authCheckService.isOnlyStudentInCourse(course, user)) { @@ -574,9 +574,9 @@ private void deleteExercisesOfCourse(Course course) { } private void deleteCompetenciesOfCourse(Course course) { - competencyRelationRepository.deleteAllByCourseId(course.getId()); - prerequisiteRepository.deleteAll(course.getPrerequisites()); - competencyRepository.deleteAll(course.getCompetencies()); + competencyRelationApi.deleteAllByCourseId(course.getId()); + prerequisitesApi.deleteAll(course.getPrerequisites()); + competencyProgressApi.deleteAll(course.getCompetencies()); } private void deleteFaqsOfCourse(Course course) { @@ -614,7 +614,7 @@ public void enrollUserForCourseOrThrow(User user, Course course) { authCheckService.checkUserAllowedToEnrollInCourseElseThrow(user, course); userService.addUserToGroup(user, course.getStudentGroupName()); if (course.getLearningPathsEnabled()) { - learningPathService.generateLearningPathForUser(course, user); + learningPathApi.generateLearningPathForUser(course, user); } final var auditEvent = new AuditEvent(user.getLogin(), Constants.ENROLL_IN_COURSE, "course=" + course.getTitle()); auditEventRepository.add(auditEvent); @@ -647,7 +647,7 @@ public List registerUsersForCourseGroup(Long courseId, List ldapUserService, GuidedTourSettingsRepository guidedTourSettingsRepository, PasswordService passwordService, Optional optionalVcsUserManagementService, Optional optionalCIUserManagementService, - InstanceMessageSendService instanceMessageSendService, FileService fileService, ScienceEventRepository scienceEventRepository, + InstanceMessageSendService instanceMessageSendService, FileService fileService, ScienceEventApi scienceEventApi, ParticipationVcsAccessTokenService participationVCSAccessTokenService) { this.userCreationService = userCreationService; this.userRepository = userRepository; @@ -130,7 +130,7 @@ public UserService(UserCreationService userCreationService, UserRepository userR this.optionalCIUserManagementService = optionalCIUserManagementService; this.instanceMessageSendService = instanceMessageSendService; this.fileService = fileService; - this.scienceEventRepository = scienceEventRepository; + this.scienceEventApi = scienceEventApi; this.participationVCSAccessTokenService = participationVCSAccessTokenService; } @@ -497,7 +497,7 @@ protected void anonymizeUser(User user) { clearUserCaches(user); userRepository.flush(); - scienceEventRepository.renameIdentity(originalLogin, anonymizedLogin); + scienceEventApi.renameIdentity(originalLogin, anonymizedLogin); if (userImageString != null) { fileService.schedulePathForDeletion(FilePathService.actualPathForPublicPath(URI.create(userImageString)), 0); diff --git a/src/main/java/de/tum/cit/aet/artemis/core/web/CourseResource.java b/src/main/java/de/tum/cit/aet/artemis/core/web/CourseResource.java index 16b7dd554842..2d9196656037 100644 --- a/src/main/java/de/tum/cit/aet/artemis/core/web/CourseResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/core/web/CourseResource.java @@ -67,7 +67,7 @@ import de.tum.cit.aet.artemis.assessment.service.CourseScoreCalculationService; import de.tum.cit.aet.artemis.assessment.service.GradingScaleService; import de.tum.cit.aet.artemis.athena.service.AthenaModuleService; -import de.tum.cit.aet.artemis.atlas.service.learningpath.LearningPathService; +import de.tum.cit.aet.artemis.atlas.api.LearningPathApi; import de.tum.cit.aet.artemis.communication.service.ConductAgreementService; import de.tum.cit.aet.artemis.core.config.Constants; import de.tum.cit.aet.artemis.core.domain.Course; @@ -181,7 +181,7 @@ public class CourseResource { @Value("${artemis.course-archives-path}") private String courseArchivesDirPath; - private final LearningPathService learningPathService; + private final LearningPathApi learningPathApi; private final ExamRepository examRepository; @@ -194,7 +194,7 @@ public CourseResource(UserRepository userRepository, CourseService courseService TutorParticipationRepository tutorParticipationRepository, SubmissionService submissionService, Optional optionalVcsUserManagementService, AssessmentDashboardService assessmentDashboardService, ExerciseRepository exerciseRepository, Optional optionalCiUserManagementService, FileService fileService, TutorialGroupsConfigurationService tutorialGroupsConfigurationService, GradingScaleService gradingScaleService, - CourseScoreCalculationService courseScoreCalculationService, GradingScaleRepository gradingScaleRepository, LearningPathService learningPathService, + CourseScoreCalculationService courseScoreCalculationService, GradingScaleRepository gradingScaleRepository, LearningPathApi learningPathApi, ConductAgreementService conductAgreementService, Optional athenaModuleService, ExamRepository examRepository, ComplaintService complaintService, TeamRepository teamRepository) { this.courseService = courseService; @@ -214,7 +214,7 @@ public CourseResource(UserRepository userRepository, CourseService courseService this.gradingScaleService = gradingScaleService; this.courseScoreCalculationService = courseScoreCalculationService; this.gradingScaleRepository = gradingScaleRepository; - this.learningPathService = learningPathService; + this.learningPathApi = learningPathApi; this.conductAgreementService = conductAgreementService; this.athenaModuleService = athenaModuleService; this.examRepository = examRepository; @@ -342,7 +342,7 @@ else if (courseUpdate.getCourseIcon() == null && existingCourse.getCourseIcon() // if learning paths got enabled, generate learning paths for students if (existingCourse.getLearningPathsEnabled() != courseUpdate.getLearningPathsEnabled() && courseUpdate.getLearningPathsEnabled()) { Course courseWithCompetencies = courseRepository.findWithEagerCompetenciesAndPrerequisitesByIdElseThrow(result.getId()); - learningPathService.generateLearningPaths(courseWithCompetencies); + learningPathApi.generateLearningPaths(courseWithCompetencies); } // if access to restricted athena modules got disabled for the course, we need to set all exercises that use restricted modules to null @@ -1277,7 +1277,7 @@ public ResponseEntity addUserToCourseGroup(String userLogin, User instruct courseService.addUserToGroup(userToAddToGroup.get(), group); if (role == Role.STUDENT && course.getLearningPathsEnabled()) { Course courseWithCompetencies = courseRepository.findWithEagerCompetenciesAndPrerequisitesByIdElseThrow(course.getId()); - learningPathService.generateLearningPathForUser(courseWithCompetencies, userToAddToGroup.get()); + learningPathApi.generateLearningPathForUser(courseWithCompetencies, userToAddToGroup.get()); } return ResponseEntity.ok().body(null); } diff --git a/src/main/java/de/tum/cit/aet/artemis/exercise/service/ExerciseDeletionService.java b/src/main/java/de/tum/cit/aet/artemis/exercise/service/ExerciseDeletionService.java index 6739cfc0c714..fd80e0a00fb5 100644 --- a/src/main/java/de/tum/cit/aet/artemis/exercise/service/ExerciseDeletionService.java +++ b/src/main/java/de/tum/cit/aet/artemis/exercise/service/ExerciseDeletionService.java @@ -16,9 +16,8 @@ import de.tum.cit.aet.artemis.assessment.repository.TutorParticipationRepository; import de.tum.cit.aet.artemis.assessment.service.ExampleSubmissionService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyExerciseLink; -import de.tum.cit.aet.artemis.atlas.repository.CompetencyExerciseLinkRepository; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; import de.tum.cit.aet.artemis.communication.domain.conversation.Channel; import de.tum.cit.aet.artemis.communication.repository.conversation.ChannelRepository; import de.tum.cit.aet.artemis.communication.service.conversation.ChannelService; @@ -79,9 +78,7 @@ public class ExerciseDeletionService { private final ChannelService channelService; - private final CompetencyProgressService competencyProgressService; - - private final CompetencyExerciseLinkRepository competencyExerciseLinkRepository; + private final CompetencyProgressApi competencyProgressApi; private final Optional irisSettingsService; @@ -89,8 +86,7 @@ public ExerciseDeletionService(ExerciseRepository exerciseRepository, ExerciseUn ProgrammingExerciseService programmingExerciseService, ModelingExerciseService modelingExerciseService, QuizExerciseService quizExerciseService, TutorParticipationRepository tutorParticipationRepository, ExampleSubmissionService exampleSubmissionService, StudentExamRepository studentExamRepository, LectureUnitService lectureUnitService, PlagiarismResultRepository plagiarismResultRepository, TextExerciseService textExerciseService, - ChannelRepository channelRepository, ChannelService channelService, CompetencyProgressService competencyProgressService, - CompetencyExerciseLinkRepository competencyExerciseLinkRepository, Optional irisSettingsService) { + ChannelRepository channelRepository, ChannelService channelService, CompetencyProgressApi competencyProgressApi, Optional irisSettingsService) { this.exerciseRepository = exerciseRepository; this.participationService = participationService; this.programmingExerciseService = programmingExerciseService; @@ -105,8 +101,7 @@ public ExerciseDeletionService(ExerciseRepository exerciseRepository, ExerciseUn this.textExerciseService = textExerciseService; this.channelRepository = channelRepository; this.channelService = channelService; - this.competencyProgressService = competencyProgressService; - this.competencyExerciseLinkRepository = competencyExerciseLinkRepository; + this.competencyProgressApi = competencyProgressApi; this.irisSettingsService = irisSettingsService; } @@ -219,7 +214,7 @@ public void delete(long exerciseId, boolean deleteStudentReposBuildPlans, boolea exerciseRepository.delete(exercise); } - competencyLinks.stream().map(CompetencyExerciseLink::getCompetency).forEach(competencyProgressService::updateProgressByCompetencyAsync); + competencyLinks.stream().map(CompetencyExerciseLink::getCompetency).forEach(competencyProgressApi::updateProgressByCompetencyAsync); } /** diff --git a/src/main/java/de/tum/cit/aet/artemis/exercise/service/ExerciseService.java b/src/main/java/de/tum/cit/aet/artemis/exercise/service/ExerciseService.java index 0a355a870620..73fce3b0f9f1 100644 --- a/src/main/java/de/tum/cit/aet/artemis/exercise/service/ExerciseService.java +++ b/src/main/java/de/tum/cit/aet/artemis/exercise/service/ExerciseService.java @@ -45,9 +45,9 @@ import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; import de.tum.cit.aet.artemis.assessment.service.RatingService; import de.tum.cit.aet.artemis.assessment.service.TutorLeaderboardService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyRelationApi; import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyExerciseLink; import de.tum.cit.aet.artemis.atlas.domain.competency.CourseCompetency; -import de.tum.cit.aet.artemis.atlas.repository.CompetencyExerciseLinkRepository; import de.tum.cit.aet.artemis.communication.service.notifications.GroupNotificationScheduleService; import de.tum.cit.aet.artemis.core.config.Constants; import de.tum.cit.aet.artemis.core.domain.Course; @@ -130,7 +130,7 @@ public class ExerciseService { private final GroupNotificationScheduleService groupNotificationScheduleService; - private final CompetencyExerciseLinkRepository competencyExerciseLinkRepository; + private final CompetencyRelationApi competencyRelationApi; public ExerciseService(ExerciseRepository exerciseRepository, AuthorizationCheckService authCheckService, AuditEventRepository auditEventRepository, TeamRepository teamRepository, ProgrammingExerciseRepository programmingExerciseRepository, Optional lti13ResourceLaunchRepository, @@ -139,7 +139,7 @@ public ExerciseService(ExerciseRepository exerciseRepository, AuthorizationCheck TutorLeaderboardService tutorLeaderboardService, ComplaintResponseRepository complaintResponseRepository, GradingCriterionRepository gradingCriterionRepository, FeedbackRepository feedbackRepository, RatingService ratingService, ExerciseDateService exerciseDateService, ExampleSubmissionRepository exampleSubmissionRepository, QuizBatchService quizBatchService, ExamLiveEventsService examLiveEventsService, GroupNotificationScheduleService groupNotificationScheduleService, - CompetencyExerciseLinkRepository competencyExerciseLinkRepository) { + CompetencyRelationApi competencyRelationApi) { this.exerciseRepository = exerciseRepository; this.resultRepository = resultRepository; this.authCheckService = authCheckService; @@ -162,7 +162,7 @@ public ExerciseService(ExerciseRepository exerciseRepository, AuthorizationCheck this.quizBatchService = quizBatchService; this.examLiveEventsService = examLiveEventsService; this.groupNotificationScheduleService = groupNotificationScheduleService; - this.competencyExerciseLinkRepository = competencyExerciseLinkRepository; + this.competencyRelationApi = competencyRelationApi; } /** @@ -773,7 +773,7 @@ public List getFeedbackToBeDeletedAfterGradingInstructionUpdate(boolea * @param competency competency to remove */ public void removeCompetency(@NotNull Set exerciseLinks, @NotNull CourseCompetency competency) { - competencyExerciseLinkRepository.deleteAll(exerciseLinks); + competencyRelationApi.deleteAllExerciseLinks(exerciseLinks); competency.getExerciseLinks().removeAll(exerciseLinks); } @@ -815,7 +815,7 @@ public T saveWithCompetencyLinks(T exercise, Function if (Hibernate.isInitialized(links) && !links.isEmpty()) { savedExercise.setCompetencyLinks(links); reconnectCompetencyExerciseLinks(savedExercise); - savedExercise.setCompetencyLinks(new HashSet<>(competencyExerciseLinkRepository.saveAll(links))); + savedExercise.setCompetencyLinks(new HashSet<>(competencyRelationApi.saveAllExerciseLinks(links))); } return savedExercise; diff --git a/src/main/java/de/tum/cit/aet/artemis/exercise/service/LearningMetricsService.java b/src/main/java/de/tum/cit/aet/artemis/exercise/service/LearningMetricsService.java index c939f59367b5..3bf12a37a1ca 100644 --- a/src/main/java/de/tum/cit/aet/artemis/exercise/service/LearningMetricsService.java +++ b/src/main/java/de/tum/cit/aet/artemis/exercise/service/LearningMetricsService.java @@ -18,6 +18,7 @@ import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Service; +import de.tum.cit.aet.artemis.atlas.api.CompetencyMetricsApi; import de.tum.cit.aet.artemis.atlas.dto.CompetencyJolDTO; import de.tum.cit.aet.artemis.atlas.dto.metrics.CompetencyInformationDTO; import de.tum.cit.aet.artemis.atlas.dto.metrics.CompetencyProgressDTO; @@ -29,7 +30,6 @@ import de.tum.cit.aet.artemis.atlas.dto.metrics.ResourceTimestampDTO; import de.tum.cit.aet.artemis.atlas.dto.metrics.ScoreDTO; import de.tum.cit.aet.artemis.atlas.dto.metrics.StudentMetricsDTO; -import de.tum.cit.aet.artemis.atlas.repository.CompetencyMetricsRepository; import de.tum.cit.aet.artemis.exercise.dto.ExerciseInformationDTO; import de.tum.cit.aet.artemis.exercise.repository.ExerciseMetricsRepository; import de.tum.cit.aet.artemis.lecture.repository.LectureUnitMetricsRepository; @@ -45,13 +45,13 @@ public class LearningMetricsService { private final LectureUnitMetricsRepository lectureUnitMetricsRepository; - private final CompetencyMetricsRepository competencyMetricsRepository; + private final CompetencyMetricsApi competencyMetricsApi; public LearningMetricsService(ExerciseMetricsRepository exerciseMetricsRepository, LectureUnitMetricsRepository lectureUnitMetricsRepository, - CompetencyMetricsRepository competencyMetricsRepository) { + CompetencyMetricsApi competencyMetricsApi) { this.exerciseMetricsRepository = exerciseMetricsRepository; this.lectureUnitMetricsRepository = lectureUnitMetricsRepository; - this.competencyMetricsRepository = competencyMetricsRepository; + this.competencyMetricsApi = competencyMetricsApi; } /** @@ -136,26 +136,26 @@ public LectureUnitStudentMetricsDTO getStudentLectureUnitMetrics(long userId, lo * @return the metrics for the student in the course */ public CompetencyStudentMetricsDTO getStudentCompetencyMetrics(long userId, long courseId) { - final var competencyInfo = competencyMetricsRepository.findAllCompetencyInformationByCourseId(courseId); + final var competencyInfo = competencyMetricsApi.findAllCompetencyInformationByCourseId(courseId); final var competencyInfoMap = competencyInfo.stream().collect(toMap(CompetencyInformationDTO::id, identity())); final var competencyIds = competencyInfoMap.keySet(); - final var competencyExerciseMapEntries = competencyMetricsRepository.findAllExerciseIdsByCompetencyIds(competencyIds); + final var competencyExerciseMapEntries = competencyMetricsApi.findAllExerciseIdsByCompetencyIds(competencyIds); final var exerciseMap = competencyExerciseMapEntries.stream().collect(groupingBy(MapEntryLongLong::key, mapping(MapEntryLongLong::value, toSet()))); - final var competencyLectureUnitMapEntries = competencyMetricsRepository.findAllLectureUnitIdsByCompetencyIds(competencyIds); + final var competencyLectureUnitMapEntries = competencyMetricsApi.findAllLectureUnitIdsByCompetencyIds(competencyIds); final var lectureUnitMap = competencyLectureUnitMapEntries.stream().collect(groupingBy(MapEntryLongLong::key, mapping(MapEntryLongLong::value, toSet()))); - final var competencyProgress = competencyMetricsRepository.findAllCompetencyProgressForUserByCompetencyIds(userId, competencyIds); + final var competencyProgress = competencyMetricsApi.findAllCompetencyProgressForUserByCompetencyIds(userId, competencyIds); final var competencyProgressMap = competencyProgress.stream().collect(toMap(CompetencyProgressDTO::competencyId, CompetencyProgressDTO::progress)); final var competencyConfidenceMap = competencyProgress.stream().collect(toMap(CompetencyProgressDTO::competencyId, CompetencyProgressDTO::confidence)); - final var currentJolValues = competencyMetricsRepository.findAllLatestCompetencyJolValuesForUserByCompetencyIds(userId, competencyIds); + final var currentJolValues = competencyMetricsApi.findAllLatestCompetencyJolValuesForUserByCompetencyIds(userId, competencyIds); final var currentJolValuesMap = currentJolValues.stream().collect(toMap(CompetencyJolDTO::competencyId, identity())); final var currentJolIds = currentJolValues.stream().map(CompetencyJolDTO::id).collect(toSet()); - final var priorJolValues = competencyMetricsRepository.findAllLatestCompetencyJolValuesForUserByCompetencyIdsExcludeJolIds(userId, competencyIds, currentJolIds); + final var priorJolValues = competencyMetricsApi.findAllLatestCompetencyJolValuesForUserByCompetencyIdsExcludeJolIds(userId, competencyIds, currentJolIds); final var priorJolValuesMap = priorJolValues.stream().collect(toMap(CompetencyJolDTO::competencyId, identity())); return new CompetencyStudentMetricsDTO(competencyInfoMap, exerciseMap, lectureUnitMap, competencyProgressMap, competencyConfidenceMap, currentJolValuesMap, diff --git a/src/main/java/de/tum/cit/aet/artemis/exercise/service/ParticipationService.java b/src/main/java/de/tum/cit/aet/artemis/exercise/service/ParticipationService.java index 9074ad8ec1f8..a8c4d3507813 100644 --- a/src/main/java/de/tum/cit/aet/artemis/exercise/service/ParticipationService.java +++ b/src/main/java/de/tum/cit/aet/artemis/exercise/service/ParticipationService.java @@ -24,7 +24,7 @@ import de.tum.cit.aet.artemis.assessment.repository.StudentScoreRepository; import de.tum.cit.aet.artemis.assessment.repository.TeamScoreRepository; import de.tum.cit.aet.artemis.assessment.service.ResultService; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.exception.ContinuousIntegrationException; import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; @@ -109,7 +109,7 @@ public class ParticipationService { private final ParticipationVcsAccessTokenService participationVCSAccessTokenService; - private final CompetencyProgressService competencyProgressService; + private final CompetencyProgressApi competencyProgressApi; public ParticipationService(GitService gitService, Optional continuousIntegrationService, Optional versionControlService, BuildLogEntryService buildLogEntryService, ParticipationRepository participationRepository, StudentParticipationRepository studentParticipationRepository, @@ -118,7 +118,7 @@ public ParticipationService(GitService gitService, Optional localCISharedBuildJobQueueService, ProfileService profileService, - ParticipationVcsAccessTokenService participationVCSAccessTokenService, CompetencyProgressService competencyProgressService) { + ParticipationVcsAccessTokenService participationVCSAccessTokenService, CompetencyProgressApi competencyProgressApi) { this.gitService = gitService; this.continuousIntegrationService = continuousIntegrationService; this.versionControlService = versionControlService; @@ -139,7 +139,7 @@ public ParticipationService(GitService gitService, Optional createFileUploadExercise(@RequestBody channelService.createExerciseChannel(result, Optional.ofNullable(fileUploadExercise.getChannelName())); groupNotificationScheduleService.checkNotificationsForNewExerciseAsync(fileUploadExercise); - competencyProgressService.updateProgressByLearningObjectAsync(result); + competencyProgressApi.updateProgressByLearningObjectAsync(result); return ResponseEntity.created(new URI("/api/file-upload-exercises/" + result.getId())).body(result); } @@ -287,7 +287,7 @@ public ResponseEntity updateFileUploadExercise(@RequestBody participationRepository.removeIndividualDueDatesIfBeforeDueDate(updatedExercise, fileUploadExerciseBeforeUpdate.getDueDate()); exerciseService.notifyAboutExerciseChanges(fileUploadExerciseBeforeUpdate, updatedExercise, notificationText); - competencyProgressService.updateProgressForUpdatedLearningObjectAsync(fileUploadExerciseBeforeUpdate, Optional.of(fileUploadExercise)); + competencyProgressApi.updateProgressForUpdatedLearningObjectAsync(fileUploadExerciseBeforeUpdate, Optional.of(fileUploadExercise)); return ResponseEntity.ok(updatedExercise); } 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 e86d7c22e7f5..4586f12d4fa4 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 @@ -16,8 +16,8 @@ import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyLectureUnitLink; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; import de.tum.cit.aet.artemis.core.exception.BadRequestAlertException; import de.tum.cit.aet.artemis.core.service.FilePathService; import de.tum.cit.aet.artemis.core.service.FileService; @@ -49,13 +49,13 @@ public class AttachmentUnitService { private final Optional irisSettingsRepository; - private final CompetencyProgressService competencyProgressService; + private final CompetencyProgressApi competencyProgressService; private final LectureUnitService lectureUnitService; public AttachmentUnitService(SlideRepository slideRepository, SlideSplitterService slideSplitterService, AttachmentUnitRepository attachmentUnitRepository, AttachmentRepository attachmentRepository, FileService fileService, Optional pyrisWebhookService, - Optional irisSettingsRepository, CompetencyProgressService competencyProgressService, LectureUnitService lectureUnitService) { + Optional irisSettingsRepository, CompetencyProgressApi competencyProgressService, LectureUnitService lectureUnitService) { this.attachmentUnitRepository = attachmentUnitRepository; this.attachmentRepository = attachmentRepository; this.fileService = fileService; 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 3095605139a1..1097eccba6c8 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 @@ -13,8 +13,8 @@ import org.springframework.data.domain.Page; import org.springframework.stereotype.Service; -import de.tum.cit.aet.artemis.atlas.repository.CompetencyLectureUnitLinkRepository; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; +import de.tum.cit.aet.artemis.atlas.api.CompetencyRelationApi; import de.tum.cit.aet.artemis.communication.domain.conversation.Channel; import de.tum.cit.aet.artemis.communication.repository.conversation.ChannelRepository; import de.tum.cit.aet.artemis.communication.service.conversation.ChannelService; @@ -46,20 +46,19 @@ public class LectureService { private final Optional pyrisWebhookService; - private final CompetencyProgressService competencyProgressService; + private final CompetencyProgressApi competencyProgressApi; - private final CompetencyLectureUnitLinkRepository competencyLectureUnitLinkRepository; + private final CompetencyRelationApi competencyRelationApi; public LectureService(LectureRepository lectureRepository, AuthorizationCheckService authCheckService, ChannelRepository channelRepository, ChannelService channelService, - Optional pyrisWebhookService, CompetencyProgressService competencyProgressService, - CompetencyLectureUnitLinkRepository competencyLectureUnitLinkRepository) { + Optional pyrisWebhookService, CompetencyProgressApi competencyProgressApi, CompetencyRelationApi competencyRelationApi) { this.lectureRepository = lectureRepository; this.authCheckService = authCheckService; this.channelRepository = channelRepository; this.channelService = channelService; this.pyrisWebhookService = pyrisWebhookService; - this.competencyProgressService = competencyProgressService; - this.competencyLectureUnitLinkRepository = competencyLectureUnitLinkRepository; + this.competencyProgressApi = competencyProgressApi; + this.competencyRelationApi = competencyRelationApi; } /** @@ -162,13 +161,13 @@ public void delete(Lecture lecture, boolean updateCompetencyProgress) { if (updateCompetencyProgress) { lecture.getLectureUnits().stream().filter(lectureUnit -> !(lectureUnit instanceof ExerciseUnit)) - .forEach(lectureUnit -> competencyProgressService.updateProgressForUpdatedLearningObjectAsync(lectureUnit, Optional.empty())); + .forEach(lectureUnit -> competencyProgressApi.updateProgressForUpdatedLearningObjectAsync(lectureUnit, Optional.empty())); } Channel lectureChannel = channelRepository.findChannelByLectureId(lecture.getId()); channelService.deleteChannel(lectureChannel); - competencyLectureUnitLinkRepository.deleteAllByLectureId(lecture.getId()); + competencyRelationApi.deleteAllLectureUnitLinksByLectureId(lecture.getId()); lectureRepository.deleteById(lecture.getId()); } 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 793752998f29..84a3b5563c4f 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 @@ -23,11 +23,11 @@ import org.springframework.dao.DataIntegrityViolationException; import org.springframework.stereotype.Service; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; +import de.tum.cit.aet.artemis.atlas.api.CompetencyRelationApi; +import de.tum.cit.aet.artemis.atlas.api.CourseCompetencyApi; import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyLectureUnitLink; import de.tum.cit.aet.artemis.atlas.domain.competency.CourseCompetency; -import de.tum.cit.aet.artemis.atlas.repository.CompetencyLectureUnitLinkRepository; -import de.tum.cit.aet.artemis.atlas.repository.CourseCompetencyRepository; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.service.FilePathService; import de.tum.cit.aet.artemis.core.service.FileService; @@ -59,24 +59,24 @@ public class LectureUnitService { private final Optional pyrisWebhookService; - private final CompetencyProgressService competencyProgressService; + private final CompetencyProgressApi competencyProgressApi; - private final CourseCompetencyRepository courseCompetencyRepository; + private final CourseCompetencyApi courseCompetencyApi; - private final CompetencyLectureUnitLinkRepository competencyLectureUnitLinkRepository; + private final CompetencyRelationApi competencyRelationApi; public LectureUnitService(LectureUnitRepository lectureUnitRepository, LectureRepository lectureRepository, LectureUnitCompletionRepository lectureUnitCompletionRepository, - FileService fileService, SlideRepository slideRepository, Optional pyrisWebhookService, CompetencyProgressService competencyProgressService, - CourseCompetencyRepository courseCompetencyRepository, CompetencyLectureUnitLinkRepository competencyLectureUnitLinkRepository) { + FileService fileService, SlideRepository slideRepository, Optional pyrisWebhookService, CompetencyProgressApi competencyProgressApi, + CourseCompetencyApi courseCompetencyApi, CompetencyRelationApi competencyRelationApi) { this.lectureUnitRepository = lectureUnitRepository; this.lectureRepository = lectureRepository; this.lectureUnitCompletionRepository = lectureUnitCompletionRepository; this.fileService = fileService; this.slideRepository = slideRepository; this.pyrisWebhookService = pyrisWebhookService; - this.courseCompetencyRepository = courseCompetencyRepository; - this.competencyProgressService = competencyProgressService; - this.competencyLectureUnitLinkRepository = competencyLectureUnitLinkRepository; + this.courseCompetencyApi = courseCompetencyApi; + this.competencyProgressApi = competencyProgressApi; + this.competencyRelationApi = competencyRelationApi; } /** @@ -177,7 +177,7 @@ public void removeLectureUnit(@NotNull LectureUnit lectureUnit) { if (!(lectureUnitToDelete instanceof ExerciseUnit)) { // update associated competency progress objects - competencyProgressService.updateProgressForUpdatedLearningObjectAsync(lectureUnitToDelete, Optional.empty()); + competencyProgressApi.updateProgressForUpdatedLearningObjectAsync(lectureUnitToDelete, Optional.empty()); } } @@ -190,7 +190,7 @@ public void removeLectureUnit(@NotNull LectureUnit lectureUnit) { public void linkLectureUnitsToCompetency(CourseCompetency competency, Set lectureUnitLinks) { lectureUnitLinks.forEach(link -> link.setCompetency(competency)); competency.setLectureUnitLinks(lectureUnitLinks); - courseCompetencyRepository.save(competency); + courseCompetencyApi.save(competency); } /** @@ -200,7 +200,7 @@ public void linkLectureUnitsToCompetency(CourseCompetency competency, Set lectureUnitLinks, CourseCompetency competency) { - competencyLectureUnitLinkRepository.deleteAll(lectureUnitLinks); + competencyRelationApi.deleteAllLectureUnitLinks(lectureUnitLinks); competency.getLectureUnitLinks().removeAll(lectureUnitLinks); } @@ -256,7 +256,7 @@ public T saveWithCompetencyLinks(T lectureUnit, Function if (Hibernate.isInitialized(links) && !links.isEmpty()) { savedLectureUnit.setCompetencyLinks(links); reconnectCompetencyLectureUnitLinks(savedLectureUnit); - savedLectureUnit.setCompetencyLinks(new HashSet<>(competencyLectureUnitLinkRepository.saveAll(links))); + savedLectureUnit.setCompetencyLinks(new HashSet<>(competencyRelationApi.saveAllLectureUnitLinks(links))); } return savedLectureUnit; 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 0c7c2996e162..41ea9438e8fb 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 @@ -29,7 +29,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; import de.tum.cit.aet.artemis.communication.service.notifications.GroupNotificationService; import de.tum.cit.aet.artemis.core.exception.BadRequestAlertException; import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; @@ -69,7 +69,7 @@ public class AttachmentUnitResource { private final LectureUnitProcessingService lectureUnitProcessingService; - private final CompetencyProgressService competencyProgressService; + private final CompetencyProgressApi competencyProgressApi; private final SlideSplitterService slideSplitterService; @@ -77,14 +77,14 @@ public class AttachmentUnitResource { public AttachmentUnitResource(AttachmentUnitRepository attachmentUnitRepository, LectureRepository lectureRepository, LectureUnitProcessingService lectureUnitProcessingService, AuthorizationCheckService authorizationCheckService, GroupNotificationService groupNotificationService, AttachmentUnitService attachmentUnitService, - CompetencyProgressService competencyProgressService, SlideSplitterService slideSplitterService, FileService fileService) { + CompetencyProgressApi competencyProgressApi, SlideSplitterService slideSplitterService, FileService fileService) { this.attachmentUnitRepository = attachmentUnitRepository; this.lectureUnitProcessingService = lectureUnitProcessingService; this.lectureRepository = lectureRepository; this.authorizationCheckService = authorizationCheckService; this.groupNotificationService = groupNotificationService; this.attachmentUnitService = attachmentUnitService; - this.competencyProgressService = competencyProgressService; + this.competencyProgressApi = competencyProgressApi; this.slideSplitterService = slideSplitterService; this.fileService = fileService; } @@ -173,7 +173,7 @@ public ResponseEntity createAttachmentUnit(@PathVariable Long le slideSplitterService.splitAttachmentUnitIntoSingleSlides(savedAttachmentUnit); } attachmentUnitService.prepareAttachmentUnitForClient(savedAttachmentUnit); - competencyProgressService.updateProgressByLearningObjectAsync(savedAttachmentUnit); + competencyProgressApi.updateProgressByLearningObjectAsync(savedAttachmentUnit); return ResponseEntity.created(new URI("/api/attachment-units/" + savedAttachmentUnit.getId())).body(savedAttachmentUnit); } @@ -228,7 +228,7 @@ public ResponseEntity> createAttachmentUnits(@PathVariable List savedAttachmentUnits = lectureUnitProcessingService.splitAndSaveUnits(lectureUnitSplitInformationDTO, fileBytes, lectureRepository.findByIdWithLectureUnitsAndAttachmentsElseThrow(lectureId)); savedAttachmentUnits.forEach(attachmentUnitService::prepareAttachmentUnitForClient); - savedAttachmentUnits.forEach(competencyProgressService::updateProgressByLearningObjectAsync); + savedAttachmentUnits.forEach(competencyProgressApi::updateProgressByLearningObjectAsync); return ResponseEntity.ok().body(savedAttachmentUnits); } catch (IOException e) { 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 b14667346674..7f53bca44abf 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 @@ -22,7 +22,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.exception.BadRequestAlertException; import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; @@ -63,16 +63,16 @@ public class LectureUnitResource { private final LectureUnitService lectureUnitService; - private final CompetencyProgressService competencyProgressService; + private final CompetencyProgressApi competencyProgressApi; public LectureUnitResource(AuthorizationCheckService authorizationCheckService, UserRepository userRepository, LectureRepository lectureRepository, - LectureUnitRepository lectureUnitRepository, LectureUnitService lectureUnitService, CompetencyProgressService competencyProgressService, UserService userService) { + LectureUnitRepository lectureUnitRepository, LectureUnitService lectureUnitService, CompetencyProgressApi competencyProgressApi, UserService userService) { this.authorizationCheckService = authorizationCheckService; this.userRepository = userRepository; this.lectureUnitRepository = lectureUnitRepository; this.lectureRepository = lectureRepository; this.lectureUnitService = lectureUnitService; - this.competencyProgressService = competencyProgressService; + this.competencyProgressApi = competencyProgressApi; } /** @@ -142,7 +142,7 @@ public ResponseEntity completeLectureUnit(@PathVariable Long lectureUnitId authorizationCheckService.checkHasAtLeastRoleInCourseElseThrow(Role.STUDENT, lectureUnit.getLecture().getCourse(), user); lectureUnitService.setLectureUnitCompletion(lectureUnit, user, completed); - competencyProgressService.updateProgressByLearningObjectForParticipantAsync(lectureUnit, user); + competencyProgressApi.updateProgressByLearningObjectForParticipantAsync(lectureUnit, user); return ResponseEntity.ok().build(); } 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 c5e8bfa600d1..891701b00afc 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 @@ -28,7 +28,7 @@ import com.google.common.net.InternetDomainName; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; import de.tum.cit.aet.artemis.core.dto.OnlineResourceDTO; import de.tum.cit.aet.artemis.core.exception.BadRequestAlertException; import de.tum.cit.aet.artemis.core.exception.InternalServerErrorException; @@ -56,16 +56,16 @@ public class OnlineUnitResource { private final AuthorizationCheckService authorizationCheckService; - private final CompetencyProgressService competencyProgressService; + private final CompetencyProgressApi competencyProgressApi; private final LectureUnitService lectureUnitService; public OnlineUnitResource(LectureRepository lectureRepository, AuthorizationCheckService authorizationCheckService, OnlineUnitRepository onlineUnitRepository, - CompetencyProgressService competencyProgressService, LectureUnitService lectureUnitService) { + CompetencyProgressApi competencyProgressApi, LectureUnitService lectureUnitService) { this.lectureRepository = lectureRepository; this.authorizationCheckService = authorizationCheckService; this.onlineUnitRepository = onlineUnitRepository; - this.competencyProgressService = competencyProgressService; + this.competencyProgressApi = competencyProgressApi; this.lectureUnitService = lectureUnitService; } @@ -110,7 +110,7 @@ public ResponseEntity updateOnlineUnit(@PathVariable Long lectureId, OnlineUnit result = lectureUnitService.saveWithCompetencyLinks(onlineUnit, onlineUnitRepository::save); - competencyProgressService.updateProgressForUpdatedLearningObjectAsync(existingOnlineUnit, Optional.of(onlineUnit)); + competencyProgressApi.updateProgressForUpdatedLearningObjectAsync(existingOnlineUnit, Optional.of(onlineUnit)); return ResponseEntity.ok(result); } @@ -148,7 +148,7 @@ public ResponseEntity createOnlineUnit(@PathVariable Long lectureId, lecture.addLectureUnit(persistedOnlineUnit); lectureRepository.save(lecture); - competencyProgressService.updateProgressByLearningObjectAsync(persistedOnlineUnit); + competencyProgressApi.updateProgressByLearningObjectAsync(persistedOnlineUnit); return ResponseEntity.created(new URI("/api/online-units/" + persistedOnlineUnit.getId())).body(persistedOnlineUnit); } 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 b48d11ca87d4..e7c15d7e786f 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 @@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; import de.tum.cit.aet.artemis.core.exception.BadRequestAlertException; import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; import de.tum.cit.aet.artemis.core.security.Role; @@ -45,16 +45,16 @@ public class TextUnitResource { private final AuthorizationCheckService authorizationCheckService; - private final CompetencyProgressService competencyProgressService; + private final CompetencyProgressApi competencyProgressApi; private final LectureUnitService lectureUnitService; public TextUnitResource(LectureRepository lectureRepository, TextUnitRepository textUnitRepository, AuthorizationCheckService authorizationCheckService, - CompetencyProgressService competencyProgressService, LectureUnitService lectureUnitService) { + CompetencyProgressApi competencyProgressApi, LectureUnitService lectureUnitService) { this.lectureRepository = lectureRepository; this.textUnitRepository = textUnitRepository; this.authorizationCheckService = authorizationCheckService; - this.competencyProgressService = competencyProgressService; + this.competencyProgressApi = competencyProgressApi; this.lectureUnitService = lectureUnitService; } @@ -108,7 +108,7 @@ public ResponseEntity updateTextUnit(@PathVariable Long lectureId, @Re TextUnit result = lectureUnitService.saveWithCompetencyLinks(textUnitForm, textUnitRepository::save); - competencyProgressService.updateProgressForUpdatedLearningObjectAsync(existingTextUnit, Optional.of(textUnitForm)); + competencyProgressApi.updateProgressForUpdatedLearningObjectAsync(existingTextUnit, Optional.of(textUnitForm)); return ResponseEntity.ok(result); } @@ -146,7 +146,7 @@ public ResponseEntity createTextUnit(@PathVariable Long lectureId, @Re Lecture updatedLecture = lectureRepository.save(lecture); TextUnit persistedTextUnit = (TextUnit) updatedLecture.getLectureUnits().getLast(); - competencyProgressService.updateProgressByLearningObjectAsync(persistedTextUnit); + competencyProgressApi.updateProgressByLearningObjectAsync(persistedTextUnit); lectureUnitService.disconnectCompetencyLectureUnitLinks(persistedTextUnit); return ResponseEntity.created(new URI("/api/text-units/" + persistedTextUnit.getId())).body(persistedTextUnit); 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 e38d2580f83e..ad4e2d75b163 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 @@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; import de.tum.cit.aet.artemis.core.exception.BadRequestAlertException; import de.tum.cit.aet.artemis.core.security.Role; import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastEditor; @@ -46,16 +46,16 @@ public class VideoUnitResource { private final AuthorizationCheckService authorizationCheckService; - private final CompetencyProgressService competencyProgressService; + private final CompetencyProgressApi competencyProgressApi; private final LectureUnitService lectureUnitService; public VideoUnitResource(LectureRepository lectureRepository, AuthorizationCheckService authorizationCheckService, VideoUnitRepository videoUnitRepository, - CompetencyProgressService competencyProgressService, LectureUnitService lectureUnitService) { + CompetencyProgressApi competencyProgressApi, LectureUnitService lectureUnitService) { this.lectureRepository = lectureRepository; this.authorizationCheckService = authorizationCheckService; this.videoUnitRepository = videoUnitRepository; - this.competencyProgressService = competencyProgressService; + this.competencyProgressApi = competencyProgressApi; this.lectureUnitService = lectureUnitService; } @@ -99,7 +99,7 @@ public ResponseEntity updateVideoUnit(@PathVariable Long lectureId, @ VideoUnit result = lectureUnitService.saveWithCompetencyLinks(videoUnit, videoUnitRepository::save); - competencyProgressService.updateProgressForUpdatedLearningObjectAsync(existingVideoUnit, Optional.of(videoUnit)); + competencyProgressApi.updateProgressForUpdatedLearningObjectAsync(existingVideoUnit, Optional.of(videoUnit)); return ResponseEntity.ok(result); } @@ -139,7 +139,7 @@ public ResponseEntity createVideoUnit(@PathVariable Long lectureId, @ Lecture updatedLecture = lectureRepository.save(lecture); VideoUnit persistedVideoUnit = (VideoUnit) updatedLecture.getLectureUnits().getLast(); - competencyProgressService.updateProgressByLearningObjectAsync(persistedVideoUnit); + competencyProgressApi.updateProgressByLearningObjectAsync(persistedVideoUnit); lectureUnitService.disconnectCompetencyLectureUnitLinks(persistedVideoUnit); return ResponseEntity.created(new URI("/api/video-units/" + persistedVideoUnit.getId())).body(persistedVideoUnit); diff --git a/src/main/java/de/tum/cit/aet/artemis/modeling/service/ModelingExerciseImportService.java b/src/main/java/de/tum/cit/aet/artemis/modeling/service/ModelingExerciseImportService.java index 3c877ce69465..c418596c3a49 100644 --- a/src/main/java/de/tum/cit/aet/artemis/modeling/service/ModelingExerciseImportService.java +++ b/src/main/java/de/tum/cit/aet/artemis/modeling/service/ModelingExerciseImportService.java @@ -21,7 +21,7 @@ import de.tum.cit.aet.artemis.assessment.repository.ExampleSubmissionRepository; import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; import de.tum.cit.aet.artemis.assessment.service.FeedbackService; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; import de.tum.cit.aet.artemis.communication.service.conversation.ChannelService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.Submission; @@ -42,17 +42,17 @@ public class ModelingExerciseImportService extends ExerciseImportService { private final ChannelService channelService; - private final CompetencyProgressService competencyProgressService; + private final CompetencyProgressApi competencyProgressApi; private final ExerciseService exerciseService; public ModelingExerciseImportService(ModelingExerciseRepository modelingExerciseRepository, ExampleSubmissionRepository exampleSubmissionRepository, SubmissionRepository submissionRepository, ResultRepository resultRepository, ChannelService channelService, FeedbackService feedbackService, - CompetencyProgressService competencyProgressService, ExerciseService exerciseService) { + CompetencyProgressApi competencyProgressApi, ExerciseService exerciseService) { super(exampleSubmissionRepository, submissionRepository, resultRepository, feedbackService); this.modelingExerciseRepository = modelingExerciseRepository; this.channelService = channelService; - this.competencyProgressService = competencyProgressService; + this.competencyProgressApi = competencyProgressApi; this.exerciseService = exerciseService; } @@ -77,7 +77,7 @@ public ModelingExercise importModelingExercise(ModelingExercise templateExercise channelService.createExerciseChannel(newModelingExercise, Optional.ofNullable(importedExercise.getChannelName())); newModelingExercise.setExampleSubmissions(copyExampleSubmission(templateExercise, newExercise, gradingInstructionCopyTracker)); - competencyProgressService.updateProgressByLearningObjectAsync(newModelingExercise); + competencyProgressApi.updateProgressByLearningObjectAsync(newModelingExercise); return newModelingExercise; } diff --git a/src/main/java/de/tum/cit/aet/artemis/modeling/web/ModelingExerciseResource.java b/src/main/java/de/tum/cit/aet/artemis/modeling/web/ModelingExerciseResource.java index a2739ed28c76..899e16a32127 100644 --- a/src/main/java/de/tum/cit/aet/artemis/modeling/web/ModelingExerciseResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/modeling/web/ModelingExerciseResource.java @@ -29,7 +29,7 @@ import de.tum.cit.aet.artemis.assessment.domain.GradingCriterion; import de.tum.cit.aet.artemis.assessment.repository.GradingCriterionRepository; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; import de.tum.cit.aet.artemis.communication.domain.conversation.Channel; import de.tum.cit.aet.artemis.communication.repository.conversation.ChannelRepository; import de.tum.cit.aet.artemis.communication.service.conversation.ChannelService; @@ -81,7 +81,7 @@ public class ModelingExerciseResource { private static final String ENTITY_NAME = "modelingExercise"; - private final CompetencyProgressService competencyProgressService; + private final CompetencyProgressApi competencyProgressApi; @Value("${jhipster.clientApp.name}") private String applicationName; @@ -126,7 +126,7 @@ public ModelingExerciseResource(ModelingExerciseRepository modelingExerciseRepos ModelingExerciseImportService modelingExerciseImportService, SubmissionExportService modelingSubmissionExportService, ExerciseService exerciseService, GroupNotificationScheduleService groupNotificationScheduleService, GradingCriterionRepository gradingCriterionRepository, PlagiarismDetectionService plagiarismDetectionService, ChannelService channelService, ChannelRepository channelRepository, - CompetencyProgressService competencyProgressService) { + CompetencyProgressApi competencyProgressApi) { this.modelingExerciseRepository = modelingExerciseRepository; this.courseService = courseService; this.modelingExerciseService = modelingExerciseService; @@ -144,7 +144,7 @@ public ModelingExerciseResource(ModelingExerciseRepository modelingExerciseRepos this.plagiarismDetectionService = plagiarismDetectionService; this.channelService = channelService; this.channelRepository = channelRepository; - this.competencyProgressService = competencyProgressService; + this.competencyProgressApi = competencyProgressApi; } // TODO: most of these calls should be done in the context of a course @@ -182,7 +182,7 @@ public ResponseEntity createModelingExercise(@RequestBody Mode channelService.createExerciseChannel(result, Optional.ofNullable(modelingExercise.getChannelName())); modelingExerciseService.scheduleOperations(result.getId()); groupNotificationScheduleService.checkNotificationsForNewExerciseAsync(modelingExercise); - competencyProgressService.updateProgressByLearningObjectAsync(result); + competencyProgressApi.updateProgressByLearningObjectAsync(result); return ResponseEntity.created(new URI("/api/modeling-exercises/" + result.getId())).body(result); } @@ -253,7 +253,7 @@ public ResponseEntity updateModelingExercise(@RequestBody Mode exerciseService.notifyAboutExerciseChanges(modelingExerciseBeforeUpdate, updatedModelingExercise, notificationText); - competencyProgressService.updateProgressForUpdatedLearningObjectAsync(modelingExerciseBeforeUpdate, Optional.of(modelingExercise)); + competencyProgressApi.updateProgressForUpdatedLearningObjectAsync(modelingExerciseBeforeUpdate, Optional.of(modelingExercise)); return ResponseEntity.ok(updatedModelingExercise); } diff --git a/src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseService.java b/src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseService.java index 65a12b87be77..20b546ad4a48 100644 --- a/src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseService.java +++ b/src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseService.java @@ -45,7 +45,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; import de.tum.cit.aet.artemis.communication.service.conversation.ChannelService; import de.tum.cit.aet.artemis.communication.service.notifications.GroupNotificationScheduleService; import de.tum.cit.aet.artemis.core.domain.Course; @@ -183,7 +183,7 @@ public class ProgrammingExerciseService { private final ExerciseService exerciseService; - private final CompetencyProgressService competencyProgressService; + private final CompetencyProgressApi competencyProgressApi; public ProgrammingExerciseService(ProgrammingExerciseRepository programmingExerciseRepository, GitService gitService, Optional versionControlService, Optional continuousIntegrationService, Optional continuousIntegrationTriggerService, @@ -199,7 +199,7 @@ public ProgrammingExerciseService(ProgrammingExerciseRepository programmingExerc ProgrammingSubmissionService programmingSubmissionService, Optional irisSettingsService, Optional aeolusTemplateService, Optional buildScriptGenerationService, ProgrammingExerciseStudentParticipationRepository programmingExerciseStudentParticipationRepository, ProfileService profileService, ExerciseService exerciseService, - ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository, CompetencyProgressService competencyProgressService) { + ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository, CompetencyProgressApi competencyProgressApi) { this.programmingExerciseRepository = programmingExerciseRepository; this.gitService = gitService; this.versionControlService = versionControlService; @@ -232,7 +232,7 @@ public ProgrammingExerciseService(ProgrammingExerciseRepository programmingExerc this.profileService = profileService; this.exerciseService = exerciseService; this.programmingExerciseBuildConfigRepository = programmingExerciseBuildConfigRepository; - this.competencyProgressService = competencyProgressService; + this.competencyProgressApi = competencyProgressApi; } /** @@ -339,7 +339,7 @@ public ProgrammingExercise createProgrammingExercise(ProgrammingExercise program // Step 12c: Check notifications for new exercise groupNotificationScheduleService.checkNotificationsForNewExerciseAsync(savedProgrammingExercise); // Step 12d: Update student competency progress - competencyProgressService.updateProgressByLearningObjectAsync(savedProgrammingExercise); + competencyProgressApi.updateProgressByLearningObjectAsync(savedProgrammingExercise); // Step 13: Set Iris settings if (irisSettingsService.isPresent()) { @@ -627,7 +627,7 @@ public ProgrammingExercise updateProgrammingExercise(ProgrammingExercise program exerciseService.notifyAboutExerciseChanges(programmingExerciseBeforeUpdate, updatedProgrammingExercise, notificationText); - competencyProgressService.updateProgressForUpdatedLearningObjectAsync(programmingExerciseBeforeUpdate, Optional.of(updatedProgrammingExercise)); + competencyProgressApi.updateProgressForUpdatedLearningObjectAsync(programmingExerciseBeforeUpdate, Optional.of(updatedProgrammingExercise)); irisSettingsService .ifPresent(settingsService -> settingsService.setEnabledForExerciseByCategories(savedProgrammingExercise, programmingExerciseBeforeUpdate.getCategories())); diff --git a/src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseExportImportResource.java b/src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseExportImportResource.java index 1659956ac1f8..748645568dc6 100644 --- a/src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseExportImportResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/programming/web/ProgrammingExerciseExportImportResource.java @@ -42,7 +42,7 @@ import de.tum.cit.aet.artemis.assessment.domain.Visibility; import de.tum.cit.aet.artemis.athena.service.AthenaModuleService; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.dto.RepositoryExportOptionsDTO; @@ -95,7 +95,7 @@ public class ProgrammingExerciseExportImportResource { private static final String ENTITY_NAME = "programmingExercise"; - private final CompetencyProgressService competencyProgressService; + private final CompetencyProgressApi competencyProgressApi; @Value("${jhipster.clientApp.name}") private String applicationName; @@ -136,7 +136,7 @@ public ProgrammingExerciseExportImportResource(ProgrammingExerciseRepository pro AuxiliaryRepositoryRepository auxiliaryRepositoryRepository, SubmissionPolicyService submissionPolicyService, ProgrammingExerciseTaskRepository programmingExerciseTaskRepository, ExamAccessService examAccessService, CourseRepository courseRepository, ProgrammingExerciseImportFromFileService programmingExerciseImportFromFileService, ConsistencyCheckService consistencyCheckService, - Optional athenaModuleService, CompetencyProgressService competencyProgressService) { + Optional athenaModuleService, CompetencyProgressApi competencyProgressApi) { this.programmingExerciseRepository = programmingExerciseRepository; this.userRepository = userRepository; this.courseService = courseService; @@ -152,7 +152,7 @@ public ProgrammingExerciseExportImportResource(ProgrammingExerciseRepository pro this.programmingExerciseImportFromFileService = programmingExerciseImportFromFileService; this.consistencyCheckService = consistencyCheckService; this.athenaModuleService = athenaModuleService; - this.competencyProgressService = competencyProgressService; + this.competencyProgressApi = competencyProgressApi; } /** @@ -259,7 +259,7 @@ public ResponseEntity importProgrammingExercise(@PathVariab importedProgrammingExercise.setExerciseHints(null); importedProgrammingExercise.setTasks(null); - competencyProgressService.updateProgressByLearningObjectAsync(importedProgrammingExercise); + competencyProgressApi.updateProgressByLearningObjectAsync(importedProgrammingExercise); return ResponseEntity.ok().headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, importedProgrammingExercise.getTitle())) .body(importedProgrammingExercise); diff --git a/src/main/java/de/tum/cit/aet/artemis/quiz/service/QuizExerciseImportService.java b/src/main/java/de/tum/cit/aet/artemis/quiz/service/QuizExerciseImportService.java index 1b26865c641b..b76d15598f91 100644 --- a/src/main/java/de/tum/cit/aet/artemis/quiz/service/QuizExerciseImportService.java +++ b/src/main/java/de/tum/cit/aet/artemis/quiz/service/QuizExerciseImportService.java @@ -24,7 +24,7 @@ import de.tum.cit.aet.artemis.assessment.repository.ExampleSubmissionRepository; import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; import de.tum.cit.aet.artemis.assessment.service.FeedbackService; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; import de.tum.cit.aet.artemis.communication.service.conversation.ChannelService; import de.tum.cit.aet.artemis.core.service.FilePathService; import de.tum.cit.aet.artemis.core.service.FileService; @@ -56,16 +56,16 @@ public class QuizExerciseImportService extends ExerciseImportService { private final ChannelService channelService; - private final CompetencyProgressService competencyProgressService; + private final CompetencyProgressApi competencyProgressApi; public QuizExerciseImportService(QuizExerciseService quizExerciseService, FileService fileService, ExampleSubmissionRepository exampleSubmissionRepository, SubmissionRepository submissionRepository, ResultRepository resultRepository, ChannelService channelService, FeedbackService feedbackService, - CompetencyProgressService competencyProgressService) { + CompetencyProgressApi competencyProgressApi) { super(exampleSubmissionRepository, submissionRepository, resultRepository, feedbackService); this.quizExerciseService = quizExerciseService; this.fileService = fileService; this.channelService = channelService; - this.competencyProgressService = competencyProgressService; + this.competencyProgressApi = competencyProgressApi; } /** @@ -90,7 +90,7 @@ public QuizExercise importQuizExercise(final QuizExercise templateExercise, Quiz channelService.createExerciseChannel(newQuizExercise, Optional.ofNullable(importedExercise.getChannelName())); - competencyProgressService.updateProgressByLearningObjectAsync(newQuizExercise); + competencyProgressApi.updateProgressByLearningObjectAsync(newQuizExercise); if (files != null) { newQuizExercise = quizExerciseService.save(quizExerciseService.uploadNewFilesToNewImportedQuiz(newQuizExercise, files)); } diff --git a/src/main/java/de/tum/cit/aet/artemis/quiz/service/QuizExerciseService.java b/src/main/java/de/tum/cit/aet/artemis/quiz/service/QuizExerciseService.java index 274718a9b382..955212be3450 100644 --- a/src/main/java/de/tum/cit/aet/artemis/quiz/service/QuizExerciseService.java +++ b/src/main/java/de/tum/cit/aet/artemis/quiz/service/QuizExerciseService.java @@ -33,7 +33,6 @@ import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; -import de.tum.cit.aet.artemis.atlas.repository.CompetencyExerciseLinkRepository; import de.tum.cit.aet.artemis.core.config.Constants; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.dto.SearchResultPageDTO; @@ -87,12 +86,10 @@ public class QuizExerciseService extends QuizService { private final ExerciseService exerciseService; - private final CompetencyExerciseLinkRepository competencyExerciseLinkRepository; - public QuizExerciseService(QuizExerciseRepository quizExerciseRepository, ResultRepository resultRepository, QuizSubmissionRepository quizSubmissionRepository, InstanceMessageSendService instanceMessageSendService, QuizStatisticService quizStatisticService, QuizBatchService quizBatchService, ExerciseSpecificationService exerciseSpecificationService, FileService fileService, DragAndDropMappingRepository dragAndDropMappingRepository, - ShortAnswerMappingRepository shortAnswerMappingRepository, ExerciseService exerciseService, CompetencyExerciseLinkRepository competencyExerciseLinkRepository) { + ShortAnswerMappingRepository shortAnswerMappingRepository, ExerciseService exerciseService) { super(dragAndDropMappingRepository, shortAnswerMappingRepository); this.quizExerciseRepository = quizExerciseRepository; this.resultRepository = resultRepository; @@ -103,7 +100,6 @@ public QuizExerciseService(QuizExerciseRepository quizExerciseRepository, Result this.exerciseSpecificationService = exerciseSpecificationService; this.fileService = fileService; this.exerciseService = exerciseService; - this.competencyExerciseLinkRepository = competencyExerciseLinkRepository; } /** diff --git a/src/main/java/de/tum/cit/aet/artemis/quiz/web/QuizExerciseResource.java b/src/main/java/de/tum/cit/aet/artemis/quiz/web/QuizExerciseResource.java index d9d276bb3bd4..ecb693e49250 100644 --- a/src/main/java/de/tum/cit/aet/artemis/quiz/web/QuizExerciseResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/quiz/web/QuizExerciseResource.java @@ -38,7 +38,7 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; import de.tum.cit.aet.artemis.communication.domain.conversation.Channel; import de.tum.cit.aet.artemis.communication.repository.conversation.ChannelRepository; import de.tum.cit.aet.artemis.communication.service.conversation.ChannelService; @@ -148,7 +148,7 @@ public class QuizExerciseResource { private final ChannelRepository channelRepository; - private final CompetencyProgressService competencyProgressService; + private final CompetencyProgressApi competencyProgressApi; public QuizExerciseResource(QuizExerciseService quizExerciseService, QuizMessagingService quizMessagingService, QuizExerciseRepository quizExerciseRepository, UserRepository userRepository, CourseService courseService, ExerciseService exerciseService, ExerciseDeletionService exerciseDeletionService, @@ -156,7 +156,7 @@ public QuizExerciseResource(QuizExerciseService quizExerciseService, QuizMessagi QuizExerciseImportService quizExerciseImportService, AuthorizationCheckService authCheckService, GroupNotificationService groupNotificationService, GroupNotificationScheduleService groupNotificationScheduleService, StudentParticipationRepository studentParticipationRepository, QuizBatchService quizBatchService, QuizBatchRepository quizBatchRepository, FileService fileService, ChannelService channelService, ChannelRepository channelRepository, - QuizSubmissionService quizSubmissionService, QuizResultService quizResultService, CompetencyProgressService competencyProgressService) { + QuizSubmissionService quizSubmissionService, QuizResultService quizResultService, CompetencyProgressApi competencyProgressApi) { this.quizExerciseService = quizExerciseService; this.quizMessagingService = quizMessagingService; this.quizExerciseRepository = quizExerciseRepository; @@ -179,7 +179,7 @@ public QuizExerciseResource(QuizExerciseService quizExerciseService, QuizMessagi this.channelRepository = channelRepository; this.quizSubmissionService = quizSubmissionService; this.quizResultService = quizResultService; - this.competencyProgressService = competencyProgressService; + this.competencyProgressApi = competencyProgressApi; } /** @@ -241,7 +241,7 @@ public ResponseEntity createQuizExercise(@RequestPart("exercise") channelService.createExerciseChannel(result, Optional.ofNullable(quizExercise.getChannelName())); - competencyProgressService.updateProgressByLearningObjectAsync(result); + competencyProgressApi.updateProgressByLearningObjectAsync(result); return ResponseEntity.created(new URI("/api/quiz-exercises/" + result.getId())) .headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, result.getId().toString())).body(result); @@ -308,7 +308,7 @@ public ResponseEntity updateQuizExercise(@PathVariable Long exerci if (updatedChannel != null) { quizExercise.setChannelName(updatedChannel.getName()); } - competencyProgressService.updateProgressForUpdatedLearningObjectAsync(originalQuiz, Optional.of(quizExercise)); + competencyProgressApi.updateProgressForUpdatedLearningObjectAsync(originalQuiz, Optional.of(quizExercise)); return ResponseEntity.ok(quizExercise); } diff --git a/src/main/java/de/tum/cit/aet/artemis/text/service/TextExerciseImportService.java b/src/main/java/de/tum/cit/aet/artemis/text/service/TextExerciseImportService.java index 161c6426589b..f45cadcd7ddd 100644 --- a/src/main/java/de/tum/cit/aet/artemis/text/service/TextExerciseImportService.java +++ b/src/main/java/de/tum/cit/aet/artemis/text/service/TextExerciseImportService.java @@ -27,7 +27,7 @@ import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; import de.tum.cit.aet.artemis.assessment.repository.TextBlockRepository; import de.tum.cit.aet.artemis.assessment.service.FeedbackService; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; import de.tum.cit.aet.artemis.communication.service.conversation.ChannelService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.Submission; @@ -57,13 +57,13 @@ public class TextExerciseImportService extends ExerciseImportService { private final ChannelService channelService; - private final CompetencyProgressService competencyProgressService; + private final CompetencyProgressApi competencyProgressApi; private final ExerciseService exerciseService; public TextExerciseImportService(TextExerciseRepository textExerciseRepository, ExampleSubmissionRepository exampleSubmissionRepository, SubmissionRepository submissionRepository, ResultRepository resultRepository, TextBlockRepository textBlockRepository, FeedbackRepository feedbackRepository, - TextSubmissionRepository textSubmissionRepository, ChannelService channelService, FeedbackService feedbackService, CompetencyProgressService competencyProgressService, + TextSubmissionRepository textSubmissionRepository, ChannelService channelService, FeedbackService feedbackService, CompetencyProgressApi competencyProgressApi, ExerciseService exerciseService) { super(exampleSubmissionRepository, submissionRepository, resultRepository, feedbackService); this.textBlockRepository = textBlockRepository; @@ -71,7 +71,7 @@ public TextExerciseImportService(TextExerciseRepository textExerciseRepository, this.feedbackRepository = feedbackRepository; this.textSubmissionRepository = textSubmissionRepository; this.channelService = channelService; - this.competencyProgressService = competencyProgressService; + this.competencyProgressApi = competencyProgressApi; this.exerciseService = exerciseService; } @@ -100,7 +100,7 @@ public TextExercise importTextExercise(final TextExercise templateExercise, Text channelService.createExerciseChannel(newTextExercise, Optional.ofNullable(importedExercise.getChannelName())); newExercise.setExampleSubmissions(copyExampleSubmission(templateExercise, newExercise, gradingInstructionCopyTracker)); - competencyProgressService.updateProgressByLearningObjectAsync(newTextExercise); + competencyProgressApi.updateProgressByLearningObjectAsync(newTextExercise); return newExercise; } diff --git a/src/main/java/de/tum/cit/aet/artemis/text/web/TextExerciseResource.java b/src/main/java/de/tum/cit/aet/artemis/text/web/TextExerciseResource.java index 0040e183e1e8..0b72f23ba0db 100644 --- a/src/main/java/de/tum/cit/aet/artemis/text/web/TextExerciseResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/text/web/TextExerciseResource.java @@ -41,7 +41,7 @@ import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; import de.tum.cit.aet.artemis.assessment.repository.TextBlockRepository; import de.tum.cit.aet.artemis.athena.service.AthenaModuleService; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; import de.tum.cit.aet.artemis.communication.domain.conversation.Channel; import de.tum.cit.aet.artemis.communication.repository.conversation.ChannelRepository; import de.tum.cit.aet.artemis.communication.service.conversation.ChannelService; @@ -154,7 +154,7 @@ public class TextExerciseResource { private final Optional athenaModuleService; - private final CompetencyProgressService competencyProgressService; + private final CompetencyProgressApi competencyProgressApi; private final Optional irisSettingsService; @@ -165,8 +165,8 @@ public TextExerciseResource(TextExerciseRepository textExerciseRepository, TextE TextSubmissionExportService textSubmissionExportService, ExampleSubmissionRepository exampleSubmissionRepository, ExerciseService exerciseService, GradingCriterionRepository gradingCriterionRepository, TextBlockRepository textBlockRepository, GroupNotificationScheduleService groupNotificationScheduleService, InstanceMessageSendService instanceMessageSendService, PlagiarismDetectionService plagiarismDetectionService, CourseRepository courseRepository, - ChannelService channelService, ChannelRepository channelRepository, Optional athenaModuleService, - CompetencyProgressService competencyProgressService, Optional irisSettingsService) { + ChannelService channelService, ChannelRepository channelRepository, Optional athenaModuleService, CompetencyProgressApi competencyProgressApi, + Optional irisSettingsService) { this.feedbackRepository = feedbackRepository; this.exerciseDeletionService = exerciseDeletionService; this.plagiarismResultRepository = plagiarismResultRepository; @@ -191,7 +191,7 @@ public TextExerciseResource(TextExerciseRepository textExerciseRepository, TextE this.channelService = channelService; this.channelRepository = channelRepository; this.athenaModuleService = athenaModuleService; - this.competencyProgressService = competencyProgressService; + this.competencyProgressApi = competencyProgressApi; this.irisSettingsService = irisSettingsService; } @@ -232,7 +232,7 @@ public ResponseEntity createTextExercise(@RequestBody TextExercise channelService.createExerciseChannel(result, Optional.ofNullable(textExercise.getChannelName())); instanceMessageSendService.sendTextExerciseSchedule(result.getId()); groupNotificationScheduleService.checkNotificationsForNewExerciseAsync(textExercise); - competencyProgressService.updateProgressByLearningObjectAsync(result); + competencyProgressApi.updateProgressByLearningObjectAsync(result); irisSettingsService.ifPresent(iss -> iss.setEnabledForExerciseByCategories(result, new HashSet<>())); @@ -294,7 +294,7 @@ public ResponseEntity updateTextExercise(@RequestBody TextExercise exerciseService.checkExampleSubmissions(updatedTextExercise); exerciseService.notifyAboutExerciseChanges(textExerciseBeforeUpdate, updatedTextExercise, notificationText); - competencyProgressService.updateProgressForUpdatedLearningObjectAsync(textExerciseBeforeUpdate, Optional.of(textExercise)); + competencyProgressApi.updateProgressForUpdatedLearningObjectAsync(textExerciseBeforeUpdate, Optional.of(textExercise)); irisSettingsService.ifPresent(iss -> iss.setEnabledForExerciseByCategories(textExercise, textExerciseBeforeUpdate.getCategories())); From 5ce31171dce09c98d83ac9b650cca3bff2dbac46 Mon Sep 17 00:00:00 2001 From: Ole Vester Date: Tue, 12 Nov 2024 11:12:46 +0100 Subject: [PATCH 05/11] Add arch tests to verify external modules not using services or repositories --- .../AtlasApiArchitectureTest.java | 11 +++ .../AbstractModuleAccessArchitectureTest.java | 67 +++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 src/test/java/de/tum/cit/aet/artemis/atlas/architecture/AtlasApiArchitectureTest.java create mode 100644 src/test/java/de/tum/cit/aet/artemis/shared/architecture/module/AbstractModuleAccessArchitectureTest.java diff --git a/src/test/java/de/tum/cit/aet/artemis/atlas/architecture/AtlasApiArchitectureTest.java b/src/test/java/de/tum/cit/aet/artemis/atlas/architecture/AtlasApiArchitectureTest.java new file mode 100644 index 000000000000..d35694be19b7 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/architecture/AtlasApiArchitectureTest.java @@ -0,0 +1,11 @@ +package de.tum.cit.aet.artemis.atlas.architecture; + +import de.tum.cit.aet.artemis.shared.architecture.module.AbstractModuleAccessArchitectureTest; + +class AtlasApiArchitectureTest extends AbstractModuleAccessArchitectureTest { + + @Override + public String getModulePackage() { + return ARTEMIS_PACKAGE + ".atlas"; + } +} diff --git a/src/test/java/de/tum/cit/aet/artemis/shared/architecture/module/AbstractModuleAccessArchitectureTest.java b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/module/AbstractModuleAccessArchitectureTest.java new file mode 100644 index 000000000000..dc3b274f146e --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/module/AbstractModuleAccessArchitectureTest.java @@ -0,0 +1,67 @@ +package de.tum.cit.aet.artemis.shared.architecture.module; + +import static com.tngtech.archunit.core.domain.JavaClass.Predicates.resideInAPackage; +import static com.tngtech.archunit.core.domain.JavaClass.Predicates.resideOutsideOfPackages; +import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes; +import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; + +import org.junit.jupiter.api.Test; +import org.springframework.stereotype.Controller; + +import com.tngtech.archunit.core.domain.JavaClass; +import com.tngtech.archunit.core.domain.JavaModifier; +import com.tngtech.archunit.lang.ArchCondition; +import com.tngtech.archunit.lang.ConditionEvents; +import com.tngtech.archunit.lang.SimpleConditionEvent; + +import de.tum.cit.aet.artemis.core.api.AbstractApi; +import de.tum.cit.aet.artemis.shared.architecture.AbstractArchitectureTest; + +public abstract class AbstractModuleAccessArchitectureTest extends AbstractArchitectureTest implements ModuleArchitectureTest { + + @Test + void shouldOnlyAccessApiDomainDto() { + noClasses().that().resideOutsideOfPackage(getModuleWithSubpackage()).should() + .dependOnClassesThat( + resideInAPackage(getModuleWithSubpackage()).and(resideOutsideOfPackages(getModuleApiSubpackage(), getModuleDomainSubpackage(), getModuleDtoSubpackage()))) + .check(productionClasses); + } + + @Test + void apiClassesShouldInheritFromAbstractApi() { + classes().that().resideInAPackage(getModuleApiSubpackage()).should().beAssignableTo(AbstractApi.class).check(productionClasses); + } + + @Test + void apiClassesShouldBeAbstractOrAnnotatedWithController() { + classes().that().resideInAPackage(getModuleApiSubpackage()).should(beAbstractOrAnnotatedWithController()).check(productionClasses); + } + + protected String getModuleApiSubpackage() { + return getModulePackage() + ".api.."; + } + + protected String getModuleDomainSubpackage() { + return getModulePackage() + ".domain.."; + } + + protected String getModuleDtoSubpackage() { + return getModulePackage() + ".dto.."; + } + + private static ArchCondition beAbstractOrAnnotatedWithController() { + return new ArchCondition<>("be abstract or annotated with @Controller") { + + @Override + public void check(JavaClass javaClass, ConditionEvents events) { + boolean isAbstract = javaClass.getModifiers().contains(JavaModifier.ABSTRACT); + boolean isAnnotatedWithController = javaClass.isAnnotatedWith(Controller.class); + + if (!isAbstract && !isAnnotatedWithController) { + String message = String.format("Class %s is neither abstract nor annotated with @Controller", javaClass.getName()); + events.add(SimpleConditionEvent.violated(javaClass, message)); + } + } + }; + } +} From e10de314901db41020309deb0e2e749ca232217d Mon Sep 17 00:00:00 2001 From: Ole Vester Date: Tue, 12 Nov 2024 11:14:09 +0100 Subject: [PATCH 06/11] Create SpyBean of CompetencyProgressApi and use for verification in module-external tests --- .../fileupload/FileUploadExerciseIntegrationTest.java | 6 +++--- .../artemis/lecture/AttachmentUnitIntegrationTest.java | 6 +++--- .../aet/artemis/lecture/ExerciseUnitIntegrationTest.java | 2 +- .../cit/aet/artemis/lecture/LectureIntegrationTest.java | 2 +- .../aet/artemis/lecture/OnlineUnitIntegrationTest.java | 6 +++--- .../cit/aet/artemis/lecture/TextUnitIntegrationTest.java | 6 +++--- .../cit/aet/artemis/lecture/VideoUnitIntegrationTest.java | 6 +++--- .../artemis/modeling/ModelingExerciseIntegrationTest.java | 7 +++---- .../ProgrammingExerciseLocalVCLocalCIIntegrationTest.java | 8 ++++---- .../shared/base/AbstractArtemisIntegrationTest.java | 7 ++++++- .../cit/aet/artemis/text/TextExerciseIntegrationTest.java | 6 +++--- 11 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadExerciseIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadExerciseIntegrationTest.java index 1c6476a486e4..7dfe79d270b1 100644 --- a/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadExerciseIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadExerciseIntegrationTest.java @@ -332,7 +332,7 @@ void testDeleteFileUploadExerciseWithCompetency() throws Exception { competencyExerciseLinkRepository.save(new CompetencyExerciseLink(competency, fileUploadExercise, 1)); request.delete("/api/file-upload-exercises/" + fileUploadExercise.getId(), HttpStatus.OK); - verify(competencyProgressService).updateProgressByCompetencyAsync(eq(competency)); + verify(competencyProgressApi).updateProgressByCompetencyAsync(eq(competency)); } @Test @@ -391,7 +391,7 @@ void updateFileUploadExercise_asInstructor() throws Exception { assertThat(receivedFileUploadExercise.getCourseViaExerciseGroupOrCourseMember().getId()).as("courseId was not updated").isEqualTo(course.getId()); verify(examLiveEventsService, never()).createAndSendProblemStatementUpdateEvent(any(), any(), any()); verify(groupNotificationScheduleService, times(1)).checkAndCreateAppropriateNotificationsWhenUpdatingExercise(any(), any(), any()); - verify(competencyProgressService, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(fileUploadExercise), eq(Optional.of(fileUploadExercise))); + verify(competencyProgressApi, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(fileUploadExercise), eq(Optional.of(fileUploadExercise))); } @Test @@ -691,7 +691,7 @@ void testImportFileUploadExerciseFromCourseToCourseAsEditorSuccess() throws Exce Channel channelFromDB = channelRepository.findChannelByExerciseId(importedFileUploadExercise.getId()); assertThat(channelFromDB).isNotNull(); assertThat(channelFromDB.getName()).isEqualTo(uniqueChannelName); - verify(competencyProgressService).updateProgressByLearningObjectAsync(eq(importedFileUploadExercise)); + verify(competencyProgressApi).updateProgressByLearningObjectAsync(eq(importedFileUploadExercise)); } @Test diff --git a/src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentUnitIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentUnitIntegrationTest.java index d127e1d40db4..7d2287eaa610 100644 --- a/src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentUnitIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentUnitIntegrationTest.java @@ -232,7 +232,7 @@ void createAttachmentUnit_asInstructor_shouldCreateAttachmentUnit() throws Excep assertThat(updatedAttachmentUnit.getAttachment()).isEqualTo(persistedAttachment); assertThat(updatedAttachmentUnit.getAttachment().getName()).isEqualTo("LoremIpsum"); assertThat(updatedAttachmentUnit.getCompetencyLinks()).anyMatch(link -> link.getCompetency().getId().equals(competency.getId())); - verify(competencyProgressService).updateProgressByLearningObjectAsync(eq(updatedAttachmentUnit)); + verify(competencyProgressApi).updateProgressByLearningObjectAsync(eq(updatedAttachmentUnit)); } @Test @@ -278,7 +278,7 @@ void updateAttachmentUnit_asInstructor_shouldUpdateAttachmentUnit() throws Excep attachment = attachmentRepository.findById(attachment.getId()).orElseThrow(); assertThat(attachmentUnit2.getAttachment()).isEqualTo(attachment); assertThat(attachment.getAttachmentUnit()).isEqualTo(attachmentUnit2); - verify(competencyProgressService, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(attachmentUnit), eq(Optional.of(attachmentUnit))); + verify(competencyProgressApi, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(attachmentUnit), eq(Optional.of(attachmentUnit))); } @Test @@ -354,6 +354,6 @@ void deleteAttachmentUnit_withAttachment_shouldDeleteAttachment() throws Excepti assertThat(slideRepository.findAllByAttachmentUnitId(persistedAttachmentUnit.getId())).hasSize(0); request.delete("/api/lectures/" + lecture1.getId() + "/lecture-units/" + persistedAttachmentUnit.getId(), HttpStatus.OK); request.get("/api/lectures/" + lecture1.getId() + "/attachment-units/" + persistedAttachmentUnit.getId(), HttpStatus.NOT_FOUND, AttachmentUnit.class); - verify(competencyProgressService, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(persistedAttachmentUnit), eq(Optional.empty())); + verify(competencyProgressApi, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(persistedAttachmentUnit), eq(Optional.empty())); } } diff --git a/src/test/java/de/tum/cit/aet/artemis/lecture/ExerciseUnitIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/lecture/ExerciseUnitIntegrationTest.java index 18ffb227b586..e1e9a8e57c4e 100644 --- a/src/test/java/de/tum/cit/aet/artemis/lecture/ExerciseUnitIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/ExerciseUnitIntegrationTest.java @@ -214,7 +214,7 @@ void deleteExerciseUnit_exerciseConnectedWithExerciseUnit_shouldNOTDeleteExercis request.get("/api/exercises/" + exercise.getId(), HttpStatus.OK, Exercise.class); } - verify(competencyProgressService, never()).updateProgressForUpdatedLearningObjectAsync(any(), any()); + verify(competencyProgressApi, never()).updateProgressForUpdatedLearningObjectAsync(any(), any()); } } diff --git a/src/test/java/de/tum/cit/aet/artemis/lecture/LectureIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/lecture/LectureIntegrationTest.java index 75587b96f77d..a754d92015d6 100644 --- a/src/test/java/de/tum/cit/aet/artemis/lecture/LectureIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/LectureIntegrationTest.java @@ -366,7 +366,7 @@ void deleteLecture_lectureExists_shouldDeleteLecture() throws Exception { assertThat(lectureOptional).isEmpty(); // ExerciseUnits do not have competencies, their exercises do - verify(competencyProgressService, timeout(1000).times(lecture1.getLectureUnits().size() - 1)).updateProgressForUpdatedLearningObjectAsync(any(), eq(Optional.empty())); + verify(competencyProgressApi, timeout(1000).times(lecture1.getLectureUnits().size() - 1)).updateProgressForUpdatedLearningObjectAsync(any(), eq(Optional.empty())); } @Test diff --git a/src/test/java/de/tum/cit/aet/artemis/lecture/OnlineUnitIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/lecture/OnlineUnitIntegrationTest.java index 53f7c139f6d9..952bcd219def 100644 --- a/src/test/java/de/tum/cit/aet/artemis/lecture/OnlineUnitIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/OnlineUnitIntegrationTest.java @@ -113,7 +113,7 @@ void createOnlineUnit_asInstructor_shouldCreateOnlineUnit() throws Exception { onlineUnit.setSource("https://www.youtube.com/embed/8iU8LPEa4o0"); var persistedOnlineUnit = request.postWithResponseBody("/api/lectures/" + this.lecture1.getId() + "/online-units", onlineUnit, OnlineUnit.class, HttpStatus.CREATED); assertThat(persistedOnlineUnit.getId()).isNotNull(); - verify(competencyProgressService).updateProgressByLearningObjectAsync(eq(persistedOnlineUnit)); + verify(competencyProgressApi).updateProgressByLearningObjectAsync(eq(persistedOnlineUnit)); } @Test @@ -148,7 +148,7 @@ void updateOnlineUnit_asInstructor_shouldUpdateOnlineUnit() throws Exception { this.onlineUnit.setDescription("Changed"); this.onlineUnit = request.putWithResponseBody("/api/lectures/" + lecture1.getId() + "/online-units", this.onlineUnit, OnlineUnit.class, HttpStatus.OK); assertThat(this.onlineUnit.getDescription()).isEqualTo("Changed"); - verify(competencyProgressService, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(onlineUnit), eq(Optional.of(onlineUnit))); + verify(competencyProgressApi, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(onlineUnit), eq(Optional.of(onlineUnit))); } @Test @@ -269,7 +269,7 @@ void deleteOnlineUnit_correctId_shouldDeleteOnlineUnit() throws Exception { assertThat(this.onlineUnit.getId()).isNotNull(); request.delete("/api/lectures/" + lecture1.getId() + "/lecture-units/" + this.onlineUnit.getId(), HttpStatus.OK); request.get("/api/lectures/" + lecture1.getId() + "/online-units/" + this.onlineUnit.getId(), HttpStatus.NOT_FOUND, OnlineUnit.class); - verify(competencyProgressService, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(onlineUnit), eq(Optional.empty())); + verify(competencyProgressApi, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(onlineUnit), eq(Optional.empty())); } } diff --git a/src/test/java/de/tum/cit/aet/artemis/lecture/TextUnitIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/lecture/TextUnitIntegrationTest.java index 0493cd108136..1d3082359dc5 100644 --- a/src/test/java/de/tum/cit/aet/artemis/lecture/TextUnitIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/TextUnitIntegrationTest.java @@ -90,7 +90,7 @@ void createTextUnit_asEditor_shouldCreateTextUnitUnit() throws Exception { var persistedTextUnit = request.postWithResponseBody("/api/lectures/" + this.lecture.getId() + "/text-units", textUnit, TextUnit.class, HttpStatus.CREATED); assertThat(persistedTextUnit.getId()).isNotNull(); assertThat(persistedTextUnit.getName()).isEqualTo("LoremIpsum"); - verify(competencyProgressService).updateProgressByLearningObjectAsync(eq(persistedTextUnit)); + verify(competencyProgressApi).updateProgressByLearningObjectAsync(eq(persistedTextUnit)); } @Test @@ -112,7 +112,7 @@ void updateTextUnit_asEditor_shouldUpdateTextUnit() throws Exception { textUnit.setContent("Changed"); TextUnit updatedTextUnit = request.putWithResponseBody("/api/lectures/" + lecture.getId() + "/text-units", textUnit, TextUnit.class, HttpStatus.OK); assertThat(updatedTextUnit.getContent()).isEqualTo("Changed"); - verify(competencyProgressService, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(textUnit), eq(Optional.of(textUnit))); + verify(competencyProgressApi, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(textUnit), eq(Optional.of(textUnit))); } @Test @@ -161,7 +161,7 @@ void deleteTextUnit_correctId_shouldDeleteTextUnit() throws Exception { assertThat(this.textUnit.getId()).isNotNull(); request.delete("/api/lectures/" + lecture.getId() + "/lecture-units/" + this.textUnit.getId(), HttpStatus.OK); request.get("/api/lectures/" + lecture.getId() + "/text-units/" + this.textUnit.getId(), HttpStatus.NOT_FOUND, TextUnit.class); - verify(competencyProgressService, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(textUnit), eq(Optional.empty())); + verify(competencyProgressApi, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(textUnit), eq(Optional.empty())); } private void persistTextUnitWithLecture() { diff --git a/src/test/java/de/tum/cit/aet/artemis/lecture/VideoUnitIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/lecture/VideoUnitIntegrationTest.java index 2c43ed5c8106..8ef389dfd672 100644 --- a/src/test/java/de/tum/cit/aet/artemis/lecture/VideoUnitIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/VideoUnitIntegrationTest.java @@ -90,7 +90,7 @@ void createVideoUnit_asInstructor_shouldCreateVideoUnit() throws Exception { videoUnit.setCompetencyLinks(Set.of(new CompetencyLectureUnitLink(competency, videoUnit, 1))); var persistedVideoUnit = request.postWithResponseBody("/api/lectures/" + this.lecture1.getId() + "/video-units", videoUnit, VideoUnit.class, HttpStatus.CREATED); assertThat(persistedVideoUnit.getId()).isNotNull(); - verify(competencyProgressService).updateProgressByLearningObjectAsync(eq(persistedVideoUnit)); + verify(competencyProgressApi).updateProgressByLearningObjectAsync(eq(persistedVideoUnit)); } @Test @@ -125,7 +125,7 @@ void updateVideoUnit_asInstructor_shouldUpdateVideoUnit() throws Exception { this.videoUnit.setDescription("Changed"); this.videoUnit = request.putWithResponseBody("/api/lectures/" + lecture1.getId() + "/video-units", this.videoUnit, VideoUnit.class, HttpStatus.OK); assertThat(this.videoUnit.getDescription()).isEqualTo("Changed"); - verify(competencyProgressService, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(videoUnit), eq(Optional.of(videoUnit))); + verify(competencyProgressApi, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(videoUnit), eq(Optional.of(videoUnit))); } @Test @@ -209,7 +209,7 @@ void deleteVideoUnit_correctId_shouldDeleteVideoUnit() throws Exception { assertThat(this.videoUnit.getId()).isNotNull(); request.delete("/api/lectures/" + lecture1.getId() + "/lecture-units/" + this.videoUnit.getId(), HttpStatus.OK); request.get("/api/lectures/" + lecture1.getId() + "/video-units/" + this.videoUnit.getId(), HttpStatus.NOT_FOUND, VideoUnit.class); - verify(competencyProgressService, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(videoUnit), eq(Optional.empty())); + verify(competencyProgressApi, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(videoUnit), eq(Optional.empty())); } @Test diff --git a/src/test/java/de/tum/cit/aet/artemis/modeling/ModelingExerciseIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/ModelingExerciseIntegrationTest.java index 6732ee7c6a2d..2891ce7dc87f 100644 --- a/src/test/java/de/tum/cit/aet/artemis/modeling/ModelingExerciseIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/ModelingExerciseIntegrationTest.java @@ -242,8 +242,7 @@ void testUpdateModelingExercise_asInstructor() throws Exception { assertThat(returnedModelingExercise.getGradingCriteria()).hasSameSizeAs(gradingCriteria); verify(groupNotificationService).notifyStudentAndEditorAndInstructorGroupAboutExerciseUpdate(returnedModelingExercise, notificationText); verify(examLiveEventsService, never()).createAndSendProblemStatementUpdateEvent(eq(returnedModelingExercise), eq(notificationText), any()); - verify(competencyProgressService, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(createdModelingExercise), - eq(Optional.of(createdModelingExercise))); + verify(competencyProgressApi, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(createdModelingExercise), eq(Optional.of(createdModelingExercise))); } @Test @@ -414,7 +413,7 @@ void testDeleteModelingExerciseWithCompetency() throws Exception { request.delete("/api/modeling-exercises/" + classExercise.getId(), HttpStatus.OK); - verify(competencyProgressService).updateProgressByCompetencyAsync(eq(competency)); + verify(competencyProgressApi).updateProgressByCompetencyAsync(eq(competency)); } @Test @@ -485,7 +484,7 @@ void importModelingExerciseFromCourseToCourse() throws Exception { Channel channelFromDB = channelRepository.findChannelByExerciseId(importedExercise.getId()); assertThat(channelFromDB).isNotNull(); assertThat(channelFromDB.getName()).isEqualTo(uniqueChannelName); - verify(competencyProgressService).updateProgressByLearningObjectAsync(eq(importedExercise)); + verify(competencyProgressApi).updateProgressByLearningObjectAsync(eq(importedExercise)); } @Test diff --git a/src/test/java/de/tum/cit/aet/artemis/programming/icl/ProgrammingExerciseLocalVCLocalCIIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/icl/ProgrammingExerciseLocalVCLocalCIIntegrationTest.java index 211d1e9ce30f..fdc6a876eb7d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/programming/icl/ProgrammingExerciseLocalVCLocalCIIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/icl/ProgrammingExerciseLocalVCLocalCIIntegrationTest.java @@ -176,7 +176,7 @@ void testCreateProgrammingExercise() throws Exception { localVCLocalCITestService.testLatestSubmission(createdExercise.getTemplateParticipation().getId(), null, 0, false); localVCLocalCITestService.testLatestSubmission(createdExercise.getSolutionParticipation().getId(), null, 13, false); - verify(competencyProgressService).updateProgressByLearningObjectAsync(eq(createdExercise)); + verify(competencyProgressApi).updateProgressByLearningObjectAsync(eq(createdExercise)); } @Test @@ -202,7 +202,7 @@ void testUpdateProgrammingExercise() throws Exception { ProgrammingExercise updatedExercise = request.putWithResponseBody("/api/programming-exercises", programmingExercise, ProgrammingExercise.class, HttpStatus.OK); assertThat(updatedExercise.getReleaseDate()).isEqualTo(programmingExercise.getReleaseDate()); - verify(competencyProgressService, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(programmingExercise), eq(Optional.of(programmingExercise))); + verify(competencyProgressApi, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(programmingExercise), eq(Optional.of(programmingExercise))); } @Test @@ -235,7 +235,7 @@ void testDeleteProgrammingExercise() throws Exception { assertThat(solutionRepositoryUri.getLocalRepositoryPath(localVCBasePath)).doesNotExist(); LocalVCRepositoryUri testsRepositoryUri = new LocalVCRepositoryUri(programmingExercise.getTestRepositoryUri()); assertThat(testsRepositoryUri.getLocalRepositoryPath(localVCBasePath)).doesNotExist(); - verify(competencyProgressService).updateProgressByCompetencyAsync(eq(competency)); + verify(competencyProgressApi).updateProgressByCompetencyAsync(eq(competency)); } @Test @@ -287,7 +287,7 @@ void testImportProgrammingExercise() throws Exception { .orElseThrow(); localVCLocalCITestService.testLatestSubmission(templateParticipation.getId(), null, 0, false); localVCLocalCITestService.testLatestSubmission(solutionParticipation.getId(), null, 13, false); - verify(competencyProgressService).updateProgressByLearningObjectAsync(eq(importedExercise)); + verify(competencyProgressApi).updateProgressByLearningObjectAsync(eq(importedExercise)); } @Nested diff --git a/src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractArtemisIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractArtemisIntegrationTest.java index 469e4f117837..3012e001bfd4 100644 --- a/src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractArtemisIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractArtemisIntegrationTest.java @@ -29,6 +29,7 @@ import de.tum.cit.aet.artemis.assessment.service.ParticipantScoreScheduleService; import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; +import de.tum.cit.aet.artemis.atlas.api.CompetencyProgressApi; import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; import de.tum.cit.aet.artemis.communication.service.WebsocketMessagingService; import de.tum.cit.aet.artemis.communication.service.notifications.ConversationNotificationService; @@ -170,6 +171,9 @@ public abstract class AbstractArtemisIntegrationTest implements MockDelegate { @SpyBean protected CompetencyProgressService competencyProgressService; + @SpyBean + protected CompetencyProgressApi competencyProgressApi; + @Autowired protected RequestUtilService request; @@ -223,7 +227,8 @@ void stopRunningTasks() { protected void resetSpyBeans() { Mockito.reset(gitService, groupNotificationService, conversationNotificationService, tutorialGroupNotificationService, singleUserNotificationService, websocketMessagingService, examAccessService, mailService, instanceMessageSendService, programmingExerciseScheduleService, programmingExerciseParticipationService, - uriService, scheduleService, participantScoreScheduleService, javaMailSender, programmingTriggerService, zipFileService, competencyProgressService); + uriService, scheduleService, participantScoreScheduleService, javaMailSender, programmingTriggerService, zipFileService, competencyProgressService, + competencyProgressApi); } @Override diff --git a/src/test/java/de/tum/cit/aet/artemis/text/TextExerciseIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/text/TextExerciseIntegrationTest.java index c635d94e9c6b..9ed51413ea40 100644 --- a/src/test/java/de/tum/cit/aet/artemis/text/TextExerciseIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/text/TextExerciseIntegrationTest.java @@ -200,7 +200,7 @@ void testDeleteTextExerciseWithCompetency() throws Exception { request.delete("/api/text-exercises/" + textExercise.getId(), HttpStatus.OK); - verify(competencyProgressService).updateProgressByCompetencyAsync(eq(competency)); + verify(competencyProgressApi).updateProgressByCompetencyAsync(eq(competency)); } @Test @@ -431,7 +431,7 @@ void updateTextExercise() throws Exception { assertThat(updatedTextExercise.getCourseViaExerciseGroupOrCourseMember().getId()).as("courseId was not updated").isEqualTo(course.getId()); verify(examLiveEventsService, never()).createAndSendProblemStatementUpdateEvent(any(), any(), any()); verify(groupNotificationScheduleService, times(1)).checkAndCreateAppropriateNotificationsWhenUpdatingExercise(any(), any(), any()); - verify(competencyProgressService, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(textExercise), eq(Optional.of(textExercise))); + verify(competencyProgressApi, timeout(1000).times(1)).updateProgressForUpdatedLearningObjectAsync(eq(textExercise), eq(Optional.of(textExercise))); } @Test @@ -596,7 +596,7 @@ void importTextExerciseFromCourseToCourse() throws Exception { var newTextExercise = request.postWithResponseBody("/api/text-exercises/import/" + textExercise.getId(), textExercise, TextExercise.class, HttpStatus.CREATED); Channel channel = channelRepository.findChannelByExerciseId(newTextExercise.getId()); assertThat(channel).isNotNull(); - verify(competencyProgressService).updateProgressByLearningObjectAsync(eq(newTextExercise)); + verify(competencyProgressApi).updateProgressByLearningObjectAsync(eq(newTextExercise)); } @Test From 3b154297de5faad421d87bc90e0416d9707c765b Mon Sep 17 00:00:00 2001 From: Ole Vester Date: Sun, 17 Nov 2024 18:26:48 +0100 Subject: [PATCH 07/11] Add profile annotations to atlas APIs --- .../tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java | 4 ++++ .../tum/cit/aet/artemis/atlas/api/CompetencyRelationApi.java | 4 ++++ .../de/tum/cit/aet/artemis/atlas/api/CourseCompetencyApi.java | 4 ++++ .../de/tum/cit/aet/artemis/atlas/api/LearningPathApi.java | 4 ++++ .../de/tum/cit/aet/artemis/atlas/api/PrerequisitesApi.java | 4 ++++ .../de/tum/cit/aet/artemis/atlas/api/ScienceEventApi.java | 4 ++++ 6 files changed, 24 insertions(+) diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java index 9d04bb3fc055..6a7065eb3d27 100644 --- a/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java @@ -1,11 +1,14 @@ package de.tum.cit.aet.artemis.atlas.api; +import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; + import java.util.List; import java.util.Optional; import java.util.Set; import jakarta.validation.constraints.NotNull; +import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Controller; import de.tum.cit.aet.artemis.atlas.domain.LearningObject; @@ -18,6 +21,7 @@ import de.tum.cit.aet.artemis.exercise.domain.participation.Participant; @Controller +@Profile(PROFILE_CORE) public class CompetencyProgressApi extends AbstractAtlasApi { private final CompetencyProgressService competencyProgressService; diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyRelationApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyRelationApi.java index f34d3bd0d6c1..d7857bdcf509 100644 --- a/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyRelationApi.java +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyRelationApi.java @@ -1,7 +1,10 @@ package de.tum.cit.aet.artemis.atlas.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.stereotype.Controller; import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyExerciseLink; @@ -11,6 +14,7 @@ import de.tum.cit.aet.artemis.atlas.repository.CompetencyRelationRepository; @Controller +@Profile(PROFILE_CORE) public class CompetencyRelationApi extends AbstractAtlasApi { private final CompetencyRelationRepository competencyRelationRepository; diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/api/CourseCompetencyApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CourseCompetencyApi.java index 74bbbe6b8113..c970d2f137ff 100644 --- a/src/main/java/de/tum/cit/aet/artemis/atlas/api/CourseCompetencyApi.java +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CourseCompetencyApi.java @@ -1,11 +1,15 @@ package de.tum.cit.aet.artemis.atlas.api; +import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; + +import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Controller; import de.tum.cit.aet.artemis.atlas.domain.competency.CourseCompetency; import de.tum.cit.aet.artemis.atlas.repository.CourseCompetencyRepository; @Controller +@Profile(PROFILE_CORE) public class CourseCompetencyApi extends AbstractAtlasApi { private final CourseCompetencyRepository courseCompetencyRepository; diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/api/LearningPathApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/LearningPathApi.java index 3a876a0a373d..834297c04288 100644 --- a/src/main/java/de/tum/cit/aet/artemis/atlas/api/LearningPathApi.java +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/LearningPathApi.java @@ -1,7 +1,10 @@ package de.tum.cit.aet.artemis.atlas.api; +import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; + import jakarta.validation.constraints.NotNull; +import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Controller; import de.tum.cit.aet.artemis.atlas.service.learningpath.LearningPathService; @@ -9,6 +12,7 @@ import de.tum.cit.aet.artemis.core.domain.User; @Controller +@Profile(PROFILE_CORE) public class LearningPathApi extends AbstractAtlasApi { private final LearningPathService learningPathService; diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/api/PrerequisitesApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/PrerequisitesApi.java index 83e67be2f7b4..ddcc8fa3c56a 100644 --- a/src/main/java/de/tum/cit/aet/artemis/atlas/api/PrerequisitesApi.java +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/PrerequisitesApi.java @@ -1,5 +1,8 @@ package de.tum.cit.aet.artemis.atlas.api; +import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; + +import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Controller; import de.tum.cit.aet.artemis.atlas.domain.competency.Prerequisite; @@ -7,6 +10,7 @@ import de.tum.cit.aet.artemis.core.domain.Course; @Controller +@Profile(PROFILE_CORE) public class PrerequisitesApi extends AbstractAtlasApi { private final PrerequisiteRepository prerequisiteRepository; diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/api/ScienceEventApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/ScienceEventApi.java index a77d450c0bd2..0da5e4beb0ca 100644 --- a/src/main/java/de/tum/cit/aet/artemis/atlas/api/ScienceEventApi.java +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/ScienceEventApi.java @@ -1,13 +1,17 @@ package de.tum.cit.aet.artemis.atlas.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.stereotype.Controller; import de.tum.cit.aet.artemis.atlas.domain.science.ScienceEvent; import de.tum.cit.aet.artemis.atlas.repository.ScienceEventRepository; @Controller +@Profile(PROFILE_CORE) public class ScienceEventApi extends AbstractAtlasApi { private final ScienceEventRepository scienceEventRepository; From 59bc157fd33e8e3e5f247a3ac166b16a1eb74bdf Mon Sep 17 00:00:00 2001 From: Ole Vester Date: Sun, 17 Nov 2024 18:28:48 +0100 Subject: [PATCH 08/11] Move LearningMetricsService to atlas module and remove unused API --- .../atlas/api/CompetencyMetricsApi.java | 45 ------------------- .../service/LearningMetricsService.java | 22 ++++----- .../artemis/atlas/web/MetricsResource.java | 2 +- .../service/pyris/PyrisPipelineService.java | 2 +- 4 files changed, 13 insertions(+), 58 deletions(-) delete mode 100644 src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyMetricsApi.java rename src/main/java/de/tum/cit/aet/artemis/{exercise => atlas}/service/LearningMetricsService.java (89%) diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyMetricsApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyMetricsApi.java deleted file mode 100644 index c01ebecf0882..000000000000 --- a/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyMetricsApi.java +++ /dev/null @@ -1,45 +0,0 @@ -package de.tum.cit.aet.artemis.atlas.api; - -import java.util.Set; - -import org.springframework.stereotype.Controller; - -import de.tum.cit.aet.artemis.atlas.dto.CompetencyJolDTO; -import de.tum.cit.aet.artemis.atlas.dto.metrics.CompetencyInformationDTO; -import de.tum.cit.aet.artemis.atlas.dto.metrics.CompetencyProgressDTO; -import de.tum.cit.aet.artemis.atlas.dto.metrics.MapEntryLongLong; -import de.tum.cit.aet.artemis.atlas.repository.CompetencyMetricsRepository; - -@Controller -public class CompetencyMetricsApi extends AbstractAtlasApi { - - private final CompetencyMetricsRepository competencyMetricsRepository; - - public CompetencyMetricsApi(CompetencyMetricsRepository competencyMetricsRepository) { - this.competencyMetricsRepository = competencyMetricsRepository; - } - - public Set findAllCompetencyInformationByCourseId(long courseId) { - return competencyMetricsRepository.findAllCompetencyInformationByCourseId(courseId); - } - - public Set findAllExerciseIdsByCompetencyIds(Set competencyIds) { - return competencyMetricsRepository.findAllExerciseIdsByCompetencyIds(competencyIds); - } - - public Set findAllLectureUnitIdsByCompetencyIds(Set competencyIds) { - return competencyMetricsRepository.findAllLectureUnitIdsByCompetencyIds(competencyIds); - } - - public Set findAllCompetencyProgressForUserByCompetencyIds(long userId, Set competencyIds) { - return competencyMetricsRepository.findAllCompetencyProgressForUserByCompetencyIds(userId, competencyIds); - } - - public Set findAllLatestCompetencyJolValuesForUserByCompetencyIds(long userId, Set competencyIds) { - return competencyMetricsRepository.findAllLatestCompetencyJolValuesForUserByCompetencyIds(userId, competencyIds); - } - - public Set findAllLatestCompetencyJolValuesForUserByCompetencyIdsExcludeJolIds(long userId, Set competencyIds, Set jolIdsToExclude) { - return competencyMetricsRepository.findAllLatestCompetencyJolValuesForUserByCompetencyIdsExcludeJolIds(userId, competencyIds, jolIdsToExclude); - } -} diff --git a/src/main/java/de/tum/cit/aet/artemis/exercise/service/LearningMetricsService.java b/src/main/java/de/tum/cit/aet/artemis/atlas/service/LearningMetricsService.java similarity index 89% rename from src/main/java/de/tum/cit/aet/artemis/exercise/service/LearningMetricsService.java rename to src/main/java/de/tum/cit/aet/artemis/atlas/service/LearningMetricsService.java index 3bf12a37a1ca..38b4552c19c3 100644 --- a/src/main/java/de/tum/cit/aet/artemis/exercise/service/LearningMetricsService.java +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/service/LearningMetricsService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.service; +package de.tum.cit.aet.artemis.atlas.service; import static de.tum.cit.aet.artemis.core.config.Constants.MIN_SCORE_GREEN; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; @@ -18,7 +18,6 @@ import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Service; -import de.tum.cit.aet.artemis.atlas.api.CompetencyMetricsApi; import de.tum.cit.aet.artemis.atlas.dto.CompetencyJolDTO; import de.tum.cit.aet.artemis.atlas.dto.metrics.CompetencyInformationDTO; import de.tum.cit.aet.artemis.atlas.dto.metrics.CompetencyProgressDTO; @@ -30,6 +29,7 @@ import de.tum.cit.aet.artemis.atlas.dto.metrics.ResourceTimestampDTO; import de.tum.cit.aet.artemis.atlas.dto.metrics.ScoreDTO; import de.tum.cit.aet.artemis.atlas.dto.metrics.StudentMetricsDTO; +import de.tum.cit.aet.artemis.atlas.repository.CompetencyMetricsRepository; import de.tum.cit.aet.artemis.exercise.dto.ExerciseInformationDTO; import de.tum.cit.aet.artemis.exercise.repository.ExerciseMetricsRepository; import de.tum.cit.aet.artemis.lecture.repository.LectureUnitMetricsRepository; @@ -45,13 +45,13 @@ public class LearningMetricsService { private final LectureUnitMetricsRepository lectureUnitMetricsRepository; - private final CompetencyMetricsApi competencyMetricsApi; + private final CompetencyMetricsRepository competencyMetricsRepository; public LearningMetricsService(ExerciseMetricsRepository exerciseMetricsRepository, LectureUnitMetricsRepository lectureUnitMetricsRepository, - CompetencyMetricsApi competencyMetricsApi) { + CompetencyMetricsRepository competencyMetricsRepository) { this.exerciseMetricsRepository = exerciseMetricsRepository; this.lectureUnitMetricsRepository = lectureUnitMetricsRepository; - this.competencyMetricsApi = competencyMetricsApi; + this.competencyMetricsRepository = competencyMetricsRepository; } /** @@ -136,26 +136,26 @@ public LectureUnitStudentMetricsDTO getStudentLectureUnitMetrics(long userId, lo * @return the metrics for the student in the course */ public CompetencyStudentMetricsDTO getStudentCompetencyMetrics(long userId, long courseId) { - final var competencyInfo = competencyMetricsApi.findAllCompetencyInformationByCourseId(courseId); + final var competencyInfo = competencyMetricsRepository.findAllCompetencyInformationByCourseId(courseId); final var competencyInfoMap = competencyInfo.stream().collect(toMap(CompetencyInformationDTO::id, identity())); final var competencyIds = competencyInfoMap.keySet(); - final var competencyExerciseMapEntries = competencyMetricsApi.findAllExerciseIdsByCompetencyIds(competencyIds); + final var competencyExerciseMapEntries = competencyMetricsRepository.findAllExerciseIdsByCompetencyIds(competencyIds); final var exerciseMap = competencyExerciseMapEntries.stream().collect(groupingBy(MapEntryLongLong::key, mapping(MapEntryLongLong::value, toSet()))); - final var competencyLectureUnitMapEntries = competencyMetricsApi.findAllLectureUnitIdsByCompetencyIds(competencyIds); + final var competencyLectureUnitMapEntries = competencyMetricsRepository.findAllLectureUnitIdsByCompetencyIds(competencyIds); final var lectureUnitMap = competencyLectureUnitMapEntries.stream().collect(groupingBy(MapEntryLongLong::key, mapping(MapEntryLongLong::value, toSet()))); - final var competencyProgress = competencyMetricsApi.findAllCompetencyProgressForUserByCompetencyIds(userId, competencyIds); + final var competencyProgress = competencyMetricsRepository.findAllCompetencyProgressForUserByCompetencyIds(userId, competencyIds); final var competencyProgressMap = competencyProgress.stream().collect(toMap(CompetencyProgressDTO::competencyId, CompetencyProgressDTO::progress)); final var competencyConfidenceMap = competencyProgress.stream().collect(toMap(CompetencyProgressDTO::competencyId, CompetencyProgressDTO::confidence)); - final var currentJolValues = competencyMetricsApi.findAllLatestCompetencyJolValuesForUserByCompetencyIds(userId, competencyIds); + final var currentJolValues = competencyMetricsRepository.findAllLatestCompetencyJolValuesForUserByCompetencyIds(userId, competencyIds); final var currentJolValuesMap = currentJolValues.stream().collect(toMap(CompetencyJolDTO::competencyId, identity())); final var currentJolIds = currentJolValues.stream().map(CompetencyJolDTO::id).collect(toSet()); - final var priorJolValues = competencyMetricsApi.findAllLatestCompetencyJolValuesForUserByCompetencyIdsExcludeJolIds(userId, competencyIds, currentJolIds); + final var priorJolValues = competencyMetricsRepository.findAllLatestCompetencyJolValuesForUserByCompetencyIdsExcludeJolIds(userId, competencyIds, currentJolIds); final var priorJolValuesMap = priorJolValues.stream().collect(toMap(CompetencyJolDTO::competencyId, identity())); return new CompetencyStudentMetricsDTO(competencyInfoMap, exerciseMap, lectureUnitMap, competencyProgressMap, competencyConfidenceMap, currentJolValuesMap, diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/web/MetricsResource.java b/src/main/java/de/tum/cit/aet/artemis/atlas/web/MetricsResource.java index ca2fa2f30251..db24d9569c88 100644 --- a/src/main/java/de/tum/cit/aet/artemis/atlas/web/MetricsResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/web/MetricsResource.java @@ -12,9 +12,9 @@ import org.springframework.web.bind.annotation.RestController; import de.tum.cit.aet.artemis.atlas.dto.metrics.StudentMetricsDTO; +import de.tum.cit.aet.artemis.atlas.service.LearningMetricsService; import de.tum.cit.aet.artemis.core.repository.UserRepository; import de.tum.cit.aet.artemis.core.security.annotations.enforceRoleInCourse.EnforceAtLeastStudentInCourse; -import de.tum.cit.aet.artemis.exercise.service.LearningMetricsService; @Profile(PROFILE_CORE) @RestController diff --git a/src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/PyrisPipelineService.java b/src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/PyrisPipelineService.java index 08861c06a773..899812321be1 100644 --- a/src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/PyrisPipelineService.java +++ b/src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/PyrisPipelineService.java @@ -19,11 +19,11 @@ import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyJol; import de.tum.cit.aet.artemis.atlas.dto.CompetencyJolDTO; +import de.tum.cit.aet.artemis.atlas.service.LearningMetricsService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.repository.CourseRepository; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.service.LearningMetricsService; import de.tum.cit.aet.artemis.iris.domain.session.IrisCourseChatSession; import de.tum.cit.aet.artemis.iris.domain.session.IrisExerciseChatSession; import de.tum.cit.aet.artemis.iris.exception.IrisException; From 5881ca9c3d577851a49caf7c6d37367f18e833c3 Mon Sep 17 00:00:00 2001 From: Ole Vester Date: Thu, 28 Nov 2024 12:44:28 +0100 Subject: [PATCH 09/11] Update and use APIs for added services --- .../aet/artemis/atlas/api/CompetencyApi.java | 24 +++++++++++++++++++ .../artemis/atlas/api/LearningMetricsApi.java | 24 +++++++++++++++++++ .../service/pyris/PyrisPipelineService.java | 10 ++++---- .../artemis/lecture/web/LectureResource.java | 12 +++++----- 4 files changed, 59 insertions(+), 11 deletions(-) create mode 100644 src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyApi.java create mode 100644 src/main/java/de/tum/cit/aet/artemis/atlas/api/LearningMetricsApi.java diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyApi.java new file mode 100644 index 000000000000..7c4f349d9215 --- /dev/null +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyApi.java @@ -0,0 +1,24 @@ +package de.tum.cit.aet.artemis.atlas.api; + +import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; + +import org.springframework.context.annotation.Profile; +import org.springframework.stereotype.Controller; + +import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyService; +import de.tum.cit.aet.artemis.lecture.domain.Lecture; + +@Controller +@Profile(PROFILE_CORE) +public class CompetencyApi extends AbstractAtlasApi { + + private final CompetencyService competencyService; + + public CompetencyApi(CompetencyService competencyService) { + this.competencyService = competencyService; + } + + public void addCompetencyLinksToExerciseUnits(Lecture lecture) { + competencyService.addCompetencyLinksToExerciseUnits(lecture); + } +} diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/api/LearningMetricsApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/LearningMetricsApi.java new file mode 100644 index 000000000000..cf2a5271cab0 --- /dev/null +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/LearningMetricsApi.java @@ -0,0 +1,24 @@ +package de.tum.cit.aet.artemis.atlas.api; + +import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; + +import org.springframework.context.annotation.Profile; +import org.springframework.stereotype.Controller; + +import de.tum.cit.aet.artemis.atlas.dto.metrics.StudentMetricsDTO; +import de.tum.cit.aet.artemis.atlas.service.LearningMetricsService; + +@Controller +@Profile(PROFILE_CORE) +public class LearningMetricsApi extends AbstractAtlasApi { + + private final LearningMetricsService metricsService; + + public LearningMetricsApi(LearningMetricsService metricsService) { + this.metricsService = metricsService; + } + + public StudentMetricsDTO getStudentCourseMetrics(long userId, long courseId) { + return metricsService.getStudentCourseMetrics(userId, courseId); + } +} diff --git a/src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/PyrisPipelineService.java b/src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/PyrisPipelineService.java index 899812321be1..c8851341e29e 100644 --- a/src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/PyrisPipelineService.java +++ b/src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/PyrisPipelineService.java @@ -17,9 +17,9 @@ import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Service; +import de.tum.cit.aet.artemis.atlas.api.LearningMetricsApi; import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyJol; import de.tum.cit.aet.artemis.atlas.dto.CompetencyJolDTO; -import de.tum.cit.aet.artemis.atlas.service.LearningMetricsService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.repository.CourseRepository; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; @@ -61,20 +61,20 @@ public class PyrisPipelineService { private final StudentParticipationRepository studentParticipationRepository; - private final LearningMetricsService learningMetricsService; + private final LearningMetricsApi learningMetricsApi; @Value("${server.url}") private String artemisBaseUrl; public PyrisPipelineService(PyrisConnectorService pyrisConnectorService, PyrisJobService pyrisJobService, PyrisDTOService pyrisDTOService, - IrisChatWebsocketService irisChatWebsocketService, CourseRepository courseRepository, LearningMetricsService learningMetricsService, + IrisChatWebsocketService irisChatWebsocketService, CourseRepository courseRepository, LearningMetricsApi learningMetricsApi, StudentParticipationRepository studentParticipationRepository) { this.pyrisConnectorService = pyrisConnectorService; this.pyrisJobService = pyrisJobService; this.pyrisDTOService = pyrisDTOService; this.irisChatWebsocketService = irisChatWebsocketService; this.courseRepository = courseRepository; - this.learningMetricsService = learningMetricsService; + this.learningMetricsApi = learningMetricsApi; this.studentParticipationRepository = studentParticipationRepository; } @@ -186,7 +186,7 @@ public void executeCourseChatPipeline(String variant, IrisCourseChatSession sess var fullCourse = loadCourseWithParticipationOfStudent(courseId, studentId); return new PyrisCourseChatPipelineExecutionDTO( PyrisExtendedCourseDTO.of(fullCourse), - learningMetricsService.getStudentCourseMetrics(session.getUser().getId(), courseId), + learningMetricsApi.getStudentCourseMetrics(session.getUser().getId(), courseId), competencyJol == null ? null : CompetencyJolDTO.of(competencyJol), pyrisDTOService.toPyrisMessageDTOList(session.getMessages()), new PyrisUserDTO(session.getUser()), 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 baecd6cd7c57..d70ddb0724d4 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 @@ -27,7 +27,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyService; +import de.tum.cit.aet.artemis.atlas.api.CompetencyApi; import de.tum.cit.aet.artemis.communication.domain.conversation.Channel; import de.tum.cit.aet.artemis.communication.repository.conversation.ChannelRepository; import de.tum.cit.aet.artemis.communication.service.conversation.ChannelService; @@ -67,7 +67,7 @@ public class LectureResource { private static final String ENTITY_NAME = "lecture"; - private final CompetencyService competencyService; + private final CompetencyApi competencyApi; @Value("${jhipster.clientApp.name}") private String applicationName; @@ -92,7 +92,7 @@ public class LectureResource { public LectureResource(LectureRepository lectureRepository, LectureService lectureService, LectureImportService lectureImportService, CourseRepository courseRepository, UserRepository userRepository, AuthorizationCheckService authCheckService, ExerciseService exerciseService, ChannelService channelService, - ChannelRepository channelRepository, CompetencyService competencyService) { + ChannelRepository channelRepository, CompetencyApi competencyApi) { this.lectureRepository = lectureRepository; this.lectureService = lectureService; this.lectureImportService = lectureImportService; @@ -102,7 +102,7 @@ public LectureResource(LectureRepository lectureRepository, LectureService lectu this.exerciseService = exerciseService; this.channelService = channelService; this.channelRepository = channelRepository; - this.competencyService = competencyService; + this.competencyApi = competencyApi; } /** @@ -304,7 +304,7 @@ public ResponseEntity ingestLectures(@PathVariable Long courseId, @Requ public ResponseEntity getLectureWithDetails(@PathVariable Long lectureId) { log.debug("REST request to get lecture {} with details", lectureId); Lecture lecture = lectureRepository.findByIdWithAttachmentsAndPostsAndLectureUnitsAndCompetenciesAndCompletionsElseThrow(lectureId); - competencyService.addCompetencyLinksToExerciseUnits(lecture); + competencyApi.addCompetencyLinksToExerciseUnits(lecture); Course course = lecture.getCourse(); if (course == null) { return ResponseEntity.badRequest().build(); @@ -334,7 +334,7 @@ public ResponseEntity getLectureWithDetailsAndSlides(@PathVariable long User user = userRepository.getUserWithGroupsAndAuthorities(); authCheckService.checkIsAllowedToSeeLectureElseThrow(lecture, user); - competencyService.addCompetencyLinksToExerciseUnits(lecture); + competencyApi.addCompetencyLinksToExerciseUnits(lecture); lectureService.filterActiveAttachmentUnits(lecture); lectureService.filterActiveAttachments(lecture, user); return ResponseEntity.ok(lecture); From 50b64ecd61bc2dd82e2ce3cb829a6eeb6a5375ee Mon Sep 17 00:00:00 2001 From: Ole Vester Date: Thu, 28 Nov 2024 12:47:38 +0100 Subject: [PATCH 10/11] Rename updateProgressForCourses to updateProgressForCoursesAsync --- .../de/tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java | 2 +- .../config/migration/entries/MigrationEntry20240614_140000.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java index 6a7065eb3d27..16be30412fb2 100644 --- a/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java @@ -66,7 +66,7 @@ public void deleteAll(Set competencies) { * * @param activeCourses the active courses */ - public void updateProgressForCourses(List activeCourses) { + public void updateProgressForCoursesAsync(List activeCourses) { activeCourses.forEach(course -> { List competencies = competencyRepository.findByCourseIdOrderById(course.getId()); // Asynchronously update the progress for each competency diff --git a/src/main/java/de/tum/cit/aet/artemis/core/config/migration/entries/MigrationEntry20240614_140000.java b/src/main/java/de/tum/cit/aet/artemis/core/config/migration/entries/MigrationEntry20240614_140000.java index 2a10897a652a..b385c3f01053 100644 --- a/src/main/java/de/tum/cit/aet/artemis/core/config/migration/entries/MigrationEntry20240614_140000.java +++ b/src/main/java/de/tum/cit/aet/artemis/core/config/migration/entries/MigrationEntry20240614_140000.java @@ -29,7 +29,7 @@ public void execute() { List activeCourses = courseRepository.findAllActiveWithoutTestCourses(ZonedDateTime.now()); log.info("Updating competency progress for {} active courses", activeCourses.size()); - competencyProgressApi.updateProgressForCourses(activeCourses); + competencyProgressApi.updateProgressForCoursesAsync(activeCourses); } @Override From 07fae72d8f86d68fd90bd467ddd07fc2222a8773 Mon Sep 17 00:00:00 2001 From: Ole Vester Date: Thu, 28 Nov 2024 12:48:11 +0100 Subject: [PATCH 11/11] Remove @NotNull annotation in api --- .../tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java index 16be30412fb2..eddc384ad8c7 100644 --- a/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java @@ -6,8 +6,6 @@ import java.util.Optional; import java.util.Set; -import jakarta.validation.constraints.NotNull; - import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Controller; @@ -33,7 +31,7 @@ public CompetencyProgressApi(CompetencyProgressService competencyProgressService this.competencyRepository = competencyRepository; } - public void updateProgressByLearningObjectForParticipantAsync(LearningObject learningObject, @NotNull Participant participant) { + public void updateProgressByLearningObjectForParticipantAsync(LearningObject learningObject, Participant participant) { competencyProgressService.updateProgressByLearningObjectForParticipantAsync(learningObject, participant); }