Bug Cards
This commit is contained in:
@@ -730,15 +730,40 @@ function TutorApp({ currentUser, onLogout }) {
|
||||
}
|
||||
|
||||
function goToNextLessonStep() {
|
||||
const nextStep = getNextLessonStep()
|
||||
if (!nextStep) return
|
||||
setActiveAssetIndex(nextStep.assetIndex)
|
||||
setActiveSectionIndex(nextStep.sectionIndex)
|
||||
}
|
||||
|
||||
function getNextLessonStep() {
|
||||
const sectionCount = activeSections.length || 1
|
||||
if (activeSectionIndex < sectionCount - 1) {
|
||||
setActiveSectionIndex((index) => index + 1)
|
||||
return
|
||||
return {
|
||||
assetIndex: activeAssetIndex,
|
||||
sectionIndex: activeSectionIndex + 1,
|
||||
asset: activeAsset,
|
||||
section: activeSections[activeSectionIndex + 1],
|
||||
}
|
||||
}
|
||||
if (activeAssetIndex < lessonAssets.length - 1) {
|
||||
setActiveAssetIndex((index) => index + 1)
|
||||
setActiveSectionIndex(0)
|
||||
const nextAsset = lessonAssets[activeAssetIndex + 1]
|
||||
return {
|
||||
assetIndex: activeAssetIndex + 1,
|
||||
sectionIndex: 0,
|
||||
asset: nextAsset,
|
||||
section: nextAsset?.sections?.[0] || null,
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
function buildNextCardInstruction(nextStep) {
|
||||
const title = nextStep?.section?.title || nextStep?.asset?.title || 'la suite'
|
||||
if (title.toLowerCase().startsWith('exemple')) {
|
||||
return `Très bien, on passe à ${title}. Lis seulement le nombre affiché.`
|
||||
}
|
||||
return `Très bien, on passe à ${title}. Regarde cette card.`
|
||||
}
|
||||
|
||||
function getSectionKey(asset, section) {
|
||||
@@ -926,15 +951,25 @@ function TutorApp({ currentUser, onLogout }) {
|
||||
...getLessonContextPayload(),
|
||||
}),
|
||||
})
|
||||
appendMessage('assistant', data.reply)
|
||||
setCurrentInstruction(data.reply)
|
||||
if (data.advance_lesson_step) {
|
||||
rememberActiveCard({ score: 100, validated: true })
|
||||
goToNextLessonStep()
|
||||
const nextStep = getNextLessonStep()
|
||||
const transitionReply = nextStep
|
||||
? buildNextCardInstruction(nextStep)
|
||||
: 'Très bien, cette fiche est terminée.'
|
||||
if (nextStep) {
|
||||
setActiveAssetIndex(nextStep.assetIndex)
|
||||
setActiveSectionIndex(nextStep.sectionIndex)
|
||||
}
|
||||
appendMessage('assistant', transitionReply)
|
||||
setCurrentInstruction(transitionReply)
|
||||
speak(transitionReply)
|
||||
} else {
|
||||
rememberActiveCard({ score: 40, validated: false })
|
||||
appendMessage('assistant', data.reply)
|
||||
setCurrentInstruction(data.reply)
|
||||
speak(data.reply)
|
||||
}
|
||||
speak(data.reply)
|
||||
}
|
||||
|
||||
async function transcribeRecording(audioBlob, mimeType, { autoSend = false } = {}) {
|
||||
|
||||
Reference in New Issue
Block a user