Bugs next card
This commit is contained in:
@@ -581,6 +581,7 @@ function TutorApp({ currentUser, onLogout }) {
|
||||
}),
|
||||
})
|
||||
await loadCardProgress(selectedStudentId, studentProgram.id)
|
||||
await loadStudentProgram(selectedStudentId)
|
||||
if (!isStudentUser) await loadSessionLogs(selectedStudentId)
|
||||
}
|
||||
|
||||
@@ -798,6 +799,15 @@ function TutorApp({ currentUser, onLogout }) {
|
||||
|
||||
function buildNextCardInstruction(nextStep) {
|
||||
const title = nextStep?.section?.title || nextStep?.asset?.title || 'la suite'
|
||||
const key = nextStep?.section?.context_key || ''
|
||||
const prompts = {
|
||||
Fiche1Card2: 'Très bien, on passe à Exemple. Lis le nombre 345 208.',
|
||||
Fiche1Card3: 'Très bien, on passe à À retenir. Dis-moi ce qu’on lit en premier.',
|
||||
Fiche1Card4: 'Très bien, on passe à Exemple 1. Lis le nombre 7 425.',
|
||||
Fiche1Card5: 'Très bien, on passe à Exemple 2. Lis le nombre 38 090.',
|
||||
Fiche1Card6: 'Très bien, on passe à Exemple 3. Lis le nombre 506 012.',
|
||||
}
|
||||
if (prompts[key]) return prompts[key]
|
||||
if (title.toLowerCase().startsWith('exemple')) {
|
||||
return `Très bien, on passe à ${title}. Lis seulement le nombre affiché.`
|
||||
}
|
||||
@@ -816,6 +826,7 @@ function TutorApp({ currentUser, onLogout }) {
|
||||
const answer = normalizeAnswer(text)
|
||||
const { section } = getLessonPosition()
|
||||
const key = section?.context_key || ''
|
||||
if (/^(ok|oui|d accord|daccord|j ai compris|compris)[.!?\s]*$/.test(answer.trim())) return true
|
||||
if (/\b(oui|ok|d accord)\b/.test(answer) && /compr/.test(answer)) return true
|
||||
if (key === 'Fiche1Card1') {
|
||||
return /compr/.test(answer) || (answer.includes('345') && answer.includes('208'))
|
||||
@@ -1018,6 +1029,20 @@ function TutorApp({ currentUser, onLogout }) {
|
||||
setLastStudentTransmission(text)
|
||||
setInput('')
|
||||
setErrorMessage('')
|
||||
if (answerValidatesCurrentCard(text)) {
|
||||
rememberActiveCard({ score: 100, validated: true })
|
||||
const nextStep = getNextLessonStep()
|
||||
const transitionReply = nextStep
|
||||
? buildNextCardInstruction(nextStep)
|
||||
: 'Très bien, cette fiche est terminée.'
|
||||
if (nextStep) {
|
||||
setLessonPosition(nextStep.assetIndex, nextStep.sectionIndex)
|
||||
}
|
||||
appendMessage('assistant', transitionReply)
|
||||
setCurrentInstruction(transitionReply)
|
||||
speak(transitionReply)
|
||||
return
|
||||
}
|
||||
const data = await apiFetch('/chat', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@@ -1027,7 +1052,7 @@ function TutorApp({ currentUser, onLogout }) {
|
||||
...getLessonContextPayload(),
|
||||
}),
|
||||
})
|
||||
const shouldAdvance = data.advance_lesson_step || answerValidatesCurrentCard(text)
|
||||
const shouldAdvance = data.advance_lesson_step
|
||||
if (shouldAdvance) {
|
||||
rememberActiveCard({ score: 100, validated: true })
|
||||
const nextStep = getNextLessonStep()
|
||||
|
||||
Reference in New Issue
Block a user