diff --git a/html/kidsai/script-new.js b/html/kidsai/script-new.js index bf4264d..e881671 100644 --- a/html/kidsai/script-new.js +++ b/html/kidsai/script-new.js @@ -553,52 +553,88 @@ class KidsAIExplorer { generateContextualResponse(answer, questionIndex) { const answerLower = answer.toLowerCase(); const currentQuestion = this.questions[questionIndex]; + const questionLower = currentQuestion ? currentQuestion.toLowerCase() : ''; - // Analyze the answer and generate a contextual response - if (!answer || answer.length < 3 || answerLower.includes('don\'t know') || answerLower.includes('no idea')) { - return "That's perfectly okay! Not knowing something is the first step to learning. Let's explore this together! 🌟"; + // Handle "I don't know" or help-seeking responses + if (answerLower.includes('don\'t know') || answerLower.includes('no idea') || + answerLower.includes('what is it') || answerLower.includes('tell me') || + (answerLower === 'no' && questionLower.includes('heard of'))) { + return "That's perfectly fine! 🤗 Not knowing something just means we're about to learn something new together. Let's keep exploring!"; } - // Topic-specific responses based on the question context - if (currentQuestion && currentQuestion.toLowerCase().includes('clutch')) { - if (answerLower.includes('separate') || answerLower.includes('disconnect') || answerLower.includes('gearbox') || answerLower.includes('engine')) { - return "🎯 Excellent! You're absolutely right - the clutch does separate the engine from the gearbox! You clearly understand the basic function. That's a great foundation!"; - } else if (answerLower.includes('gear') || answerLower.includes('shift')) { - return "👍 Yes, exactly! You understand that it's all about changing gears. The clutch is the key component that makes smooth gear changes possible!"; - } else if (answerLower.includes('pedal') || answerLower.includes('foot') || answerLower.includes('press')) { - return "💡 Great observation! Yes, the clutch pedal is how the driver controls it. You're thinking about the practical side of how it works!"; + // Handle very short positive answers like "yes" + if (answerLower === 'yes' || answerLower === 'yeah' || answerLower === 'yep') { + if (questionLower.includes('bicycle') || questionLower.includes('pedal')) { + return "Great! 🚴‍♂️ Since you understand how bicycles work, you're already thinking about mechanical connections. That's exactly the kind of thinking we need!"; + } else if (questionLower.includes('heard of') || questionLower.includes('know')) { + return "Excellent! 👍 Your knowledge will help us build on these concepts together!"; } else { - return "🤔 Interesting thought! You're on the right track. The clutch is indeed a crucial part of how cars work!"; + return "Perfect! 🌟 I can see you're following along. Let's dive a bit deeper!"; } } - // Bird/flight topic responses - if (currentQuestion && (currentQuestion.toLowerCase().includes('bird') || currentQuestion.toLowerCase().includes('wing') || currentQuestion.toLowerCase().includes('fly'))) { + // Handle "no" responses + if (answerLower === 'no' || answerLower === 'nope') { + return "No problem at all! 😊 That's why we're exploring this together - to discover new things!"; + } + + // Topic-specific contextual responses + if (questionLower.includes('bicycle') || questionLower.includes('pedal') || questionLower.includes('chain')) { + if (answerLower.includes('pedal') || answerLower.includes('chain') || answerLower.includes('wheel')) { + return "�‍♂️ Excellent! You understand the connection between pedals, chain, and wheels. That mechanical connection concept is key!"; + } else if (answerLower.includes('gear') || answerLower.includes('speed')) { + return "👍 Yes! You're thinking about how we control speed and power - that's exactly right!"; + } + } + + if (questionLower.includes('car') && questionLower.includes('bicycle')) { + if (answerLower.includes('engine')) { + return "� You're thinking about the engine - that's the power source! But I'm thinking of a specific part that works between the engine and wheels, kind of like how bike pedals connect to the chain."; + } else if (answerLower.includes('gear') || answerLower.includes('transmission')) { + return "🎯 Great thinking! You're absolutely on the right track with gears and transmission systems!"; + } else if (answerLower.includes('pedal') || answerLower.includes('brake')) { + return "🦶 Good connection! You're thinking about pedals in cars. There are actually multiple pedals that do different things!"; + } + } + + if (questionLower.includes('clutch') || questionLower.includes('gears') || questionLower.includes('switch gears')) { + if (answerLower.includes('clutch')) { + return "🎯 Perfect! You know about the clutch! That's exactly what I was thinking of - the component that helps with smooth gear changes!"; + } else if (answerLower.includes('transmission') || answerLower.includes('gearbox')) { + return "🔧 Excellent! You're thinking about the transmission system. The clutch is the part that connects and disconnects the engine from the gearbox!"; + } else if (answerLower.includes('separate') || answerLower.includes('disconnect')) { + return "👍 Yes! You understand the separation concept - that's exactly what the clutch does!"; + } + } + + if (questionLower.includes('traffic light') || questionLower.includes('stopped') || questionLower.includes('engine running')) { + if (answerLower.includes('clutch') || answerLower.includes('neutral')) { + return "🚦 Brilliant! You understand that we need a way to keep the engine running while the car is stopped!"; + } else if (answerLower.includes('brake') || answerLower.includes('park')) { + return "🛑 You're thinking about stopping the car, which is important! But I'm thinking of how the engine can keep running while the wheels aren't moving."; + } + } + + // Bird flight responses + if (questionLower.includes('bird') || questionLower.includes('wing') || questionLower.includes('fly')) { if (answerLower.includes('push') || answerLower.includes('air') || answerLower.includes('lift')) { - return "🌟 Fantastic! You understand that it's all about air and creating lift! That's exactly how flight works - you're thinking like a scientist!"; + return "� Fantastic! You understand that it's all about air and creating lift! That's exactly how flight works!"; } else if (answerLower.includes('feather') || answerLower.includes('airflow')) { - return "✨ Brilliant! Feathers and airflow are absolutely key to how birds fly. You're connecting the right concepts!"; - } else if (answerLower.includes('flap') || answerLower.includes('move') || answerLower.includes('wing')) { - return "🎯 Perfect! Wing movement is exactly what creates the forces that allow birds to fly. Great observation!"; + return "✨ Brilliant! Feathers and airflow are absolutely key to how birds fly!"; + } else if (answerLower.includes('flap') || answerLower.includes('move')) { + return "🌟 Perfect! Wing movement creates the forces that allow birds to fly!"; } } - // Sky/color topic responses - if (currentQuestion && (currentQuestion.toLowerCase().includes('sky') || currentQuestion.toLowerCase().includes('blue') || currentQuestion.toLowerCase().includes('color'))) { - if (answerLower.includes('light') || answerLower.includes('scatter') || answerLower.includes('blue')) { - return "💙 Excellent! You're thinking about light and how it behaves - that's exactly the scientific principle behind the blue sky!"; - } else if (answerLower.includes('particle') || answerLower.includes('air') || answerLower.includes('atmosphere')) { - return "🔬 Great scientific thinking! The particles in our atmosphere do play a crucial role in what we see!"; - } - } - - // Generic positive responses that acknowledge effort - if (answer.length > 20) { - return "🌟 Wonderful explanation! I can see you're really thinking deeply about this. Your detailed answer shows great curiosity!"; + // Generic responses based on answer quality and engagement + if (answer.length > 25) { + return "🌟 I love your detailed thinking! You're really exploring this concept thoroughly. That kind of curiosity is what leads to great discoveries!"; } else if (answer.length > 10) { - return "👍 Good thinking! You're on the right track. I like how you're approaching this problem!"; + return "👍 Good observation! I can see you're thinking about this carefully. Your reasoning is developing nicely!"; + } else if (answer.length > 3) { + return "� Interesting thought! You're engaging with the concept. Can you help me understand your thinking a bit more?"; } else { - return "💡 Nice start! Can you tell me a bit more about what you're thinking?"; + return "🤔 I see you're thinking about this! Feel free to share whatever comes to mind - there are no wrong answers here!"; } }