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/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 { +} 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/CompetencyProgressApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java new file mode 100644 index 000000000000..eddc384ad8c7 --- /dev/null +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyProgressApi.java @@ -0,0 +1,74 @@ +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 org.springframework.context.annotation.Profile; +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 +@Profile(PROFILE_CORE) +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, 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 updateProgressForCoursesAsync(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..d7857bdcf509 --- /dev/null +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CompetencyRelationApi.java @@ -0,0 +1,56 @@ +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; +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 +@Profile(PROFILE_CORE) +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..c970d2f137ff --- /dev/null +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/CourseCompetencyApi.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.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; + + 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/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/atlas/api/LearningPathApi.java b/src/main/java/de/tum/cit/aet/artemis/atlas/api/LearningPathApi.java new file mode 100644 index 000000000000..834297c04288 --- /dev/null +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/LearningPathApi.java @@ -0,0 +1,31 @@ +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; +import de.tum.cit.aet.artemis.core.domain.Course; +import de.tum.cit.aet.artemis.core.domain.User; + +@Controller +@Profile(PROFILE_CORE) +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..ddcc8fa3c56a --- /dev/null +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/PrerequisitesApi.java @@ -0,0 +1,29 @@ +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; +import de.tum.cit.aet.artemis.atlas.repository.PrerequisiteRepository; +import de.tum.cit.aet.artemis.core.domain.Course; + +@Controller +@Profile(PROFILE_CORE) +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..0da5e4beb0ca --- /dev/null +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/api/ScienceEventApi.java @@ -0,0 +1,30 @@ +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; + + 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); + } +} 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 99% 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 c939f59367b5..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; 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/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 { +} 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..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 @@ -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.updateProgressForCoursesAsync(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 f10248c99b81..1b037532e453 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.FaqState; import de.tum.cit.aet.artemis.communication.domain.NotificationType; import de.tum.cit.aet.artemis.communication.domain.Post; @@ -132,7 +132,7 @@ public class CourseService { private final TutorialGroupChannelManagementService tutorialGroupChannelManagementService; - private final CompetencyRelationRepository competencyRelationRepository; + private final CompetencyRelationApi competencyRelationApi; private final ExerciseService exerciseService; @@ -162,9 +162,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; @@ -200,7 +200,7 @@ public class CourseService { private final ConversationRepository conversationRepository; - private final LearningPathService learningPathService; + private final LearningPathApi learningPathApi; private final Optional irisSettingsService; @@ -217,17 +217,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; @@ -239,7 +239,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; @@ -260,13 +260,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; @@ -354,9 +354,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 (course.isFaqEnabled()) { @@ -578,9 +578,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) { @@ -618,7 +618,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); @@ -651,7 +651,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, SavedPostRepository savedPostRepository) { this.userCreationService = userCreationService; this.userRepository = userRepository; @@ -134,7 +134,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; this.savedPostRepository = savedPostRepository; } @@ -508,7 +508,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 e6af8db0cd8a..2545a6ffb192 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 @@ -66,7 +66,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; @@ -180,7 +180,7 @@ public class CourseResource { @Value("${artemis.course-archives-path}") private String courseArchivesDirPath; - private final LearningPathService learningPathService; + private final LearningPathApi learningPathApi; private final ExamRepository examRepository; @@ -193,7 +193,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; @@ -213,7 +213,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; @@ -335,7 +335,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 @@ -1244,7 +1244,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 36b7e99fedd0..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,8 +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.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; @@ -78,7 +78,7 @@ public class ExerciseDeletionService { private final ChannelService channelService; - private final CompetencyProgressService competencyProgressService; + private final CompetencyProgressApi competencyProgressApi; private final Optional irisSettingsService; @@ -86,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, - Optional irisSettingsService) { + ChannelRepository channelRepository, ChannelService channelService, CompetencyProgressApi competencyProgressApi, Optional irisSettingsService) { this.exerciseRepository = exerciseRepository; this.participationService = participationService; this.programmingExerciseService = programmingExerciseService; @@ -102,7 +101,7 @@ public ExerciseDeletionService(ExerciseRepository exerciseRepository, ExerciseUn this.textExerciseService = textExerciseService; this.channelRepository = channelRepository; this.channelService = channelService; - this.competencyProgressService = competencyProgressService; + this.competencyProgressApi = competencyProgressApi; this.irisSettingsService = irisSettingsService; } @@ -215,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/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/iris/service/pyris/PyrisPipelineService.java b/src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/PyrisPipelineService.java index 08861c06a773..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,13 +17,13 @@ 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.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; @@ -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/service/AttachmentUnitService.java b/src/main/java/de/tum/cit/aet/artemis/lecture/service/AttachmentUnitService.java index 83d3ffdf6751..342e463b5650 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 7654884f753d..9bf8edba5bea 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 74ec8a5fa90c..b3fba2a6c829 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 @@ -27,11 +27,11 @@ import org.springframework.http.ResponseEntity; 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; @@ -65,24 +65,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; } /** @@ -183,7 +183,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()); } } @@ -196,7 +196,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); } /** @@ -206,7 +206,7 @@ public void linkLectureUnitsToCompetency(CourseCompetency competency, Set lectureUnitLinks, CourseCompetency competency) { - competencyLectureUnitLinkRepository.deleteAll(lectureUnitLinks); + competencyRelationApi.deleteAllLectureUnitLinks(lectureUnitLinks); competency.getLectureUnitLinks().removeAll(lectureUnitLinks); } @@ -286,7 +286,7 @@ public T saveWithCompetencyLinks(T lectureUnit, Function if (Hibernate.isInitialized(links) && links != null && !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 83aa9f8ebefb..ec1514ca668b 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/LectureResource.java b/src/main/java/de/tum/cit/aet/artemis/lecture/web/LectureResource.java index 6d0a6f0f33e9..deeb3ec3861c 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, @Request 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); 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 78bb7d708f86..2faca61e3854 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 @@ -24,7 +24,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; @@ -65,16 +65,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; } /** @@ -144,7 +144,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/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())); 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/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 929d46b4b5bb..e81d7571973b 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 @@ -279,7 +279,7 @@ void updateAttachmentUnit_asInstructor_shouldUpdateAttachmentUnit() throws Excep assertThat(attachmentUnit2.getAttachment()).isEqualTo(attachment); assertThat(attachment.getAttachmentUnit()).isEqualTo(attachmentUnit2); assertThat(attachmentUnit1.getCompetencyLinks()).anyMatch(link -> link.getCompetency().getId().equals(competency.getId())); - 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 @@ -357,6 +357,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 dea62c73d76b..310eaee69286 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 @@ -370,7 +370,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/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)); + } + } + }; + } +} 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 3252a1afdc8b..769ba99ea29b 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; @@ -171,6 +172,9 @@ public abstract class AbstractArtemisIntegrationTest implements MockDelegate { @SpyBean protected CompetencyProgressService competencyProgressService; + @SpyBean + protected CompetencyProgressApi competencyProgressApi; + @Autowired protected RequestUtilService request; @@ -227,7 +231,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