From febd63c8e5f077d91c7ed8230b3411b32a2a49e8 Mon Sep 17 00:00:00 2001 From: myluki2000 Date: Sun, 14 Sep 2025 23:38:52 +0200 Subject: [PATCH 1/3] Add/rebalance achievements --- .../DefaultCourseAchievementMapper.java | 87 +++++++++++++------ 1 file changed, 59 insertions(+), 28 deletions(-) diff --git a/src/main/java/de/unistuttgart/iste/meitrex/gamification_service/service/internal/achievements/DefaultCourseAchievementMapper.java b/src/main/java/de/unistuttgart/iste/meitrex/gamification_service/service/internal/achievements/DefaultCourseAchievementMapper.java index 63573ee7..7f4a47ba 100644 --- a/src/main/java/de/unistuttgart/iste/meitrex/gamification_service/service/internal/achievements/DefaultCourseAchievementMapper.java +++ b/src/main/java/de/unistuttgart/iste/meitrex/gamification_service/service/internal/achievements/DefaultCourseAchievementMapper.java @@ -7,10 +7,7 @@ import jakarta.persistence.EntityNotFoundException; import org.springframework.stereotype.Component; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Objects; +import java.util.*; import java.util.function.Function; @Component @@ -18,7 +15,7 @@ class DefaultCourseAchievementMapper implements ICourseAchievementMapper { @FunctionalInterface interface IAchievementSource { - AchievementEntity create(CourseEntity course); + Optional create(CourseEntity course); } // Functional constructors @@ -47,8 +44,10 @@ public DefaultCourseAchievementMapper() { this.achievementSourceList.add(this::generateForumAnswerer); this.achievementSourceList.add(this::generateLoginAchievement); this.achievementSourceList.add(this::generateQuizzerAchievement); - this.achievementSourceList.add(this::generateActiveAchievement); - + this.achievementSourceList.add(this::generateFirstStartAchievement); + this.achievementSourceList.add(this::generateGamblerAchievement); + this.achievementSourceList.add(this::generateFastFashionAchievement); + this.achievementSourceList.add(this::generateCuriousAchievement); } @Override @@ -57,39 +56,39 @@ public List map(CourseEntity course) { final Function courseAchievementLinker = createLinker(course); return this.achievementSourceList .stream() - .map(source -> source.create(course)) + .flatMap(source -> source.create(course).stream()) .map(courseAchievementLinker) .toList(); } // Sources - public AchievementEntity generateQuizMaster(CourseEntity course) { + public Optional generateQuizMaster(CourseEntity course) { AchievementEntity quizMaster = create("Quiz Master", ""); CompletedQuizzesGoalEntity quizMasterGoal = new CompletedQuizzesGoalEntity(); quizMasterGoal.setMinimumScore(1.0F); - quizMasterGoal.setRequiredCount(1); + quizMasterGoal.setRequiredCount(5); quizMaster.setGoal(quizMasterGoal); - return quizMaster; + return Optional.of(quizMaster); } - public AchievementEntity generateForumAnswerer(CourseEntity course) { + public Optional generateForumAnswerer(CourseEntity course) { AchievementEntity forumAnswerer = create("Forum Answer", ""); AnswerForumQuestionGoalEntity forumAnswerGoal = new AnswerForumQuestionGoalEntity(); - forumAnswerGoal.setRequiredCount(1); + forumAnswerGoal.setRequiredCount(3); forumAnswerer.setGoal(forumAnswerGoal); - return forumAnswerer; + return Optional.of(forumAnswerer); } - public AchievementEntity generateLoginAchievement(CourseEntity course) { + public Optional generateLoginAchievement(CourseEntity course) { AchievementEntity loginAchievement = create("Login Achievement", ""); LoginStreakGoalEntity loginStreakGoal = new LoginStreakGoalEntity(); - loginStreakGoal.setRequiredCount(2); + loginStreakGoal.setRequiredCount(3); loginAchievement.setGoal(loginStreakGoal); - return loginAchievement; + return Optional.of(loginAchievement); } - public AchievementEntity generateQuizzerAchievement(CourseEntity course) { + public Optional generateQuizzerAchievement(CourseEntity course) { AchievementEntity quizzer = create("Quizzer", ""); CompletedQuizzesGoalEntity quizzerGoal1 = new CompletedQuizzesGoalEntity(); quizzerGoal1.setMinimumScore(1.0F); @@ -101,23 +100,55 @@ public AchievementEntity generateQuizzerAchievement(CourseEntity course) { orCombinatorGoalEntity.setGoal1(quizzerGoal1); orCombinatorGoalEntity.setGoal2(quizzerGoal2); quizzer.setGoal(orCombinatorGoalEntity); - return quizzer; + return Optional.of(quizzer); } - public AchievementEntity generateActiveAchievement(CourseEntity course) { - AchievementEntity activeUser = create("Active User", ""); + public Optional generateFirstStartAchievement(CourseEntity course) { + AchievementEntity activeUser = create("A First Start", ""); LoginStreakGoalEntity loginStreakGoal = new LoginStreakGoalEntity(); - loginStreakGoal.setRequiredCount(7); + loginStreakGoal.setRequiredCount(1); CompleteSpecificChapterGoalEntity completeSpecificChapterGoalEntity = new CompleteSpecificChapterGoalEntity(); - Chapter firstChapter = course.getChapters().stream() - .min(Comparator.comparingInt(Chapter::getNumber)) - .orElseThrow(() -> new EntityNotFoundException("Chapter List empty")); - completeSpecificChapterGoalEntity.setChapterId(firstChapter.getId()); - completeSpecificChapterGoalEntity.setChapterName(firstChapter.getTitle()); + Optional firstChapter = course.getChapters().stream() + .min(Comparator.comparingInt(Chapter::getNumber)); + + if (firstChapter.isEmpty()) + return Optional.empty(); + + completeSpecificChapterGoalEntity.setChapterId(firstChapter.get().getId()); + completeSpecificChapterGoalEntity.setChapterName(firstChapter.get().getTitle()); AndCombinatorGoalEntity andCombinatorGoalEntity = new AndCombinatorGoalEntity(); andCombinatorGoalEntity.setGoal1(loginStreakGoal); andCombinatorGoalEntity.setGoal2(completeSpecificChapterGoalEntity); activeUser.setGoal(andCombinatorGoalEntity); - return activeUser; + return Optional.of(activeUser); + } + + public Optional generateGamblerAchievement(CourseEntity course) { + AchievementEntity gamblerAchievement = create("Gambler", ""); + + LotteryRunGoalEntity lotteryRunGoal = new LotteryRunGoalEntity(); + lotteryRunGoal.setRequiredCount(5); + gamblerAchievement.setGoal(lotteryRunGoal); + + return Optional.of(gamblerAchievement); + } + + public Optional generateFastFashionAchievement(CourseEntity course) { + AchievementEntity fastFashion = create("Fast Fashion", ""); + + ReceiveItemsGoalEntity receiveItemsGoalEntity = new ReceiveItemsGoalEntity(); + receiveItemsGoalEntity.setRequiredCount(5); + fastFashion.setGoal(receiveItemsGoalEntity); + + return Optional.of(fastFashion); + } + + public Optional generateCuriousAchievement(CourseEntity course) { + AchievementEntity curiousAchievement = create("Curious", ""); + + AskTutorCourseQuestionsGoalEntity askTutorCourseQuestionsGoalEntity = new AskTutorCourseQuestionsGoalEntity(); + askTutorCourseQuestionsGoalEntity.setRequiredCount(5); + curiousAchievement.setGoal(askTutorCourseQuestionsGoalEntity); + return Optional.of(curiousAchievement); } } From ca70c4ee643873dd52c4478662dc8bec36822d79 Mon Sep 17 00:00:00 2001 From: myluki2000 Date: Mon, 6 Oct 2025 22:36:00 +0200 Subject: [PATCH 2/3] set starting capital to 0 --- src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 28a72eba..b551af94 100755 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -30,7 +30,7 @@ management.health.readinessState.enabled=true app.achievements.completion-reward=1000 -app.items.default-starting-capital=10000 +app.items.default-starting-capital=0 app.adaptivity.max-adaptive-achievement-count=999 app.adaptivity.skill-level-quest-min-bloom-score=0.8 From a804ca9547e9444bcfd7f58d9833b9d09bb83f65 Mon Sep 17 00:00:00 2001 From: Lukas Date: Tue, 7 Oct 2025 16:21:57 +0200 Subject: [PATCH 3/3] Change starting capital to 500 --- src/main/resources/application.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index b551af94..8deee95b 100755 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -30,7 +30,7 @@ management.health.readinessState.enabled=true app.achievements.completion-reward=1000 -app.items.default-starting-capital=0 +app.items.default-starting-capital=500 app.adaptivity.max-adaptive-achievement-count=999 app.adaptivity.skill-level-quest-min-bloom-score=0.8 @@ -53,4 +53,4 @@ app.adaptivity.widget-recommendation-max-feedback-request-interval-days=30 logging.level.org.hibernate.SQL=OFF logging.level.org.hibernate.orm.jdbc.bind=OFF logging.level.org.hibernate.type.descriptor.sql=OFF -logging.level.org.hibernate.type.descriptor.sql.BasicBinder=OFF \ No newline at end of file +logging.level.org.hibernate.type.descriptor.sql.BasicBinder=OFF