Files
Speech/apps/api/internal/domain/models.go
T
Eugenius Naumenko 16cceae28a Muttersprache koppeln und russischen A1-Kurs ergänzen
GUI und neue Erklärungen verwenden gemeinsam native_language. Deutsch und
Russisch sind die beiden Muttersprachen; Englisch bleibt die Lernsprache.
Kompatibilitätsfelder werden atomar gekoppelt, widersprüchliche Eingaben
abgewiesen und bestehende Profile sowie eingefrorene Inhalte erhalten.

Ergänzt vollständige russische GUI-Kataloge und 840 geprüfte Aufgabenansichten
in sieben Modulen einschließlich A1-Test, mit getrennten Sprachrollen für
Ausgangs- und Lernmaterial. Äquivalente Ansichten teilen ihre Nachweisidentität.
Stabile API-Fehlercodes, neue deterministische Hilfen und Trainingsbegründungen
berücksichtigen die Muttersprache. Dokumentiert das Sprachmodell in AGENTS.md.

Validierung: Go-Race-Suite mit eigener lokaler PostgreSQL-Testdatenbank, go vet,
Web-Build, Offline-Bank-/Variantenaudit, Diff-Prüfung sowie lokale Browser-Smokes
für Sprachen, Kurs, Administration, Aussprache und Aufnahme. Keine Live-Anbieter,
Produktionsprofile, Deployment-Schritte oder historischen Neubewertungen.
2026-11-07 17:02:17 +00:00

309 lines
11 KiB
Go

