'online', 'message' => 'API de MathKids Perú está lista y respondiendo.' ]); } // 1. RUTAS DE AUTENTICACIÓN elseif ($path === '/auth/login' && $method === 'POST') { AuthController::login(); } elseif ($path === '/auth/select-profile' && $method === 'POST') { AuthController::selectProfile(); } // 2. RUTAS DEL ESTUDIANTE elseif ($path === '/student/dashboard' && $method === 'GET') { StudentController::getDashboard(); } elseif ($path === '/student/questions' && $method === 'GET') { StudentController::getQuestions(); } elseif (preg_match('#^/student/questions/(\d+)$#', $path, $matches) && $method === 'GET') { StudentController::getQuestionDetail($matches[1]); } elseif (preg_match('#^/student/questions/(\d+)/attempt$#', $path, $matches) && $method === 'POST') { StudentController::attemptQuestion($matches[1]); } elseif (preg_match('#^/student/questions/(\d+)/hint$#', $path, $matches) && $method === 'GET') { StudentController::getHint($matches[1]); } elseif (preg_match('#^/student/questions/(\d+)/solution$#', $path, $matches) && $method === 'GET') { StudentController::getSolution($matches[1]); } // 3. RUTAS DEL PADRE elseif ($path === '/parent/children' && $method === 'GET') { ParentController::getChildren(); } elseif ($path === '/parent/children' && $method === 'POST') { ParentController::createChild(); } elseif (preg_match('#^/parent/children/(\d+)/progress$#', $path, $matches) && $method === 'GET') { ParentController::getChildProgress($matches[1]); } elseif (preg_match('#^/parent/children/(\d+)/help-controls$#', $path, $matches) && $method === 'PUT') { ParentController::updateHelpControls($matches[1]); } // 4. RUTAS DE ADMINISTRACIÓN elseif ($path === '/admin/questions' && $method === 'GET') { AdminController::getQuestions(); } elseif ($path === '/admin/questions' && $method === 'POST') { AdminController::createQuestion(); } elseif (preg_match('#^/admin/questions/(\d+)$#', $path, $matches) && $method === 'PUT') { AdminController::updateQuestion($matches[1]); } elseif ($path === '/admin/questions/ai-generate' && $method === 'POST') { AdminController::generateAiQuestion(); } elseif ($path === '/admin/questions/import-pdf' && $method === 'POST') { AdminController::importPdf(); } // 5. RUTA NO ENCONTRADA else { jsonResponse([ 'error' => 'No encontrado', 'message' => "La ruta '$path' [$method] no existe." ], 404); } } catch (Exception $e) { jsonResponse([ 'error' => 'Server Error', 'message' => $e->getMessage() ], 500); }