isLoggedIn()) { throw new Exception('Unauthorized'); } // Get and validate input $input = json_decode(file_get_contents('php://input'), true); if (!isset($input['survey_id'])) { throw new Exception('Survey ID is required'); } $surveyManager = SurveyManager::getInstance(); $result = $surveyManager->deleteSurvey($input['survey_id'], $_SESSION['user_id']); if (!$result['success']) { throw new Exception($result['error']); } echo json_encode([ 'success' => true, 'message' => 'Survey deleted successfully' ]); } catch (Exception $e) { http_response_code(500); echo json_encode([ 'success' => false, 'error' => $e->getMessage() ]); } ?>