Skip to content

Commit

Permalink
Move LearningMetricsService to atlas module and remove unused API
Browse files Browse the repository at this point in the history
  • Loading branch information
ole-ve committed Nov 17, 2024
1 parent 3b15429 commit 59bc157
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 58 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -18,7 +18,6 @@
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

import de.tum.cit.aet.artemis.atlas.api.CompetencyMetricsApi;
import de.tum.cit.aet.artemis.atlas.dto.CompetencyJolDTO;
import de.tum.cit.aet.artemis.atlas.dto.metrics.CompetencyInformationDTO;
import de.tum.cit.aet.artemis.atlas.dto.metrics.CompetencyProgressDTO;
Expand All @@ -30,6 +29,7 @@
import de.tum.cit.aet.artemis.atlas.dto.metrics.ResourceTimestampDTO;
import de.tum.cit.aet.artemis.atlas.dto.metrics.ScoreDTO;
import de.tum.cit.aet.artemis.atlas.dto.metrics.StudentMetricsDTO;
import de.tum.cit.aet.artemis.atlas.repository.CompetencyMetricsRepository;
import de.tum.cit.aet.artemis.exercise.dto.ExerciseInformationDTO;
import de.tum.cit.aet.artemis.exercise.repository.ExerciseMetricsRepository;
import de.tum.cit.aet.artemis.lecture.repository.LectureUnitMetricsRepository;
Expand All @@ -45,13 +45,13 @@ public class LearningMetricsService {

private final LectureUnitMetricsRepository lectureUnitMetricsRepository;

private final CompetencyMetricsApi competencyMetricsApi;
private final CompetencyMetricsRepository competencyMetricsRepository;

public LearningMetricsService(ExerciseMetricsRepository exerciseMetricsRepository, LectureUnitMetricsRepository lectureUnitMetricsRepository,
CompetencyMetricsApi competencyMetricsApi) {
CompetencyMetricsRepository competencyMetricsRepository) {
this.exerciseMetricsRepository = exerciseMetricsRepository;
this.lectureUnitMetricsRepository = lectureUnitMetricsRepository;
this.competencyMetricsApi = competencyMetricsApi;
this.competencyMetricsRepository = competencyMetricsRepository;
}

/**
Expand Down Expand Up @@ -136,26 +136,26 @@ public LectureUnitStudentMetricsDTO getStudentLectureUnitMetrics(long userId, lo
* @return the metrics for the student in the course
*/
public CompetencyStudentMetricsDTO getStudentCompetencyMetrics(long userId, long courseId) {
final var competencyInfo = competencyMetricsApi.findAllCompetencyInformationByCourseId(courseId);
final var competencyInfo = competencyMetricsRepository.findAllCompetencyInformationByCourseId(courseId);
final var competencyInfoMap = competencyInfo.stream().collect(toMap(CompetencyInformationDTO::id, identity()));

final var competencyIds = competencyInfoMap.keySet();

final var competencyExerciseMapEntries = competencyMetricsApi.findAllExerciseIdsByCompetencyIds(competencyIds);
final var competencyExerciseMapEntries = competencyMetricsRepository.findAllExerciseIdsByCompetencyIds(competencyIds);
final var exerciseMap = competencyExerciseMapEntries.stream().collect(groupingBy(MapEntryLongLong::key, mapping(MapEntryLongLong::value, toSet())));

final var competencyLectureUnitMapEntries = competencyMetricsApi.findAllLectureUnitIdsByCompetencyIds(competencyIds);
final var competencyLectureUnitMapEntries = competencyMetricsRepository.findAllLectureUnitIdsByCompetencyIds(competencyIds);
final var lectureUnitMap = competencyLectureUnitMapEntries.stream().collect(groupingBy(MapEntryLongLong::key, mapping(MapEntryLongLong::value, toSet())));

final var competencyProgress = competencyMetricsApi.findAllCompetencyProgressForUserByCompetencyIds(userId, competencyIds);
final var competencyProgress = competencyMetricsRepository.findAllCompetencyProgressForUserByCompetencyIds(userId, competencyIds);
final var competencyProgressMap = competencyProgress.stream().collect(toMap(CompetencyProgressDTO::competencyId, CompetencyProgressDTO::progress));
final var competencyConfidenceMap = competencyProgress.stream().collect(toMap(CompetencyProgressDTO::competencyId, CompetencyProgressDTO::confidence));

final var currentJolValues = competencyMetricsApi.findAllLatestCompetencyJolValuesForUserByCompetencyIds(userId, competencyIds);
final var currentJolValues = competencyMetricsRepository.findAllLatestCompetencyJolValuesForUserByCompetencyIds(userId, competencyIds);
final var currentJolValuesMap = currentJolValues.stream().collect(toMap(CompetencyJolDTO::competencyId, identity()));

final var currentJolIds = currentJolValues.stream().map(CompetencyJolDTO::id).collect(toSet());
final var priorJolValues = competencyMetricsApi.findAllLatestCompetencyJolValuesForUserByCompetencyIdsExcludeJolIds(userId, competencyIds, currentJolIds);
final var priorJolValues = competencyMetricsRepository.findAllLatestCompetencyJolValuesForUserByCompetencyIdsExcludeJolIds(userId, competencyIds, currentJolIds);
final var priorJolValuesMap = priorJolValues.stream().collect(toMap(CompetencyJolDTO::competencyId, identity()));

return new CompetencyStudentMetricsDTO(competencyInfoMap, exerciseMap, lectureUnitMap, competencyProgressMap, competencyConfidenceMap, currentJolValuesMap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyJol;
import de.tum.cit.aet.artemis.atlas.dto.CompetencyJolDTO;
import de.tum.cit.aet.artemis.atlas.service.LearningMetricsService;
import de.tum.cit.aet.artemis.core.domain.Course;
import de.tum.cit.aet.artemis.core.repository.CourseRepository;
import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation;
import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository;
import de.tum.cit.aet.artemis.exercise.service.LearningMetricsService;
import de.tum.cit.aet.artemis.iris.domain.session.IrisCourseChatSession;
import de.tum.cit.aet.artemis.iris.domain.session.IrisExerciseChatSession;
import de.tum.cit.aet.artemis.iris.exception.IrisException;
Expand Down

0 comments on commit 59bc157

Please sign in to comment.