Search in sources :

Example 6 with IndividualLearningGoalProgress

use of de.tum.in.www1.artemis.web.rest.dto.IndividualLearningGoalProgress in project ArTEMiS by ls1intum.

the class LearningGoalIntegrationTest method getLearningGoalProgress_asStudent1_shouldReturnProgressTenOutOfTwenty.

@Test
@WithMockUser(username = "student1", roles = "USER")
public void getLearningGoalProgress_asStudent1_shouldReturnProgressTenOutOfTwenty() throws Exception {
    IndividualLearningGoalProgress individualLearningGoalProgress = request.get("/api/courses/" + idOfCourse + "/goals/" + idOfLearningGoal + "/individual-progress", HttpStatus.OK, IndividualLearningGoalProgress.class);
    assertThat(individualLearningGoalProgress.totalPointsAchievableByStudentsInLearningGoal).isEqualTo(30.0);
    assertThat(individualLearningGoalProgress.pointsAchievedByStudentInLearningGoal).isEqualTo(10.0);
}
Also used : IndividualLearningGoalProgress(de.tum.in.www1.artemis.web.rest.dto.IndividualLearningGoalProgress) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 7 with IndividualLearningGoalProgress

use of de.tum.in.www1.artemis.web.rest.dto.IndividualLearningGoalProgress in project ArTEMiS by ls1intum.

the class LearningGoalIntegrationTest method getLearningGoalProgress_asTeam1Student1_usingParticipantScores_shouldReturnProgressTenOutOfThirty.

@Test
@WithMockUser(username = "team1student1", roles = "USER")
public void getLearningGoalProgress_asTeam1Student1_usingParticipantScores_shouldReturnProgressTenOutOfThirty() throws Exception {
    IndividualLearningGoalProgress individualLearningGoalProgress = request.get("/api/courses/" + idOfCourse + "/goals/" + idOfLearningGoal + "/individual-progress?useParticipantScoreTable=true", HttpStatus.OK, IndividualLearningGoalProgress.class);
    assertThat(individualLearningGoalProgress.totalPointsAchievableByStudentsInLearningGoal).isEqualTo(30.0);
    assertThat(individualLearningGoalProgress.pointsAchievedByStudentInLearningGoal).isEqualTo(5.0);
}
Also used : IndividualLearningGoalProgress(de.tum.in.www1.artemis.web.rest.dto.IndividualLearningGoalProgress) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 8 with IndividualLearningGoalProgress

use of de.tum.in.www1.artemis.web.rest.dto.IndividualLearningGoalProgress in project Artemis by ls1intum.

the class LearningGoalIntegrationTest method getLearningGoalProgress_asStudent1_shouldReturnProgressTenOutOfTwenty.

@Test
@WithMockUser(username = "student1", roles = "USER")
public void getLearningGoalProgress_asStudent1_shouldReturnProgressTenOutOfTwenty() throws Exception {
    IndividualLearningGoalProgress individualLearningGoalProgress = request.get("/api/courses/" + idOfCourse + "/goals/" + idOfLearningGoal + "/individual-progress", HttpStatus.OK, IndividualLearningGoalProgress.class);
    assertThat(individualLearningGoalProgress.totalPointsAchievableByStudentsInLearningGoal).isEqualTo(30.0);
    assertThat(individualLearningGoalProgress.pointsAchievedByStudentInLearningGoal).isEqualTo(10.0);
}
Also used : IndividualLearningGoalProgress(de.tum.in.www1.artemis.web.rest.dto.IndividualLearningGoalProgress) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 9 with IndividualLearningGoalProgress

use of de.tum.in.www1.artemis.web.rest.dto.IndividualLearningGoalProgress in project Artemis by ls1intum.

the class LearningGoalService method calculateLearningGoalProgress.

/**
 * Calculate the progress in a learning goal for a specific user
 *
 * @param learningGoal             learning goal to get the progress for
 * @param user                     user to get the progress for
 * @param useParticipantScoreTable use the participant score table instead of going through participation -> submission -> result
 * @return progress of the user in the learning goal
 */
