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:
@@ -5,6 +5,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"testing"
|
||||
@@ -60,7 +61,7 @@ func TestCourseVariantSnapshotsAndEvidence(t *testing.T) {
|
||||
if _, _, err = engine.Submit(ctx, user.ID, "en-US", old.ID, "old-answer", old.AnswerKey.CorrectOptionID, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = repo.SetInstructionLanguage(ctx, user.ID, "en-US", "en-US"); err != nil {
|
||||
if err = repo.SetInstructionLanguage(ctx, user.ID, "en-US", "ru-RU"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
run := func(skill, request string, changeAfterEnqueue bool) domain.AdaptiveTask {
|
||||
@@ -69,7 +70,7 @@ func TestCourseVariantSnapshotsAndEvidence(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if j.InstructionLanguage != "en-US" {
|
||||
if j.InstructionLanguage != "ru-RU" {
|
||||
t.Fatal("job did not freeze explanation language", j)
|
||||
}
|
||||
if changeAfterEnqueue {
|
||||
@@ -88,24 +89,32 @@ func TestCourseVariantSnapshotsAndEvidence(t *testing.T) {
|
||||
if err = repo.Finish(ctx, j, task, ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if task.InstructionLanguage != "en-US" || task.VariantID == "" || task.ContentRevision == "" || task.Instruction == "" {
|
||||
if task.InstructionLanguage != "ru-RU" || task.VariantID == "" || task.ContentRevision == "" || task.Instruction == "" {
|
||||
t.Fatal("incomplete frozen variant", task)
|
||||
}
|
||||
return *task
|
||||
}
|
||||
first := run("grammar", "english-grammar-first", false)
|
||||
if _, _, err = engine.Submit(ctx, user.ID, "en-US", first.ID, "english-first-answer", first.AnswerKey.CorrectOptionID, nil); err != nil {
|
||||
|
||||
// Limit this fixture to the historical grammar goal so evidence reuse is deterministic.
|
||||
if _, err = db.ExecContext(ctx, `UPDATE course_v2_bank_variants v SET active=false FROM course_v2_bank b WHERE v.base_entry_id=b.id AND b.module_id='a1_introductions_v1' AND b.skill='grammar' AND b.id<>(SELECT bank_entry_id FROM course_v2_tasks WHERE id=$1)`, old.ID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
translated := run("grammar", "english-grammar-second", true)
|
||||
if !translated.Review || translated.EvidenceTaskID != old.ID {
|
||||
t.Fatal("translation did not reuse existing evidence", translated, old)
|
||||
var translated domain.AdaptiveTask
|
||||
distinct := map[string]bool{old.ID: true}
|
||||
for n := 0; n < 2; n++ {
|
||||
translated = run("grammar", fmt.Sprintf("russian-grammar-%d", n), n == 1)
|
||||
distinct[translated.EvidenceTaskID] = true
|
||||
if _, _, err = engine.Submit(ctx, user.ID, "en-US", translated.ID, fmt.Sprintf("russian-answer-%d", n), translated.AnswerKey.CorrectOptionID, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if _, _, err = engine.Submit(ctx, user.ID, "en-US", translated.ID, "english-second-answer", translated.AnswerKey.CorrectOptionID, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
// The translated historical task retains its canonical evidence identity.
|
||||
var shared int
|
||||
if err = db.QueryRowContext(ctx, `SELECT count(*) FROM course_v2_tasks WHERE owner_id=$1 AND data->>'evidence_task_id'=$2 AND variant_id IS NOT NULL`, user.ID, old.ID).Scan(&shared); err != nil || shared != 1 {
|
||||
t.Fatal("translation did not share historical evidence", shared, err)
|
||||
}
|
||||
replay, err := repo.Enqueue(ctx, user.ID, "en-US", "next", "a1_introductions_v1", "grammar", "", "english-grammar-second")
|
||||
if err != nil || replay.TaskID != translated.ID || replay.InstructionLanguage != "en-US" {
|
||||
replay, err := repo.Enqueue(ctx, user.ID, "en-US", "next", "a1_introductions_v1", "grammar", "", "russian-grammar-1")
|
||||
if err != nil || replay.TaskID != translated.ID || replay.InstructionLanguage != "ru-RU" {
|
||||
t.Fatal("locale change altered idempotent replay", replay, err)
|
||||
}
|
||||
snapshot, err := repo.Snapshot(ctx, user.ID, "en-US", "de-DE")
|
||||
@@ -116,7 +125,7 @@ func TestCourseVariantSnapshotsAndEvidence(t *testing.T) {
|
||||
for _, p := range snapshot.Progress {
|
||||
if p.Skill == "grammar" && p.ModuleID == old.ModuleID {
|
||||
found = true
|
||||
if p.Attempts != 3 || p.DistinctTasks != 2 {
|
||||
if p.Attempts != 3 || p.DistinctTasks != len(distinct) {
|
||||
t.Fatalf("translation inflated task evidence: %+v", p)
|
||||
}
|
||||
}
|
||||
@@ -124,7 +133,10 @@ func TestCourseVariantSnapshotsAndEvidence(t *testing.T) {
|
||||
if !found {
|
||||
t.Fatal("missing graded evidence")
|
||||
}
|
||||
if err = repo.SetInstructionLanguage(ctx, user.ID, "en-US", "en-US"); err != nil {
|
||||
if err = repo.SetInstructionLanguage(ctx, user.ID, "en-US", "ru-RU"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err = db.ExecContext(ctx, `UPDATE course_v2_bank_variants SET active=true WHERE instruction_language='ru-RU'`); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
inventory, err := repo.BankInventory(ctx, user.ID, "en-US")
|
||||
@@ -134,11 +146,9 @@ func TestCourseVariantSnapshotsAndEvidence(t *testing.T) {
|
||||
total := 0
|
||||
for _, item := range inventory {
|
||||
total += item.Total
|
||||
if item.ModuleID != "a1_introductions_v1" {
|
||||
t.Fatal("German fallback advertised as English", item)
|
||||
}
|
||||
|
||||
}
|
||||
if total != 12 {
|
||||
if total != 840 {
|
||||
t.Fatal("incorrect locale inventory", inventory)
|
||||
}
|
||||
// Local speech fixtures exercise the real observation path; no Azure is called.
|
||||
@@ -146,13 +156,16 @@ func TestCourseVariantSnapshotsAndEvidence(t *testing.T) {
|
||||
if _, _, err = engine.Submit(ctx, user.ID, "en-US", oldSpeech.ID, "old-speech", oldSpeech.ReferenceText, &speech); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
localizedSpeech := run("speaking", "localized-speech", false)
|
||||
if localizedSpeech.Kind != "free_speech" { // The existing repeat may be scheduled after the unseen free task.
|
||||
if localizedSpeech.Kind != "repeat_sentence" {
|
||||
t.Fatal(localizedSpeech.Kind)
|
||||
|
||||
if _, err = db.ExecContext(ctx, `UPDATE course_v2_bank_variants v SET active=false FROM course_v2_bank b WHERE v.base_entry_id=b.id AND b.module_id='a1_introductions_v1' AND b.skill='speaking' AND b.id<>(SELECT bank_entry_id FROM course_v2_tasks WHERE id=$1)`, oldSpeech.ID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var localizedSpeech domain.AdaptiveTask
|
||||
for n := 0; n < 20; n++ {
|
||||
localizedSpeech = run("speaking", fmt.Sprintf("localized-speech-%d", n), false)
|
||||
if localizedSpeech.EvidenceTaskID == oldSpeech.ID {
|
||||
break
|
||||
}
|
||||
} else {
|
||||
localizedSpeech = run("speaking", "localized-repeat", false)
|
||||
}
|
||||
if localizedSpeech.EvidenceTaskID != oldSpeech.ID {
|
||||
t.Fatal("translated repeat changed evidence identity", localizedSpeech)
|
||||
@@ -182,10 +195,13 @@ func TestCourseVariantSnapshotsAndEvidence(t *testing.T) {
|
||||
if !bytes.Equal(before, after) {
|
||||
t.Fatal("historical snapshot was rewritten")
|
||||
}
|
||||
if err = repo.SetInstructionLanguage(ctx, user.ID, "en-US", "fr-FR"); !errors.Is(err, store.ErrCourseVariantUnavailable) {
|
||||
if err = repo.SetInstructionLanguage(ctx, user.ID, "en-US", "fr-FR"); !errors.Is(err, domain.ErrNativeLanguageUnsupported) {
|
||||
t.Fatal("unsupported locale accepted", err)
|
||||
}
|
||||
// Missing reviewed variants must not silently select a German reserve.
|
||||
if _, err = db.ExecContext(ctx, `UPDATE course_v2_bank_variants v SET active=false FROM course_v2_bank b WHERE v.base_entry_id=b.id AND b.module_id='a1_family_v1'`); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err = repo.Enqueue(ctx, user.ID, "en-US", "next", "a1_family_v1", "grammar", "", "missing-variants"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user