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:
@@ -241,6 +241,11 @@ func (s *AdaptiveStore) SaveExamTasks(ctx context.Context, user, language, exam
|
||||
return err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
// Serialize equivalent assignments with ordinary bank selection, so a
|
||||
// concurrent exam and exercise share the same first evidence identity.
|
||||
if _, err = tx.ExecContext(ctx, `SELECT pg_advisory_xact_lock(hashtextextended($1,0))`, user+":"+language+":"+domain.CourseVersion); err != nil {
|
||||
return err
|
||||
}
|
||||
var status string
|
||||
err = tx.QueryRowContext(ctx, `SELECT status FROM course_v2_exams WHERE id=$1 AND user_id=$2 AND language=$3 FOR UPDATE`, exam, user, language).Scan(&status)
|
||||
if err != nil {
|
||||
@@ -259,11 +264,26 @@ func (s *AdaptiveStore) SaveExamTasks(ctx context.Context, user, language, exam
|
||||
fp = "bank-exam:" + t.BriefID
|
||||
t.BriefID = ""
|
||||
}
|
||||
bankID := ""
|
||||
if t.Source == "curated" {
|
||||
bankID = t.CanonicalTaskID
|
||||
if t.VariantID != "" {
|
||||
if err = tx.QueryRowContext(ctx, `SELECT base_entry_id FROM course_v2_bank_variants WHERE id=$1`, t.VariantID).Scan(&bankID); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
err = tx.QueryRowContext(ctx, `SELECT COALESCE(NULLIF(data->>'evidence_task_id',''),id) FROM course_v2_tasks WHERE owner_id=$1 AND language=$2 AND version=$3 AND COALESCE(NULLIF(data->>'canonical_task_id',''),bank_entry_id)=$4 ORDER BY created_at,id LIMIT 1`, user, language, domain.CourseVersion, t.CanonicalTaskID).Scan(&t.EvidenceTaskID)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
t.EvidenceTaskID = t.ID
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
data, err := json.Marshal(t)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = tx.ExecContext(ctx, `INSERT INTO course_v2_tasks(id,module_id,language,version,owner_id,source,skill,kind,data,fingerprint,exam_id) VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11)`, t.ID, t.ModuleID, language, domain.CourseVersion, user, t.Source, t.Skill, t.Kind, data, fp, exam)
|
||||
_, err = tx.ExecContext(ctx, `INSERT INTO course_v2_tasks(id,module_id,language,version,owner_id,source,skill,kind,data,fingerprint,exam_id,bank_entry_id,variant_id) VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,NULLIF($12,''),NULLIF($13,''))`, t.ID, t.ModuleID, language, domain.CourseVersion, user, t.Source, t.Skill, t.Kind, data, fp, exam, bankID, t.VariantID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -389,7 +389,7 @@ func (s *AdaptiveStore) AssignBankTask(ctx context.Context, j domain.CourseJob)
|
||||
t.CanonicalTaskID = chosen.bankEntryID
|
||||
}
|
||||
// Reuse the earliest evidence identity without editing any historic snapshot.
|
||||
err = tx.QueryRowContext(ctx, `SELECT COALESCE(NULLIF(data->>'evidence_task_id',''),id) FROM course_v2_tasks WHERE owner_id=$1 AND language=$2 AND version=$3 AND exam_id IS NULL AND COALESCE(NULLIF(data->>'canonical_task_id',''),bank_entry_id)=$4 ORDER BY created_at,id LIMIT 1`, j.UserID, j.Language, domain.CourseVersion, t.CanonicalTaskID).Scan(&t.EvidenceTaskID)
|
||||
err = tx.QueryRowContext(ctx, `SELECT COALESCE(NULLIF(data->>'evidence_task_id',''),id) FROM course_v2_tasks WHERE owner_id=$1 AND language=$2 AND version=$3 AND COALESCE(NULLIF(data->>'canonical_task_id',''),bank_entry_id)=$4 ORDER BY created_at,id LIMIT 1`, j.UserID, j.Language, domain.CourseVersion, t.CanonicalTaskID).Scan(&t.EvidenceTaskID)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
t.EvidenceTaskID = t.ID
|
||||
} else if err != nil {
|
||||
@@ -415,8 +415,12 @@ func (s *AdaptiveStore) AssignBankTask(ctx context.Context, j domain.CourseJob)
|
||||
return out, err
|
||||
}
|
||||
|
||||
func (s *AdaptiveStore) BankExam(ctx context.Context, user, language, module string) ([]domain.AdaptiveTask, error) {
|
||||
func (s *AdaptiveStore) BankExam(ctx context.Context, user, language, module string, native ...string) ([]domain.AdaptiveTask, error) {
|
||||
out := []domain.AdaptiveTask{}
|
||||
mother := "de-DE"
|
||||
if len(native) > 0 && native[0] != "" {
|
||||
mother = native[0]
|
||||
}
|
||||
mods, err := s.Modules(ctx, language)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -428,7 +432,7 @@ func (s *AdaptiveStore) BankExam(ctx context.Context, user, language, module str
|
||||
for n := 0; n < 2; n++ {
|
||||
origin := mods[(i+n+1)%6].Key
|
||||
var data []byte
|
||||
err = s.db.QueryRowContext(ctx, `SELECT b.data FROM course_v2_bank b WHERE b.active AND b.language=$1 AND b.version=$2 AND b.module_id=$3 AND b.skill=$4 AND b.data->'task'->>'origin_module_key'=$5 ORDER BY (SELECT count(*) FROM course_v2_tasks t WHERE t.owner_id=$6 AND (t.bank_entry_id=b.id OR t.fingerprint='bank-exam:'||b.id)),md5(b.id||$6) LIMIT 1`, language, domain.CourseVersion, module, skill, origin, user).Scan(&data)
|
||||
err = s.db.QueryRowContext(ctx, availableBank+` SELECT av.entry FROM available av WHERE av.module_id=$5 AND av.skill=$6 AND av.entry->'task'->>'origin_module_key'=$7 ORDER BY (SELECT count(*) FROM course_v2_tasks t WHERE t.owner_id=$1 AND (t.bank_entry_id=av.base_id OR t.fingerprint='bank-exam:'||(CASE WHEN av.variant_id='' THEN av.base_id ELSE av.variant_id END))),md5((av.entry->>'id')||$1) LIMIT 1`, user, language, domain.CourseVersion, mother, module, skill, origin).Scan(&data)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, ErrNotFound
|
||||
}
|
||||
@@ -442,6 +446,12 @@ func (s *AdaptiveStore) BankExam(ctx context.Context, user, language, module str
|
||||
t := entry.Task
|
||||
t.Source = "curated"
|
||||
t.BriefID = entry.ID
|
||||
if t.CanonicalTaskID == "" {
|
||||
t.CanonicalTaskID = entry.ID
|
||||
}
|
||||
if t.InstructionLanguage == "" {
|
||||
t.InstructionLanguage = "de-DE"
|
||||
}
|
||||
out = append(out, t)
|
||||
}
|
||||
}
|
||||
@@ -483,6 +493,8 @@ func (s *AdaptiveStore) BankInventory(ctx context.Context, user, language string
|
||||
// Also repairs a crash between completing scores and storing the static summary.
|
||||
// Existing ready/historical summaries are not overwritten.
|
||||
func (s *AdaptiveStore) EnsureBankExamSummary(ctx context.Context, user, id string) error {
|
||||
_, err := s.db.ExecContext(ctx, `UPDATE course_v2_exams SET result=result||jsonb_build_object('summary',$3::text,'summary_status','ready') WHERE id=$1 AND user_id=$2 AND status='completed' AND result->>'summary_status'='pending'`, id, user, "Interne A1-Lerneinschätzung aus den gespeicherten Bewertungen. Kein Zertifikat.")
|
||||
_, err := s.db.ExecContext(ctx, `UPDATE course_v2_exams e SET result=result||jsonb_build_object('summary',CASE WHEN (SELECT t.data->>'instruction_language' FROM course_v2_tasks t WHERE t.owner_id=$2 AND t.exam_id=e.id ORDER BY t.id LIMIT 1)='ru-RU' THEN $3::text ELSE $4::text END,'summary_status','ready') WHERE e.id=$1 AND e.user_id=$2 AND e.status='completed' AND e.result->>'summary_status'='pending'`, id, user,
|
||||
"Внутренняя оценка уровня A1 на основе сохранённых результатов. Это не сертификат.",
|
||||
"Interne A1-Lerneinschätzung aus den gespeicherten Bewertungen. Kein Zertifikat.")
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -223,15 +223,20 @@ func (s *AdaptiveStore) InstructionLanguages(ctx context.Context, language strin
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
// Deprecated endpoint compatibility: changing explanations changes the entire
|
||||
// native language, even for a target language without installed course content.
|
||||
func (s *AdaptiveStore) SetInstructionLanguage(ctx context.Context, user, language, instruction string) error {
|
||||
options, err := s.InstructionLanguages(ctx, language)
|
||||
if !domain.SupportedNativeLanguage(instruction) {
|
||||
return domain.ErrNativeLanguageUnsupported
|
||||
}
|
||||
result, err := s.db.ExecContext(ctx, `UPDATE users SET native_language=$2,ui_language=$2,instruction_language=$2 WHERE id=$1`, user, instruction)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !bankMember(instruction, options) {
|
||||
return ErrCourseVariantUnavailable
|
||||
n, err := result.RowsAffected()
|
||||
if err == nil && n == 0 {
|
||||
return ErrNotFound
|
||||
}
|
||||
_, err = s.db.ExecContext(ctx, `UPDATE users SET instruction_language=$2 WHERE id=$1`, user, instruction)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ func TestReviewedVariantsRejectChangedIdentityAndLeakedMedia(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(variants) != 12 {
|
||||
t.Fatal("unexpected pilot count", len(variants))
|
||||
if len(variants) != 840 {
|
||||
t.Fatal("unexpected Russian count", len(variants))
|
||||
}
|
||||
copyVariants := func() []domain.BankVariant {
|
||||
raw, _ := json.Marshal(variants)
|
||||
@@ -29,12 +29,8 @@ func TestReviewedVariantsRejectChangedIdentityAndLeakedMedia(t *testing.T) {
|
||||
}
|
||||
t.Run("changed requirement is not a translation", func(t *testing.T) {
|
||||
v := copyVariants()
|
||||
for i := range v {
|
||||
if v[i].Equivalence == "adaptation" {
|
||||
v[i].Equivalence = "translation"
|
||||
break
|
||||
}
|
||||
}
|
||||
v[0].CanonicalTaskID = v[0].ID
|
||||
v[0].Task.CanonicalTaskID = v[0].ID
|
||||
if ValidateVariants(base, v) == nil {
|
||||
t.Fatal("adaptation with shared identity accepted")
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,630 +0,0 @@
|
||||
[
|
||||
{
|
||||
"id": "intro_en_explanations_v1_grammar_01",
|
||||
"revision": "introductions-en-explanations-v1",
|
||||
"base_entry_id": "a1bank_en_v1_introductions_grammar_01",
|
||||
"canonical_task_id": "a1bank_en_v1_introductions_grammar_01",
|
||||
"instruction_language": "en-US",
|
||||
"module_title": "Greetings & introductions",
|
||||
"module_description": "Greet people, introduce a name and origin; I am, my name is",
|
||||
"equivalence": "translation",
|
||||
"reviewed": true,
|
||||
"task": {
|
||||
"schema_version": 2,
|
||||
"module_id": "a1_introductions_v1",
|
||||
"origin_module_key": "introductions",
|
||||
"target_language": "en-US",
|
||||
"course_version": "a1-v2",
|
||||
"cefr_level": "A1",
|
||||
"skill": "grammar",
|
||||
"kind": "choice",
|
||||
"prompt": "Complete the sentence. I ___ Anna.",
|
||||
"options": [
|
||||
{
|
||||
"id": "o1",
|
||||
"label": "am",
|
||||
"role": "target",
|
||||
"language": "en-US"
|
||||
},
|
||||
{
|
||||
"id": "o2",
|
||||
"label": "is",
|
||||
"role": "target",
|
||||
"language": "en-US"
|
||||
},
|
||||
{
|
||||
"id": "o3",
|
||||
"label": "are",
|
||||
"role": "target",
|
||||
"language": "en-US"
|
||||
}
|
||||
],
|
||||
"answer_key": {
|
||||
"correct_option_id": "o1",
|
||||
"reference_answer": "am",
|
||||
"rubric": [
|
||||
"Choose the one answer supported by the sentence, word meaning or supplied text."
|
||||
],
|
||||
"explanation": "Use am after I.",
|
||||
"reference_answer_language": "en-US"
|
||||
},
|
||||
"instruction_language": "en-US",
|
||||
"variant_id": "intro_en_explanations_v1_grammar_01",
|
||||
"canonical_task_id": "a1bank_en_v1_introductions_grammar_01",
|
||||
"content_revision": "introductions-en-explanations-v1",
|
||||
"instruction": "Complete the sentence.",
|
||||
"stimulus": {
|
||||
"role": "target",
|
||||
"language": "en-US",
|
||||
"text": "I ___ Anna."
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "intro_en_explanations_v1_grammar_02",
|
||||
"revision": "introductions-en-explanations-v1",
|
||||
"base_entry_id": "a1bank_en_v1_introductions_grammar_02",
|
||||
"canonical_task_id": "a1bank_en_v1_introductions_grammar_02",
|
||||
"instruction_language": "en-US",
|
||||
"module_title": "Greetings & introductions",
|
||||
"module_description": "Greet people, introduce a name and origin; I am, my name is",
|
||||
"equivalence": "translation",
|
||||
"reviewed": true,
|
||||
"task": {
|
||||
"schema_version": 2,
|
||||
"module_id": "a1_introductions_v1",
|
||||
"origin_module_key": "introductions",
|
||||
"target_language": "en-US",
|
||||
"course_version": "a1-v2",
|
||||
"cefr_level": "A1",
|
||||
"skill": "grammar",
|
||||
"kind": "choice",
|
||||
"prompt": "Complete the sentence. You ___ my friend.",
|
||||
"options": [
|
||||
{
|
||||
"id": "o1",
|
||||
"label": "is",
|
||||
"role": "target",
|
||||
"language": "en-US"
|
||||
},
|
||||
{
|
||||
"id": "o2",
|
||||
"label": "are",
|
||||
"role": "target",
|
||||
"language": "en-US"
|
||||
},
|
||||
{
|
||||
"id": "o3",
|
||||
"label": "am",
|
||||
"role": "target",
|
||||
"language": "en-US"
|
||||
}
|
||||
],
|
||||
"answer_key": {
|
||||
"correct_option_id": "o2",
|
||||
"reference_answer": "are",
|
||||
"rubric": [
|
||||
"Choose the one answer supported by the sentence, word meaning or supplied text."
|
||||
],
|
||||
"explanation": "Use are after you.",
|
||||
"reference_answer_language": "en-US"
|
||||
},
|
||||
"instruction_language": "en-US",
|
||||
"variant_id": "intro_en_explanations_v1_grammar_02",
|
||||
"canonical_task_id": "a1bank_en_v1_introductions_grammar_02",
|
||||
"content_revision": "introductions-en-explanations-v1",
|
||||
"instruction": "Complete the sentence.",
|
||||
"stimulus": {
|
||||
"role": "target",
|
||||
"language": "en-US",
|
||||
"text": "You ___ my friend."
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "intro_en_explanations_v1_vocabulary_01",
|
||||
"revision": "introductions-en-explanations-v1",
|
||||
"base_entry_id": "a1bank_en_v1_introductions_vocabulary_01",
|
||||
"canonical_task_id": "intro_en_explanations_v1_vocabulary_01",
|
||||
"instruction_language": "en-US",
|
||||
"module_title": "Greetings & introductions",
|
||||
"module_description": "Greet people, introduce a name and origin; I am, my name is",
|
||||
"equivalence": "adaptation",
|
||||
"reviewed": true,
|
||||
"task": {
|
||||
"schema_version": 2,
|
||||
"module_id": "a1_introductions_v1",
|
||||
"origin_module_key": "introductions",
|
||||
"target_language": "en-US",
|
||||
"course_version": "a1-v2",
|
||||
"cefr_level": "A1",
|
||||
"skill": "vocabulary",
|
||||
"kind": "choice",
|
||||
"prompt": "What does hello mean in this sentence? Hello, I am Anna.",
|
||||
"options": [
|
||||
{
|
||||
"id": "o1",
|
||||
"label": "a greeting",
|
||||
"role": "meaning",
|
||||
"language": "en-US"
|
||||
},
|
||||
{
|
||||
"id": "o2",
|
||||
"label": "a farewell",
|
||||
"role": "meaning",
|
||||
"language": "en-US"
|
||||
},
|
||||
{
|
||||
"id": "o3",
|
||||
"label": "a polite request",
|
||||
"role": "meaning",
|
||||
"language": "en-US"
|
||||
}
|
||||
],
|
||||
"answer_key": {
|
||||
"correct_option_id": "o1",
|
||||
"reference_answer": "a greeting",
|
||||
"rubric": [
|
||||
"Choose the one answer supported by the sentence, word meaning or supplied text."
|
||||
],
|
||||
"explanation": "Hello is a greeting. We use it when we meet someone.",
|
||||
"reference_answer_language": "en-US"
|
||||
},
|
||||
"instruction_language": "en-US",
|
||||
"variant_id": "intro_en_explanations_v1_vocabulary_01",
|
||||
"canonical_task_id": "intro_en_explanations_v1_vocabulary_01",
|
||||
"content_revision": "introductions-en-explanations-v1",
|
||||
"instruction": "What does hello mean in this sentence?",
|
||||
"stimulus": {
|
||||
"role": "target",
|
||||
"language": "en-US",
|
||||
"text": "Hello, I am Anna."
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "intro_en_explanations_v1_vocabulary_02",
|
||||
"revision": "introductions-en-explanations-v1",
|
||||
"base_entry_id": "a1bank_en_v1_introductions_vocabulary_02",
|
||||
"canonical_task_id": "intro_en_explanations_v1_vocabulary_02",
|
||||
"instruction_language": "en-US",
|
||||
"module_title": "Greetings & introductions",
|
||||
"module_description": "Greet people, introduce a name and origin; I am, my name is",
|
||||
"equivalence": "adaptation",
|
||||
"reviewed": true,
|
||||
"task": {
|
||||
"schema_version": 2,
|
||||
"module_id": "a1_introductions_v1",
|
||||
"origin_module_key": "introductions",
|
||||
"target_language": "en-US",
|
||||
"course_version": "a1-v2",
|
||||
"cefr_level": "A1",
|
||||
"skill": "vocabulary",
|
||||
"kind": "choice",
|
||||
"prompt": "What does name mean in this sentence? My name is Ben.",
|
||||
"options": [
|
||||
{
|
||||
"id": "o1",
|
||||
"label": "where someone lives",
|
||||
"role": "meaning",
|
||||
"language": "en-US"
|
||||
},
|
||||
{
|
||||
"id": "o2",
|
||||
"label": "what a person is called",
|
||||
"role": "meaning",
|
||||
"language": "en-US"
|
||||
},
|
||||
{
|
||||
"id": "o3",
|
||||
"label": "how old someone is",
|
||||
"role": "meaning",
|
||||
"language": "en-US"
|
||||
}
|
||||
],
|
||||
"answer_key": {
|
||||
"correct_option_id": "o2",
|
||||
"reference_answer": "what a person is called",
|
||||
"rubric": [
|
||||
"Choose the one answer supported by the sentence, word meaning or supplied text."
|
||||
],
|
||||
"explanation": "A name is what a person is called. The person's name here is Ben.",
|
||||
"reference_answer_language": "en-US"
|
||||
},
|
||||
"instruction_language": "en-US",
|
||||
"variant_id": "intro_en_explanations_v1_vocabulary_02",
|
||||
"canonical_task_id": "intro_en_explanations_v1_vocabulary_02",
|
||||
"content_revision": "introductions-en-explanations-v1",
|
||||
"instruction": "What does name mean in this sentence?",
|
||||
"stimulus": {
|
||||
"role": "target",
|
||||
"language": "en-US",
|
||||
"text": "My name is Ben."
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "intro_en_explanations_v1_reading_01",
|
||||
"revision": "introductions-en-explanations-v1",
|
||||
"base_entry_id": "a1bank_en_v1_introductions_reading_01",
|
||||
"canonical_task_id": "a1bank_en_v1_introductions_reading_01",
|
||||
"instruction_language": "en-US",
|
||||
"module_title": "Greetings & introductions",
|
||||
"module_description": "Greet people, introduce a name and origin; I am, my name is",
|
||||
"equivalence": "translation",
|
||||
"reviewed": true,
|
||||
"task": {
|
||||
"schema_version": 2,
|
||||
"module_id": "a1_introductions_v1",
|
||||
"origin_module_key": "introductions",
|
||||
"target_language": "en-US",
|
||||
"course_version": "a1-v2",
|
||||
"cefr_level": "A1",
|
||||
"skill": "reading",
|
||||
"kind": "choice",
|
||||
"prompt": "What is the person's name?",
|
||||
"passage": "My name is Anna. I am from Spain.",
|
||||
"options": [
|
||||
{
|
||||
"id": "o1",
|
||||
"label": "Anna",
|
||||
"role": "target",
|
||||
"language": "en-US"
|
||||
},
|
||||
{
|
||||
"id": "o2",
|
||||
"label": "Mia",
|
||||
"role": "target",
|
||||
"language": "en-US"
|
||||
},
|
||||
{
|
||||
"id": "o3",
|
||||
"label": "Eva",
|
||||
"role": "target",
|
||||
"language": "en-US"
|
||||
}
|
||||
],
|
||||
"answer_key": {
|
||||
"correct_option_id": "o1",
|
||||
"reference_answer": "Anna",
|
||||
"rubric": [
|
||||
"Choose the one answer supported by the sentence, word meaning or supplied text."
|
||||
],
|
||||
"explanation": "The text says: My name is Anna. The correct answer is Anna.",
|
||||
"reference_answer_language": "en-US"
|
||||
},
|
||||
"instruction_language": "en-US",
|
||||
"variant_id": "intro_en_explanations_v1_reading_01",
|
||||
"canonical_task_id": "a1bank_en_v1_introductions_reading_01",
|
||||
"content_revision": "introductions-en-explanations-v1",
|
||||
"instruction": "What is the person's name?"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "intro_en_explanations_v1_reading_02",
|
||||
"revision": "introductions-en-explanations-v1",
|
||||
"base_entry_id": "a1bank_en_v1_introductions_reading_02",
|
||||
"canonical_task_id": "a1bank_en_v1_introductions_reading_02",
|
||||
"instruction_language": "en-US",
|
||||
"module_title": "Greetings & introductions",
|
||||
"module_description": "Greet people, introduce a name and origin; I am, my name is",
|
||||
"equivalence": "translation",
|
||||
"reviewed": true,
|
||||
"task": {
|
||||
"schema_version": 2,
|
||||
"module_id": "a1_introductions_v1",
|
||||
"origin_module_key": "introductions",
|
||||
"target_language": "en-US",
|
||||
"course_version": "a1-v2",
|
||||
"cefr_level": "A1",
|
||||
"skill": "reading",
|
||||
"kind": "choice",
|
||||
"prompt": "Which country is Ben from?",
|
||||
"passage": "Ben is from Canada. He lives in London.",
|
||||
"options": [
|
||||
{
|
||||
"id": "o1",
|
||||
"label": "Italy",
|
||||
"role": "target",
|
||||
"language": "en-US"
|
||||
},
|
||||
{
|
||||
"id": "o2",
|
||||
"label": "Canada",
|
||||
"role": "target",
|
||||
"language": "en-US"
|
||||
},
|
||||
{
|
||||
"id": "o3",
|
||||
"label": "Germany",
|
||||
"role": "target",
|
||||
"language": "en-US"
|
||||
}
|
||||
],
|
||||
"answer_key": {
|
||||
"correct_option_id": "o2",
|
||||
"reference_answer": "Canada",
|
||||
"rubric": [
|
||||
"Choose the one answer supported by the sentence, word meaning or supplied text."
|
||||
],
|
||||
"explanation": "The text says: Ben is from Canada. The correct answer is Canada.",
|
||||
"reference_answer_language": "en-US"
|
||||
},
|
||||
"instruction_language": "en-US",
|
||||
"variant_id": "intro_en_explanations_v1_reading_02",
|
||||
"canonical_task_id": "a1bank_en_v1_introductions_reading_02",
|
||||
"content_revision": "introductions-en-explanations-v1",
|
||||
"instruction": "Which country is Ben from?"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "intro_en_explanations_v1_listening_01",
|
||||
"revision": "introductions-en-explanations-v1",
|
||||
"base_entry_id": "a1bank_en_v1_introductions_listening_01",
|
||||
"canonical_task_id": "a1bank_en_v1_introductions_listening_01",
|
||||
"instruction_language": "en-US",
|
||||
"module_title": "Greetings & introductions",
|
||||
"module_description": "Greet people, introduce a name and origin; I am, my name is",
|
||||
"equivalence": "translation",
|
||||
"reviewed": true,
|
||||
"task": {
|
||||
"schema_version": 2,
|
||||
"module_id": "a1_introductions_v1",
|
||||
"origin_module_key": "introductions",
|
||||
"target_language": "en-US",
|
||||
"course_version": "a1-v2",
|
||||
"cefr_level": "A1",
|
||||
"skill": "listening",
|
||||
"kind": "choice",
|
||||
"prompt": "Which country is Anna from?",
|
||||
"audio_text": "My name is Anna. I am from Spain.",
|
||||
"options": [
|
||||
{
|
||||
"id": "o1",
|
||||
"label": "Spain",
|
||||
"role": "target",
|
||||
"language": "en-US"
|
||||
},
|
||||
{
|
||||
"id": "o2",
|
||||
"label": "France",
|
||||
"role": "target",
|
||||
"language": "en-US"
|
||||
},
|
||||
{
|
||||
"id": "o3",
|
||||
"label": "Italy",
|
||||
"role": "target",
|
||||
"language": "en-US"
|
||||
}
|
||||
],
|
||||
"answer_key": {
|
||||
"correct_option_id": "o1",
|
||||
"reference_answer": "Spain",
|
||||
"rubric": [
|
||||
"Choose the one answer supported by the sentence, word meaning or supplied text."
|
||||
],
|
||||
"explanation": "The recording says: I am from Spain. The correct answer is Spain.",
|
||||
"reference_answer_language": "en-US"
|
||||
},
|
||||
"instruction_language": "en-US",
|
||||
"variant_id": "intro_en_explanations_v1_listening_01",
|
||||
"canonical_task_id": "a1bank_en_v1_introductions_listening_01",
|
||||
"content_revision": "introductions-en-explanations-v1",
|
||||
"instruction": "Which country is Anna from?"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "intro_en_explanations_v1_listening_02",
|
||||
"revision": "introductions-en-explanations-v1",
|
||||
"base_entry_id": "a1bank_en_v1_introductions_listening_02",
|
||||
"canonical_task_id": "a1bank_en_v1_introductions_listening_02",
|
||||
"instruction_language": "en-US",
|
||||
"module_title": "Greetings & introductions",
|
||||
"module_description": "Greet people, introduce a name and origin; I am, my name is",
|
||||
"equivalence": "translation",
|
||||
"reviewed": true,
|
||||
"task": {
|
||||
"schema_version": 2,
|
||||
"module_id": "a1_introductions_v1",
|
||||
"origin_module_key": "introductions",
|
||||
"target_language": "en-US",
|
||||
"course_version": "a1-v2",
|
||||
"cefr_level": "A1",
|
||||
"skill": "listening",
|
||||
"kind": "choice",
|
||||
"prompt": "Where does Ben live?",
|
||||
"audio_text": "Ben is from Canada. He lives in London.",
|
||||
"options": [
|
||||
{
|
||||
"id": "o1",
|
||||
"label": "Rome",
|
||||
"role": "target",
|
||||
"language": "en-US"
|
||||
},
|
||||
{
|
||||
"id": "o2",
|
||||
"label": "London",
|
||||
"role": "target",
|
||||
"language": "en-US"
|
||||
},
|
||||
{
|
||||
"id": "o3",
|
||||
"label": "Paris",
|
||||
"role": "target",
|
||||
"language": "en-US"
|
||||
}
|
||||
],
|
||||
"answer_key": {
|
||||
"correct_option_id": "o2",
|
||||
"reference_answer": "London",
|
||||
"rubric": [
|
||||
"Choose the one answer supported by the sentence, word meaning or supplied text."
|
||||
],
|
||||
"explanation": "The recording says: He lives in London. The correct answer is London.",
|
||||
"reference_answer_language": "en-US"
|
||||
},
|
||||
"instruction_language": "en-US",
|
||||
"variant_id": "intro_en_explanations_v1_listening_02",
|
||||
"canonical_task_id": "a1bank_en_v1_introductions_listening_02",
|
||||
"content_revision": "introductions-en-explanations-v1",
|
||||
"instruction": "Where does Ben live?"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "intro_en_explanations_v1_speaking_01",
|
||||
"revision": "introductions-en-explanations-v1",
|
||||
"base_entry_id": "a1bank_en_v1_introductions_speaking_01",
|
||||
"canonical_task_id": "a1bank_en_v1_introductions_speaking_01",
|
||||
"instruction_language": "en-US",
|
||||
"module_title": "Greetings & introductions",
|
||||
"module_description": "Greet people, introduce a name and origin; I am, my name is",
|
||||
"equivalence": "translation",
|
||||
"reviewed": true,
|
||||
"task": {
|
||||
"schema_version": 2,
|
||||
"module_id": "a1_introductions_v1",
|
||||
"origin_module_key": "introductions",
|
||||
"target_language": "en-US",
|
||||
"course_version": "a1-v2",
|
||||
"cefr_level": "A1",
|
||||
"skill": "speaking",
|
||||
"kind": "repeat_sentence",
|
||||
"prompt": "Repeat the English sentence.",
|
||||
"reference_text": "My name is Anna.",
|
||||
"answer_key": {
|
||||
"reference_answer": "My name is Anna.",
|
||||
"rubric": [
|
||||
"Repeat the displayed English sentence clearly.",
|
||||
"Do not claim pronunciation or fluency errors without actual Azure measurements."
|
||||
],
|
||||
"explanation": "Repeat the complete sentence clearly. Pronunciation feedback uses only available speech measurements.",
|
||||
"reference_answer_language": "en-US"
|
||||
},
|
||||
"instruction_language": "en-US",
|
||||
"variant_id": "intro_en_explanations_v1_speaking_01",
|
||||
"canonical_task_id": "a1bank_en_v1_introductions_speaking_01",
|
||||
"content_revision": "introductions-en-explanations-v1",
|
||||
"instruction": "Repeat the English sentence."
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "intro_en_explanations_v1_speaking_11",
|
||||
"revision": "introductions-en-explanations-v1",
|
||||
"base_entry_id": "a1bank_en_v2_introductions_speaking_11",
|
||||
"canonical_task_id": "a1bank_en_v2_introductions_speaking_11",
|
||||
"instruction_language": "en-US",
|
||||
"module_title": "Greetings & introductions",
|
||||
"module_description": "Greet people, introduce a name and origin; I am, my name is",
|
||||
"equivalence": "translation",
|
||||
"reviewed": true,
|
||||
"task": {
|
||||
"schema_version": 2,
|
||||
"module_id": "a1_introductions_v1",
|
||||
"origin_module_key": "introductions",
|
||||
"target_language": "en-US",
|
||||
"course_version": "a1-v2",
|
||||
"cefr_level": "A1",
|
||||
"skill": "speaking",
|
||||
"kind": "free_speech",
|
||||
"prompt": "Introduce yourself. Give a name and the country you are from. You may use real or invented details. Say two or three short English sentences in at most 30 seconds.",
|
||||
"answer_key": {
|
||||
"reference_answer": "My name is Nina. I am not from Germany. I am from Poland.",
|
||||
"rubric": [
|
||||
"Introduce one person with a name and country of origin.",
|
||||
"Two or three short, understandable English sentences meet the required length.",
|
||||
"Real or invented names and countries are allowed. Facts in the example are not mandatory.",
|
||||
"Assess only the explicitly requested content and actual language errors. Do not penalise ambiguity in the task.",
|
||||
"For this free-speech response, assess content and English formulations only. Azure pronunciation is displayed separately and is not part of this score."
|
||||
],
|
||||
"explanation": "The example is only one possible answer. You may choose your own name and country. Content and language are assessed separately from Azure pronunciation.",
|
||||
"reference_answer_language": "en-US"
|
||||
},
|
||||
"instruction_language": "en-US",
|
||||
"variant_id": "intro_en_explanations_v1_speaking_11",
|
||||
"canonical_task_id": "a1bank_en_v2_introductions_speaking_11",
|
||||
"content_revision": "introductions-en-explanations-v1",
|
||||
"instruction": "Introduce yourself. Give a name and the country you are from. You may use real or invented details. Say two or three short English sentences in at most 30 seconds."
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "intro_en_explanations_v1_writing_01",
|
||||
"revision": "introductions-en-explanations-v1",
|
||||
"base_entry_id": "a1bank_en_v1_introductions_writing_01",
|
||||
"canonical_task_id": "intro_en_explanations_v1_writing_01",
|
||||
"instruction_language": "en-US",
|
||||
"module_title": "Greetings & introductions",
|
||||
"module_description": "Greet people, introduce a name and origin; I am, my name is",
|
||||
"equivalence": "adaptation",
|
||||
"reviewed": true,
|
||||
"task": {
|
||||
"schema_version": 2,
|
||||
"module_id": "a1_introductions_v1",
|
||||
"origin_module_key": "introductions",
|
||||
"target_language": "en-US",
|
||||
"course_version": "a1-v2",
|
||||
"cefr_level": "A1",
|
||||
"skill": "writing",
|
||||
"kind": "short_text",
|
||||
"prompt": "Write one short English sentence to introduce yourself. For this exercise, use the name Anna. Name: Anna",
|
||||
"answer_key": {
|
||||
"reference_answer": "My name is Anna.",
|
||||
"rubric": [
|
||||
"Write one understandable English sentence to introduce yourself using the explicitly requested name Anna.",
|
||||
"Accept My name is Anna., I am Anna. and other correct equivalent formulations.",
|
||||
"Consider actual A1 language errors proportionately. Do not invent additional requirements."
|
||||
],
|
||||
"explanation": "My name is Anna. and I am Anna. are both valid answers. Use the name Anna as requested; other correct ways to introduce yourself are allowed.",
|
||||
"reference_answer_language": "en-US"
|
||||
},
|
||||
"instruction_language": "en-US",
|
||||
"variant_id": "intro_en_explanations_v1_writing_01",
|
||||
"canonical_task_id": "intro_en_explanations_v1_writing_01",
|
||||
"content_revision": "introductions-en-explanations-v1",
|
||||
"instruction": "Write one short English sentence to introduce yourself. For this exercise, use the name Anna.",
|
||||
"stimulus": {
|
||||
"role": "context",
|
||||
"language": "en-US",
|
||||
"text": "Name: Anna"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "intro_en_explanations_v1_writing_11",
|
||||
"revision": "introductions-en-explanations-v1",
|
||||
"base_entry_id": "a1bank_en_v2_introductions_writing_11",
|
||||
"canonical_task_id": "a1bank_en_v2_introductions_writing_11",
|
||||
"instruction_language": "en-US",
|
||||
"module_title": "Greetings & introductions",
|
||||
"module_description": "Greet people, introduce a name and origin; I am, my name is",
|
||||
"equivalence": "translation",
|
||||
"reviewed": true,
|
||||
"task": {
|
||||
"schema_version": 2,
|
||||
"module_id": "a1_introductions_v1",
|
||||
"origin_module_key": "introductions",
|
||||
"target_language": "en-US",
|
||||
"course_version": "a1-v2",
|
||||
"cefr_level": "A1",
|
||||
"skill": "writing",
|
||||
"kind": "free_text",
|
||||
"prompt": "Introduce yourself. Give a name and the country you are from. You may use real or invented details. Write two or three short English sentences.",
|
||||
"answer_key": {
|
||||
"reference_answer": "My name is Nina. I am not from Germany. I am from Poland.",
|
||||
"rubric": [
|
||||
"Introduce one person with a name and country of origin.",
|
||||
"Two or three short, understandable English sentences meet the required length.",
|
||||
"Real or invented names and countries are allowed. Facts in the example are not mandatory.",
|
||||
"Assess only the explicitly requested content and actual language errors. Do not penalise ambiguity in the task."
|
||||
],
|
||||
"explanation": "The example is only one possible answer. You may choose your own name and country. Only the explicitly requested information is required.",
|
||||
"reference_answer_language": "en-US"
|
||||
},
|
||||
"instruction_language": "en-US",
|
||||
"variant_id": "intro_en_explanations_v1_writing_11",
|
||||
"canonical_task_id": "a1bank_en_v2_introductions_writing_11",
|
||||
"content_revision": "introductions-en-explanations-v1",
|
||||
"instruction": "Introduce yourself. Give a name and the country you are from. You may use real or invented details. Write two or three short English sentences."
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -1,7 +1,13 @@
|
||||
{
|
||||
"total": 12,
|
||||
"editorial_review_sha256": "05cf8e999f341338101fa42d667e031ea6509a19f56b116b5af7329457a75368",
|
||||
"total": 840,
|
||||
"editorial_review_sha256": "bf482411a30c9e6096e9ab7f34785b844541f40bdb70d725a8a465696d53ee75",
|
||||
"files": {
|
||||
"introductions.en-US.v1.json": "07f3a3935290760bd64935ca66825c6321654aa017cd45c5651b86ddd9fbdc39"
|
||||
"a1_daily_life_v1.ru-RU.v1.json": "83120bc77948d6c3b0ede8fd7ca013302bf7f570fe17db09195fa00ab24dcc4f",
|
||||
"a1_family_v1.ru-RU.v1.json": "2d439fba0686cdd29794affa32a29f145bc101375e36c4dc550d434839f6c135",
|
||||
"a1_food_shopping_v1.ru-RU.v1.json": "e13f1aa36f1ace664305947382b965ad6e01029e9363ce34b2ae9b31a049777c",
|
||||
"a1_home_city_v1.ru-RU.v1.json": "783179d50cb197bd28310cbd7a605c43216bfcb9f691cadd3dd5b7c77dcebbbe",
|
||||
"a1_introductions_v1.ru-RU.v1.json": "6458a0fc052c615f5a11b87f6a2a6ce9be67c4e03e1c6532092009bef2841bd0",
|
||||
"a1_numbers_time_v1.ru-RU.v1.json": "403d758af8264eaa98a0f6b869f35e45a519efd7727daed68bc3f179ed9f1fdc",
|
||||
"a1_review_test_v1.ru-RU.v1.json": "4b89bc0ecdb283cc49e75ee3d6113bd49f9d678b2261af682dbcd6a7edd308ae"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,6 +259,11 @@ func (s *PostgresStore) PlanPronunciation(ctx context.Context, user, language st
|
||||
return domain.PronunciationPlan{}, err
|
||||
}
|
||||
plan := pronunciation.Select(p, history, now)
|
||||
var native string
|
||||
if err = tx.QueryRowContext(ctx, `SELECT native_language FROM users WHERE id=$1`, user).Scan(&native); err != nil {
|
||||
return plan, err
|
||||
}
|
||||
pronunciation.SetNativeLanguage(&plan, native)
|
||||
plan.ID = NewID("pronplan")
|
||||
raw, err := json.Marshal(plan)
|
||||
if err != nil {
|
||||
|
||||
@@ -98,15 +98,16 @@ func (s *PostgresStore) SaveGeneratedExercise(ctx context.Context, userID string
|
||||
return domain.Lesson{}, domain.Exercise{}, err
|
||||
}
|
||||
exercise := domain.Exercise{
|
||||
ID: NewID("exg"),
|
||||
LessonID: lesson.ID,
|
||||
TargetLanguage: targetLanguage,
|
||||
CEFRLevel: cefrLevel,
|
||||
Type: valueOr(generated.ExerciseType, "repeat_sentence"),
|
||||
PromptText: valueOr(generated.DisplayPrompt, "Sprich den Satz klar nach."),
|
||||
TargetText: generated.ReferenceText,
|
||||
Difficulty: 1,
|
||||
Source: valueOr(generated.Source, "flowise"),
|
||||
ID: NewID("exg"),
|
||||
LessonID: lesson.ID,
|
||||
TargetLanguage: targetLanguage,
|
||||
CEFRLevel: cefrLevel,
|
||||
Type: valueOr(generated.ExerciseType, "repeat_sentence"),
|
||||
PromptText: valueOr(generated.DisplayPrompt, "Sprich den Satz klar nach."),
|
||||
InstructionLanguage: valueOr(generated.NativeLanguage, "de-DE"),
|
||||
TargetText: generated.ReferenceText,
|
||||
Difficulty: 1,
|
||||
Source: valueOr(generated.Source, "flowise"),
|
||||
}
|
||||
if strings.TrimSpace(exercise.TargetText) == "" {
|
||||
return domain.Lesson{}, domain.Exercise{}, errors.New("generated exercise reference_text is required")
|
||||
@@ -178,13 +179,16 @@ func (s *PostgresStore) DebugStatus(ctx context.Context) domain.DebugDBStatus {
|
||||
}
|
||||
|
||||
func (s *PostgresStore) CreateUser(ctx context.Context, email, passwordHash, uiLanguage string) (domain.User, error) {
|
||||
if !domain.SupportedNativeLanguage(uiLanguage) {
|
||||
return domain.User{}, domain.ErrNativeLanguageUnsupported
|
||||
}
|
||||
user := domain.User{ID: NewID("usr"), Email: strings.ToLower(strings.TrimSpace(email)), UILanguage: uiLanguage}
|
||||
row := s.db.QueryRowContext(ctx, `
|
||||
INSERT INTO users (id, email, password_hash, ui_language)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING id, email, ui_language, instruction_language, role, created_at
|
||||
INSERT INTO users (id, email, password_hash, native_language, ui_language, instruction_language)
|
||||
VALUES ($1, $2, $3, $4, $4, $4)
|
||||
RETURNING id, email, native_language, ui_language, instruction_language, role, created_at
|
||||
`, user.ID, user.Email, passwordHash, uiLanguage)
|
||||
if err := row.Scan(&user.ID, &user.Email, &user.UILanguage, &user.InstructionLanguage, &user.Role, &user.CreatedAt); err != nil {
|
||||
if err := row.Scan(&user.ID, &user.Email, &user.NativeLanguage, &user.UILanguage, &user.InstructionLanguage, &user.Role, &user.CreatedAt); err != nil {
|
||||
return domain.User{}, err
|
||||
}
|
||||
return user, nil
|
||||
@@ -194,11 +198,11 @@ func (s *PostgresStore) GetPasswordHashByEmail(ctx context.Context, email string
|
||||
var user domain.User
|
||||
var hash string
|
||||
row := s.db.QueryRowContext(ctx, `
|
||||
SELECT id, email, password_hash, ui_language, instruction_language, role, created_at
|
||||
SELECT id, email, password_hash, native_language, ui_language, instruction_language, role, created_at
|
||||
FROM users
|
||||
WHERE email = $1
|
||||
`, strings.ToLower(strings.TrimSpace(email)))
|
||||
if err := row.Scan(&user.ID, &user.Email, &hash, &user.UILanguage, &user.InstructionLanguage, &user.Role, &user.CreatedAt); err != nil {
|
||||
if err := row.Scan(&user.ID, &user.Email, &hash, &user.NativeLanguage, &user.UILanguage, &user.InstructionLanguage, &user.Role, &user.CreatedAt); err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return domain.User{}, "", ErrNotFound
|
||||
}
|
||||
@@ -210,11 +214,11 @@ func (s *PostgresStore) GetPasswordHashByEmail(ctx context.Context, email string
|
||||
func (s *PostgresStore) GetUser(ctx context.Context, id string) (domain.User, error) {
|
||||
var user domain.User
|
||||
row := s.db.QueryRowContext(ctx, `
|
||||
SELECT id, email, ui_language, instruction_language, role, created_at
|
||||
SELECT id, email, native_language, ui_language, instruction_language, role, created_at
|
||||
FROM users
|
||||
WHERE id = $1
|
||||
`, id)
|
||||
if err := row.Scan(&user.ID, &user.Email, &user.UILanguage, &user.InstructionLanguage, &user.Role, &user.CreatedAt); err != nil {
|
||||
if err := row.Scan(&user.ID, &user.Email, &user.NativeLanguage, &user.UILanguage, &user.InstructionLanguage, &user.Role, &user.CreatedAt); err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return domain.User{}, ErrNotFound
|
||||
}
|
||||
@@ -266,7 +270,7 @@ func (s *PostgresStore) GetPrimaryProfile(ctx context.Context, userID string) (d
|
||||
|
||||
func (s *PostgresStore) UpdatePreferences(ctx context.Context, userID, uiLanguage, targetLanguage, cefrLevel string, dailyGoalMinutes int) (domain.LearnerProfile, error) {
|
||||
if uiLanguage != "" && !domain.SupportedUILanguage(uiLanguage) {
|
||||
return domain.LearnerProfile{}, errors.New("unsupported UI language")
|
||||
return domain.LearnerProfile{}, domain.ErrNativeLanguageUnsupported
|
||||
}
|
||||
tx, err := s.db.BeginTx(ctx, nil)
|
||||
if err != nil {
|
||||
@@ -302,7 +306,7 @@ func (s *PostgresStore) UpdatePreferences(ctx context.Context, userID, uiLanguag
|
||||
if err != nil {
|
||||
return profile, err
|
||||
}
|
||||
_, err = tx.ExecContext(ctx, `UPDATE users SET active_profile_id=$2,ui_language=CASE WHEN $3='' THEN ui_language ELSE $3 END WHERE id=$1`, userID, profile.ID, uiLanguage)
|
||||
_, err = tx.ExecContext(ctx, `UPDATE users SET active_profile_id=$2,native_language=CASE WHEN $3='' THEN native_language ELSE $3 END,ui_language=CASE WHEN $3='' THEN native_language ELSE $3 END,instruction_language=CASE WHEN $3='' THEN native_language ELSE $3 END WHERE id=$1`, userID, profile.ID, uiLanguage)
|
||||
if err != nil {
|
||||
return profile, err
|
||||
}
|
||||
@@ -414,11 +418,11 @@ func (s *PostgresStore) RecentPronunciationTexts(ctx context.Context, userID, la
|
||||
func (s *PostgresStore) GetExercise(ctx context.Context, id, userID string) (domain.Exercise, error) {
|
||||
var e domain.Exercise
|
||||
row := s.db.QueryRowContext(ctx, `
|
||||
SELECT id, lesson_id, target_language, cefr_level, type, prompt_text, target_text, difficulty, COALESCE(source, 'seed'), COALESCE((SELECT data->>'reason' FROM pronunciation_plans WHERE exercise_id=exercises.id),''), COALESCE((SELECT data->>'category' FROM pronunciation_plans WHERE exercise_id=exercises.id),'')
|
||||
SELECT id, lesson_id, target_language, cefr_level, type, prompt_text, target_text, difficulty, COALESCE(source, 'seed'), COALESCE((SELECT data->>'reason' FROM pronunciation_plans WHERE exercise_id=exercises.id),''), COALESCE((SELECT data->>'category' FROM pronunciation_plans WHERE exercise_id=exercises.id),''), COALESCE(NULLIF(agent_context_json->>'native_language',''),'de-DE')
|
||||
FROM exercises
|
||||
WHERE id = $1 AND (COALESCE(source, 'seed') = 'seed' OR created_by_user_id = $2)
|
||||
`, id, userID)
|
||||
if err := row.Scan(&e.ID, &e.LessonID, &e.TargetLanguage, &e.CEFRLevel, &e.Type, &e.PromptText, &e.TargetText, &e.Difficulty, &e.Source, &e.TrainingReason, &e.TrainingCategory); err != nil {
|
||||
if err := row.Scan(&e.ID, &e.LessonID, &e.TargetLanguage, &e.CEFRLevel, &e.Type, &e.PromptText, &e.TargetText, &e.Difficulty, &e.Source, &e.TrainingReason, &e.TrainingCategory, &e.InstructionLanguage); err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return domain.Exercise{}, ErrNotFound
|
||||
}
|
||||
@@ -699,6 +703,19 @@ ALTER TABLE users ADD COLUMN IF NOT EXISTS instruction_language TEXT;
|
||||
UPDATE users SET instruction_language=ui_language WHERE instruction_language IS NULL;
|
||||
ALTER TABLE users ALTER COLUMN instruction_language SET DEFAULT 'de-DE';
|
||||
ALTER TABLE users ALTER COLUMN instruction_language SET NOT NULL;
|
||||
-- The product has two roles: native language (GUI and explanations together)
|
||||
-- and target language. Old unsupported GUI preferences become German once.
|
||||
ALTER TABLE users ADD COLUMN IF NOT EXISTS native_language TEXT;
|
||||
UPDATE users SET native_language=CASE WHEN ui_language IN ('de-DE','ru-RU') THEN ui_language ELSE 'de-DE' END WHERE native_language IS NULL;
|
||||
ALTER TABLE users ALTER COLUMN native_language SET DEFAULT 'de-DE';
|
||||
ALTER TABLE users ALTER COLUMN native_language SET NOT NULL;
|
||||
UPDATE users SET ui_language=native_language,instruction_language=native_language WHERE ui_language IS DISTINCT FROM native_language OR instruction_language IS DISTINCT FROM native_language;
|
||||
DO $$ BEGIN
|
||||
IF NOT EXISTS(SELECT 1 FROM pg_constraint WHERE conrelid='users'::regclass AND conname='users_native_language_coupled') THEN
|
||||
ALTER TABLE users ADD CONSTRAINT users_native_language_coupled CHECK(native_language IN ('de-DE','ru-RU') AND ui_language=native_language AND instruction_language=native_language);
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS learner_profiles (
|
||||
id TEXT PRIMARY KEY,
|
||||
|
||||
Reference in New Issue
Block a user