public IndividualLearningGoalProgress calculateLearningGoalProgress(LearningGoal learningGoal, User user, boolean useParticipantScoreTable) {
    IndividualLearningGoalProgress individualLearningGoalProgress = new IndividualLearningGoalProgress();
    individualLearningGoalProgress.studentId = user.getId();
    individualLearningGoalProgress.learningGoalId = learningGoal.getId();
    individualLearningGoalProgress.learningGoalTitle = learningGoal.getTitle();
    individualLearningGoalProgress.totalPointsAchievableByStudentsInLearningGoal = 0.0;
    individualLearningGoalProgress.pointsAchievedByStudentInLearningGoal = 0.0;
    // The progress will be calculated from a subset of the connected lecture units (currently only from released exerciseUnits)
    Set<ExerciseUnit> exerciseUnitsUsableForProgressCalculation = learningGoal.getLectureUnits().parallelStream().filter(LectureUnit::isVisibleToStudents).filter(lectureUnit -> lectureUnit instanceof ExerciseUnit).map(lectureUnit -> (ExerciseUnit) lectureUnit).collect(Collectors.toSet());
    Set<IndividualLearningGoalProgress.IndividualLectureUnitProgress> progressInLectureUnits = this.calculateExerciseUnitsProgress(exerciseUnitsUsableForProgressCalculation, user, useParticipantScoreTable);
    // updating learningGoalPerformance by summing up the points of the individual lecture unit performances
    individualLearningGoalProgress.totalPointsAchievableByStudentsInLearningGoal = progressInLectureUnits.stream().map(individualLectureUnitProgress -> individualLectureUnitProgress.totalPointsAchievableByStudentsInLectureUnit).reduce(0.0, Double::sum);
    individualLearningGoalProgress.pointsAchievedByStudentInLearningGoal = progressInLectureUnits.stream().map(individualLectureUnitProgress -> (individualLectureUnitProgress.scoreAchievedByStudentInLectureUnit / 100.0) * individualLectureUnitProgress.totalPointsAchievableByStudentsInLectureUnit).reduce(0.0, Double::sum);
    individualLearningGoalProgress.progressInLectureUnits = new ArrayList<>(progressInLectureUnits);
    return individualLearningGoalProgress;
}
Also used : java.util(java.util) TeamScore(de.tum.in.www1.artemis.domain.scores.TeamScore) de.tum.in.www1.artemis.repository(de.tum.in.www1.artemis.repository) StudentScore(de.tum.in.www1.artemis.domain.scores.StudentScore) Collectors(java.util.stream.Collectors) CourseLearningGoalProgress(de.tum.in.www1.artemis.web.rest.dto.CourseLearningGoalProgress) Stream(java.util.stream.Stream) de.tum.in.www1.artemis.domain(de.tum.in.www1.artemis.domain) LectureUnit(de.tum.in.www1.artemis.domain.lecture.LectureUnit) Service(org.springframework.stereotype.Service) ExerciseUnit(de.tum.in.www1.artemis.domain.lecture.ExerciseUnit) CourseExerciseStatisticsDTO(de.tum.in.www1.artemis.web.rest.dto.CourseExerciseStatisticsDTO) StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) ParticipantScore(de.tum.in.www1.artemis.domain.scores.ParticipantScore) IndividualLearningGoalProgress(de.tum.in.www1.artemis.web.rest.dto.IndividualLearningGoalProgress) ExerciseUnit(de.tum.in.www1.artemis.domain.lecture.ExerciseUnit) IndividualLearningGoalProgress(de.tum.in.www1.artemis.web.rest.dto.IndividualLearningGoalProgress)

Example 10 with IndividualLearningGoalProgress

use of de.tum.in.www1.artemis.web.rest.dto.IndividualLearningGoalProgress in project ArTEMiS by ls1intum.

the class LearningGoalService method calculateLearningGoalProgress.

/**
 * Calculate the progress in a learning goal for a specific user
 *
 * @param learningGoal             learning goal to get the progress for
 * @param user                     user to get the progress for
 * @param useParticipantScoreTable use the participant score table instead of going through participation -> submission -> result
 * @return progress of the user in the learning goal
 */