package domain
import (
"errors"
"time"
)
type User struct {
ID string `json:"id"`
NativeLanguage string `json:"native_language"`
Email string `json:"email"`
UILanguage string `json:"ui_language"`
InstructionLanguage string `json:"instruction_language"`
Role string `json:"role"`
CreatedAt time.Time `json:"created_at"`
}
// Compatibility fields mirror NativeLanguage; they are never separate preferences.
func (u User) ExplanationLanguage() string {
if SupportedNativeLanguage(u.NativeLanguage) {
return u.NativeLanguage
}
if SupportedNativeLanguage(u.UILanguage) {
return u.UILanguage
}
return "de-DE"
}
var ErrNativeLanguageUnsupported = errors.New("unsupported native language")
var ErrNativeLanguageConflict = errors.New("conflicting native language fields")
func SupportedNativeLanguage(language string) bool { return language == "de-DE" || language == "ru-RU" }
func SupportedUILanguage(language string) bool { return SupportedNativeLanguage(language) }
// ResolveNativeLanguage accepts old client aliases only if all provided values agree.
func ResolveNativeLanguage(values ...string) (string, error) {
selected := ""
for _, value := range values {
if value == "" {
continue
}
if !SupportedNativeLanguage(value) {
return "", ErrNativeLanguageUnsupported
}
if selected != "" && selected != value {
return "", ErrNativeLanguageConflict
}
selected = value
}
return selected, nil
}
type AdminOverview struct {
UsersTotal int `json:"users_total"`
UsersActive7Days int `json:"users_active_7_days"`
AttemptsTotal int `json:"attempts_total"`
ExercisesGenerated int `json:"exercises_generated"`
AverageScore float64 `json:"average_score"`
}
type AdminUser struct {
ID string `json:"id"`
Email string `json:"email"`
Role string `json:"role"`
CreatedAt time.Time `json:"created_at"`
Attempts int `json:"attempts"`
AverageScore float64 `json:"average_score"`
LastAttempt *time.Time `json:"last_attempt,omitempty"`
}
type AdminUserPage struct {
Users []AdminUser `json:"users"`
Total int `json:"total"`
Page int `json:"page"`
}
type LearnerProfile struct {
ID string `json:"id"`
UserID string `json:"user_id"`
TargetLanguage string `json:"target_language"`
CEFRLevel string `json:"cefr_level"`
DailyGoalMinutes int `json:"daily_goal_minutes"`
CreatedAt time.Time `json:"created_at"`
}
type LanguageProfile struct {
Code string `json:"code"`
DisplayName string `json:"display_name"`
AzureLocale string `json:"azure_locale"`
DefaultTTSVoice string `json:"default_tts_voice"`
Voices []string `json:"voices"`
SupportsPronunciationAssessment bool `json:"supports_pronunciation_assessment"`
SupportsProsody bool `json:"supports_prosody"`
}
type Lesson struct {
ID string `json:"id"`
TargetLanguage string `json:"target_language"`
CEFRLevel string `json:"cefr_level"`
Topic string `json:"topic"`
Title string `json:"title"`
}
type Exercise struct {
InstructionLanguage string `json:"instruction_language,omitempty"`
TrainingReason string `json:"training_reason,omitempty"`
TrainingCategory string `json:"training_category,omitempty"`
ID string `json:"id"`
LessonID string `json:"lesson_id"`
TargetLanguage string `json:"target_language"`
CEFRLevel string `json:"cefr_level"`
Type string `json:"type"`
PromptText string `json:"prompt_text"`
TargetText string `json:"target_text"`
Difficulty int `json:"difficulty"`
Source string `json:"source,omitempty"`
}
type WordScore struct {
AccuracyMeasured *bool `json:"accuracy_measured,omitempty"`
Word string `json:"word"`
Accuracy float64 `json:"accuracy"`
ErrorType string `json:"error_type,omitempty"`
Phonemes []string `json:"phonemes,omitempty"`
PhonemeScores []PhonemeScore `json:"phoneme_scores,omitempty"`
Highlight string `json:"highlight"`
}
type PhonemeScore struct {
Position *int `json:"position,omitempty"`
Phoneme string `json:"phoneme"`
Accuracy float64 `json:"accuracy"`
Highlight string `json:"highlight"`
}
type WeakPhoneme struct {
Word string `json:"word"`
Phoneme string `json:"phoneme"`
Accuracy float64 `json:"accuracy"`
}
type PronunciationResult struct {
Locale string `json:"locale,omitempty"`
Alphabet string `json:"alphabet,omitempty"`
Method string `json:"method,omitempty"`
MeasurementVersion string `json:"measurement_version,omitempty"`
RecognizedText string `json:"recognized_text"`
OverallScore float64 `json:"overall_score"`
AccuracyScore float64 `json:"accuracy_score"`
FluencyScore float64 `json:"fluency_score"`
CompletenessScore float64 `json:"completeness_score"`
ProsodyScore float64 `json:"prosody_score"`
WordScores []WordScore `json:"word_scores"`
Provider string `json:"provider"`
}
type Attempt struct {
Provider string `json:"provider,omitempty"`
Measurement *PronunciationResult `json:"-"`
ID string `json:"id"`
UserID string `json:"user_id"`
ExerciseID string `json:"exercise_id"`
TargetLanguage string `json:"target_language"`
RecognizedText string `json:"recognized_text"`
OverallScore float64 `json:"overall_score"`
AccuracyScore float64 `json:"accuracy_score"`
FluencyScore float64 `json:"fluency_score"`
CompletenessScore float64 `json:"completeness_score"`
ProsodyScore float64 `json:"prosody_score"`
WordScores []WordScore `json:"word_scores"`
TeacherFeedback string `json:"teacher_feedback"`
CreatedAt time.Time `json:"created_at"`
}
type ProgressSummary struct {
TotalAttempts int `json:"total_attempts"`
AverageScore float64 `json:"average_score"`
WeakWords []WordScore `json:"weak_words"`
WeakPhonemes []WeakPhoneme `json:"weak_phonemes"`
RecentAttempts []Attempt `json:"recent_attempts"`
DailyGoalMinutes int `json:"daily_goal_minutes"`
}
type GeneratedExerciseRequest struct {
TrainingPlan *PronunciationPlan `json:"training_plan,omitempty"`
UserID string `json:"user_id"`
Profile LearnerProfile `json:"profile"`
Progress ProgressSummary `json:"progress"`
TargetLanguage string `json:"target_language"`
CEFRLevel string `json:"cefr_level"`
UILanguage string `json:"ui_language"`
SessionID string `json:"session_id"`
RecentWeakWords []WordScore `json:"recent_weak_words"`
PreferredType string `json:"preferred_type"`
AvoidReferenceText string `json:"avoid_reference_text,omitempty"`
AvoidReferenceTexts []string `json:"avoid_reference_texts,omitempty"`
}
type GeneratedExercise struct {
NativeLanguage string `json:"native_language,omitempty"`
TrainingPlan *PronunciationPlan `json:"-"`
CandidateWord string `json:"candidate_word,omitempty"`
ID string `json:"exercise_id"`
ExerciseType string `json:"exercise_type"`
TargetLanguage string `json:"target_language"`
CEFRLevel string `json:"cefr_level"`
ReferenceText string `json:"reference_text"`
DisplayPrompt string `json:"display_prompt"`
TTSText string `json:"tts_text"`
FocusPoints []string `json:"focus_points"`
SuccessCriteria []string `json:"success_criteria"`
ReasonForChoice string `json:"reason_for_choice"`
Source string `json:"source"`
}
type Dashboard struct {
User User `json:"user"`
Profile LearnerProfile `json:"profile"`
Progress ProgressSummary `json:"progress"`
NextLesson Lesson `json:"next_lesson"`
NextExercise Exercise `json:"next_exercise"`
}
type ConversationSession struct {
ID string `json:"id"`
UserID string `json:"user_id"`
TargetLanguage string `json:"target_language"`
CEFRLevel string `json:"cefr_level"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
}
type ConversationTurn struct {
ID string `json:"id"`
SessionID string `json:"session_id"`
Speaker string `json:"speaker"`
Text string `json:"text"`
AttemptID string `json:"attempt_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
type TeacherResponse struct {
ExerciseType string `json:"exercise_type"`
TargetText string `json:"target_text"`
TeacherFeedback string `json:"teacher_feedback"`
TTSText string `json:"tts_text"`
SSML string `json:"ssml"`
NextRecommendation string `json:"next_recommendation"`
}
type DebugDBStatus struct {
OK bool `json:"ok"`
Counts map[string]int `json:"counts"`
SeedLanguageCount int `json:"seed_language_count"`
SeedExerciseCount int `json:"seed_exercise_count"`
Error string `json:"error,omitempty"`
}
type CourseModule struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
TargetLanguage string `json:"target_language"`
CEFRLevel string `json:"cefr_level"`
Version int `json:"version"`
TaskCount int `json:"task_count"`
AttemptedCount int `json:"attempted_count"`
CorrectCount int `json:"correct_count"`
}
type CourseTask struct {
Source string `json:"source,omitempty"`
ID string `json:"id"`
ModuleID string `json:"module_id"`
Skill string `json:"skill"`
Kind string `json:"kind"`
Prompt string `json:"prompt"`
Passage string `json:"passage,omitempty"`
Options []string `json:"options,omitempty"`
PronunciationExercise *Exercise `json:"pronunciation_exercise,omitempty"`
Attempted bool `json:"attempted"`
Correct bool `json:"correct"`
}
type CourseModuleDetail struct {
Module CourseModule `json:"module"`
Tasks []CourseTask `json:"tasks"`
}
type CourseTaskKey struct {
ID string
ModuleID string
Skill string
Kind string
AudioText string
AcceptedAnswers []string
Solution string
Explanation string
}
type CourseAttemptResult struct {
ID string `json:"id"`
TaskID string `json:"task_id"`
Correct bool `json:"correct"`
Solution string `json:"solution"`
Explanation string `json:"explanation"`
Transcript string `json:"transcript,omitempty"`
}