Definitions & Constants - Learn English Zero

Status: Single Source of Truth Last Updated: 2026-01-09 Purpose: Tất cả các file design khác PHẢI reference file này cho constants.


1. Prescription Types

1.1 Master List

ID Database Value Display Name (VI) Display Name (EN)
RX_MU don_mu Đơn Mù - Học Từ Vựng Vocabulary Prescription
RX_DIEC don_diec Đơn Điếc - Luyện Nghe Listening Prescription
RX_CAM don_cam Đơn Câm - Luyện Phát Âm Speaking Prescription
RX_PHAN_XA don_yeu_phan_xa Đơn Phản Xạ Reflex Prescription
RX_FOUNDATION don_foundation Đơn Nền Tảng Foundation Prescription

1.2 Prescription Duration

Tất cả prescriptions đều 120 ngày. Sự khác biệt là tỷ trọng content:

Prescription Từ vựng Nghe Phát âm Phản xạ Daily New Words
RX_MU 70% 10% 10% 10% 25
RX_DIEC 20% 50% 20% 10% 10
RX_CAM 20% 10% 60% 10% 10
RX_PHAN_XA 20% 10% 10% 60% 10
RX_FOUNDATION 35% 35% 15% 15% 15

2. CEFR Levels & Phases

2.1 Level Mapping

Level Phase Days Words
A1 Phase 1 1-40 1,000
A2 Phase 2 41-80 1,000
B1 Phase 3 81-120 1,000

Total: 120 days, 3,000 words

2.2 Checkpoint Tests

Day Level Words Tested Duration Pass Threshold
40 A1 1,000 ~30 min 70%
80 A2 1,000 ~30 min 70%
120 All 500 (sampled) ~15 min 70%

3. Streak System

3.1 Grace Period

Days Missed Streak Status AI Coach Action
0 Active Normal
1 Grace 1/3 No action
2 Grace 2/3 Gentle nudge
3 Grace 3/3 Warning (streak reset tomorrow)
4+ RESET Caring message + show longest streak

3.2 Reset Timing

  • Streak reset xảy ra vào 00:00 ngày thứ 4 (theo user timezone)
  • User có thể học vào ngày 3 để cứu streak

4. Milestones

4.1 Word Milestones

Words AI Module Message Trigger
100 milestone_100_words total_words_learned >= 100
500 milestone_500_words total_words_learned >= 500
1,500 milestone_1500_words total_words_learned >= 1500
3,000 milestone_3000_words total_words_learned >= 3000

4.2 Day Milestones

Day AI Module Message Trigger
7 milestone_7day_streak streak_current >= 7
30 milestone_month_1 current_day >= 30
60 milestone_month_2 current_day >= 60
90 milestone_month_3 current_day >= 90
120 milestone_completion current_day >= 120

5. Disease Types (4 Bệnh)

ID Vietnamese Name English Name Test Focus
MU Vocabulary Blindness Reading comprehension
DIEC Điếc Listening Deafness Listening comprehension
CAM Câm Speaking Muteness Pronunciation
PHAN_XA Yếu phản xạ Slow Reflex Response speed

5.1 Severity Thresholds

Disease Nặng (Severe) Trung Bình Nhẹ (Mild)
< 50% correct 50-70% > 70%
Điếc < 45% correct 45-65% > 65%
Câm < 30% correct 30-55% > 55%
Phản xạ < 30% correct 30-60% > 60%

6. AI Coach Configuration

6.1 Naming

  • AI self-reference: "mình"
  • User reference: "bạn"
  • Custom name: stored in user_profiles.preferred_ai_name

6.2 Conversation Types

vocabulary_question
motivation
scenario_practice
general
milestone_celebration
missed_day_nudge
boundary_redirect
pronunciation_feedback
quiz_feedback

7. Database Enums

7.1 prescription_type (user_diagnosis_results)

'don_mu', 'don_diec', 'don_cam', 'don_yeu_phan_xa', 'don_foundation'

7.2 difficulty_level (words)

'A1', 'A2', 'B1'

7.3 status (user_word_progress)

'new', 'learning', 'mastered', 'forgotten'

7.4 previous_learning_experience (user_profiles)

'school', 'center', 'self', 'never'

7.5 available_study_time_minutes (user_profiles)

15, 30, 45, 60

7.6 status (user_daily_progress)

'not_started', 'in_progress', 'completed'

8. Time Constants

Constant Value Usage
TOTAL_DAYS 120 Lộ trình học
DAILY_NEW_WORDS_MU 25 RX_MU daily load
DAILY_NEW_WORDS_OTHER 10 RX_DIEC/CAM/PHAN_XA daily load
DAILY_NEW_WORDS_FOUNDATION 15 RX_FOUNDATION daily load
DAILY_REVIEW_WORDS 10 Approximate review
GRACE_PERIOD_DAYS 3 Streak grace period
SM2_DEFAULT_EASE_FACTOR 2.5 Initial ease factor
SM2_MIN_EASE_FACTOR 1.3 Minimum ease factor
SM2_INITIAL_INTERVAL_1 1 First interval (days)
SM2_INITIAL_INTERVAL_2 6 Second interval (days)
SM2_MAX_INTERVAL 180 Max review interval (days)
CHECKPOINT_PASS_RATE 0.70 70% to pass

9. AI Coach Module to Database Mapping

Module Name (Internal) Database conversation_type Trigger Condition
motivation_streak motivation Streak milestone reached
missed_day missed_day_nudge User missed 2-3 days
quiz_wrong_answer quiz_feedback User fails quiz question
pronunciation_feedback pronunciation_feedback After pronunciation attempt
boundary_redirect boundary_redirect User asks about IELTS/Business English
milestone_celebration milestone_celebration Any milestone reached
vocabulary_question vocabulary_question User asks about a word
scenario_practice scenario_practice User requests conversation practice
general general Default/uncategorized

Note: Specific milestone modules (milestone_100_words, milestone_7day_streak, etc.) all map to milestone_celebration in database but use different prompt templates internally.


Usage Instructions

Khi cần reference constants:

  1. Check file này trước
  2. Copy exact values
  3. Không tự định nghĩa khác
  4. Nếu cần thay đổi, update file này TRƯỚC, rồi sync tất cả files khác

Files cần sync khi update:

  • database-schema.md
  • diagnosis-test.md
  • don-mu-vocabulary.md
  • gamification.md
  • ai-coach-behavior.md
  • user-flow.md

Change Log

Date Change Author
2026-01-09 Initial creation Claude