public IndividualLearningGoalProgress calculateLearningGoalProgress(LearningGoal learningGoal, User user, boolean useParticipantScoreTable) {
    IndividualLearningGoalProgress individualLearningGoalProgress = new IndividualLearningGoalProgress();
    individualLearningGoalProgress.studentId = user.getId();
    individualLearningGoalProgress.learningGoalId = learningGoal.getId();
    individualLearningGoalProgress.learningGoalTitle = learningGoal.getTitle();
    individualLearningGoalProgress.totalPointsAchievableByStudentsInLearningGoal = 0.0;
    individualLearningGoalProgress.pointsAchievedByStudentInLearningGoal = 0.0;
    // The progress will be calculated from a subset of the connected lecture units (currently only from released exerciseUnits)
    Set<ExerciseUnit> exerciseUnitsUsableForProgressCalculation = learningGoal.getLectureUnits().parallelStream().filter(LectureUnit::isVisibleToStudents).filter(lectureUnit -> lectureUnit instanceof ExerciseUnit).map(lectureUnit -> (ExerciseUnit) lectureUnit).collect(Collectors.toSet());
    Set<IndividualLearningGoalProgress.IndividualLectureUnitProgress> progressInLectureUnits = this.calculateExerciseUnitsProgress(exerciseUnitsUsableForProgressCalculation, user, useParticipantScoreTable);
    // updating learningGoalPerformance by summing up the points of the individual lecture unit performances
    individualLearningGoalProgress.totalPointsAchievableByStudentsInLearningGoal = progressInLectureUnits.stream().map(individualLectureUnitProgress -> individualLectureUnitProgress.totalPointsAchievableByStudentsInLectureUnit).reduce(0.0, Double::sum);
    individualLearningGoalProgress.pointsAchievedByStudentInLearningGoal = progressInLectureUnits.stream().map(individualLectureUnitProgress -> (individualLectureUnitProgress.scoreAchievedByStudentInLectureUnit / 100.0) * individualLectureUnitProgress.totalPointsAchievableByStudentsInLectureUnit).reduce(0.0, Double::sum);
    individualLearningGoalProgress.progressInLectureUnits = new ArrayList<>(progressInLectureUnits);
    return individualLearningGoalProgress;
}
Also used : java.util(java.util) TeamScore(de.tum.in.www1.artemis.domain.scores.TeamScore) de.tum.in.www1.artemis.repository(de.tum.in.www1.artemis.repository) StudentScore(de.tum.in.www1.artemis.domain.scores.StudentScore) Collectors(java.util.stream.Collectors) CourseLearningGoalProgress(de.tum.in.www1.artemis.web.rest.dto.CourseLearningGoalProgress) Stream(java.util.stream.Stream) de.tum.in.www1.artemis.domain(de.tum.in.www1.artemis.domain) LectureUnit(de.tum.in.www1.artemis.domain.lecture.LectureUnit) Service(org.springframework.stereotype.Service) ExerciseUnit(de.tum.in.www1.artemis.domain.lecture.ExerciseUnit) CourseExerciseStatisticsDTO(de.tum.in.www1.artemis.web.rest.dto.CourseExerciseStatisticsDTO) StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) ParticipantScore(de.tum.in.www1.artemis.domain.scores.ParticipantScore) IndividualLearningGoalProgress(de.tum.in.www1.artemis.web.rest.dto.IndividualLearningGoalProgress) ExerciseUnit(de.tum.in.www1.artemis.domain.lecture.ExerciseUnit) IndividualLearningGoalProgress(de.tum.in.www1.artemis.web.rest.dto.IndividualLearningGoalProgress)

Aggregations

IndividualLearningGoalProgress (de.tum.in.www1.artemis.web.rest.dto.IndividualLearningGoalProgress)10 Test (org.junit.jupiter.api.Test)8 WithMockUser (org.springframework.security.test.context.support.WithMockUser)8 de.tum.in.www1.artemis.domain (de.tum.in.www1.artemis.domain)2 ExerciseUnit (de.tum.in.www1.artemis.domain.lecture.ExerciseUnit)2 LectureUnit (de.tum.in.www1.artemis.domain.lecture.LectureUnit)2 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)2 ParticipantScore (de.tum.in.www1.artemis.domain.scores.ParticipantScore)2 StudentScore (de.tum.in.www1.artemis.domain.scores.StudentScore)2 TeamScore (de.tum.in.www1.artemis.domain.scores.TeamScore)2 de.tum.in.www1.artemis.repository (de.tum.in.www1.artemis.repository)2 CourseExerciseStatisticsDTO (de.tum.in.www1.artemis.web.rest.dto.CourseExerciseStatisticsDTO)2 CourseLearningGoalProgress (de.tum.in.www1.artemis.web.rest.dto.CourseLearningGoalProgress)2 java.util (java.util)2 Collectors (java.util.stream.Collectors)2 Stream (java.util.stream.Stream)2 Service (org.springframework.stereotype.Service)2