Skip to content

fix(achievements): Graduate achievements only unlock when all kanji for the specific JLPT level are mastered#7152

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-graduate-achievements-bug
Draft

fix(achievements): Graduate achievements only unlock when all kanji for the specific JLPT level are mastered#7152
Copilot wants to merge 2 commits intomainfrom
copilot/fix-graduate-achievements-bug

Conversation

Copy link
Contributor

Copilot AI commented Mar 4, 2026

checkContentMastery for contentType === 'kanji' ignored jlptLevel entirely — it checked whatever kanji happened to be in characterMastery, so practicing a handful of N5 kanji with ≥80% accuracy trivially satisfied N4–N1 Graduate checks as well.

Root cause

// Before — jlptLevel from achievement.requirements.additional is never used
} else if (contentType === 'kanji') {
  relevantEntries = entries.filter(([key]) => isSingleKanji(key)); // all kanji, any level
}

Changes

  • store/kanjiSets.ts (new) — Static Set<string> per JLPT level extracted from public/data-kanji/*.json (N5: 80, N4: 167, N3: 370, N2: 374, N1: 1504 chars), plus a KANJI_BY_JLPT_LEVEL lookup map. Same pattern as the existing BASIC_HIRAGANA/BASIC_KATAKANA sets.

  • checkContentMastery — Kanji branch now requires jlptLevel, scopes relevantEntries to only that level's set, and guards relevantEntries.length < kanjiSet.size so all kanji in the level must have been practiced before the achievement can unlock:

    } else if (contentType === 'kanji') {
      const jlptLevel = additional?.jlptLevel;
      if (!jlptLevel) return false;
      const kanjiSet = KANJI_BY_JLPT_LEVEL[jlptLevel];
      relevantEntries = entries.filter(([key]) => kanjiSet.has(key));
      if (relevantEntries.length < kanjiSet.size) return false;
    }
  • useAchievementProgress.ts — Progress for kanji Graduate achievements now displays masteredCount / kanjiSet.size (count of level-specific kanji at ≥80% accuracy) instead of a static 0%.

  • __tests__/kanjiGraduate.test.ts (new) — Regression tests covering: correct set sizes, practicing only N5 does not unlock N4–N1, partial N5 practice does not unlock N5, below-threshold accuracy does not unlock, and each level checks its own set.

Original prompt

This section details on the original issue you should resolve

<issue_title>[BUG] N4 to N1 Graduate achievements achieved before completed</issue_title>
<issue_description>## 🐛 Bug Description

I was just finished my first session in Kanji dojo practicing the level 1 in N5. After I completed the session, I've got a few achievements, some of them are the N5 to N1 Graduate which requires 80% of accuracy on the practices of each level. Since I only practiced N5 Kanji Training once, and haven't tried any other units yet, I don't think I'm supposed to get the Graduate achievements for N4 to N1.

📋 Steps to Reproduce

  1. Start a Kanji Training for the first time and finish it.
  2. You'll get the achievements mentioned before.

🎯 Expected Behavior

User should get the Graduate achievements according to what units they practiced.

📸 Screenshots

Screenshot_20260303_172202.jpg

📱 Environment Information

  • Browser: Cromite 145.0.7632.120
  • Operating System: Android 14
  • Device: Mobile

🔍 Additional Context

None

Thank you for helping improve KanaDojo! 🙏
</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

The checkContentMastery function was ignoring jlptLevel for kanji,
checking ALL kanji in characterMastery instead of only those belonging
to the specific JLPT level. This caused N4-N1 Graduate achievements to
unlock when only N5 kanji had been practiced.

- Add kanjiSets.ts with static character Sets per JLPT level (N5-N1)
- Fix checkContentMastery to filter kanji by jlptLevel and require ALL
  kanji from that level to have been practiced with >=80% accuracy
- Improve progress calculation in useAchievementProgress.ts to show
  actual kanji mastery count (X/Y) for Graduate achievements
- Add kanjiGraduate.test.ts with 8 regression tests

Co-authored-by: tentoumushii <169354375+tentoumushii@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix graduate achievements awarded incorrectly fix(achievements): Graduate achievements only unlock when all kanji for the specific JLPT level are mastered Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] N4 to N1 Graduate achievements achieved before completed

2 participants