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.
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
package domain
|
||||
|
||||
import "time"
|
||||
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"`
|
||||
@@ -11,20 +15,39 @@ type User struct {
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// ExplanationLanguage preserves compatibility with callers that construct users
|
||||
// without the additive field; persisted accounts always have an explicit value.
|
||||
// Compatibility fields mirror NativeLanguage; they are never separate preferences.
|
||||
func (u User) ExplanationLanguage() string {
|
||||
if u.InstructionLanguage != "" {
|
||||
return u.InstructionLanguage
|
||||
if SupportedNativeLanguage(u.NativeLanguage) {
|
||||
return u.NativeLanguage
|
||||
}
|
||||
if u.UILanguage != "" {
|
||||
if SupportedNativeLanguage(u.UILanguage) {
|
||||
return u.UILanguage
|
||||
}
|
||||
return "de-DE"
|
||||
}
|
||||
|
||||
func SupportedUILanguage(language string) bool {
|
||||
return language == "de-DE" || language == "en-US"
|
||||
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 {
|
||||
@@ -79,17 +102,18 @@ type Lesson struct {
|
||||
}
|
||||
|
||||
type Exercise struct {
|
||||
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"`
|
||||
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 {
|
||||
@@ -173,6 +197,7 @@ type GeneratedExerciseRequest struct {
|
||||
}
|
||||
|
||||
type GeneratedExercise struct {
|
||||
NativeLanguage string `json:"native_language,omitempty"`
|
||||
TrainingPlan *PronunciationPlan `json:"-"`
|
||||
CandidateWord string `json:"candidate_word,omitempty"`
|
||||
ID string `json:"exercise_id"`
|
||||
|
||||
Reference in New Issue
Block a user