models/classes/cat/CatService.php
public function getCatSession(AssessmentTestSession $testSession, \tao_models_classes_service_StorageDirectory $compilationDirectory, RouteItem $routeItem = null)
    {
        if ($catSection = $this->getCatSection($testSession, $compilationDirectory, $routeItem)) {
            $catSectionId = $catSection->getSectionId();

            if (!isset($this->catSession[$catSectionId])) {
                // No retrieval trial yet in the current execution context.
                $this->catSession = false;

                $catSessionData = $this->getServiceManager()->get(ExtendedStateService::SERVICE_ID)->getCatValue(
                    $testSession->getSessionId(),
                    $catSection->getSectionId(),
                    'cat-session'
                );

                if ($catSessionData) {
                    // We already have something in persistence for the session, let's restore it.
                    $this->catSession[$catSectionId] = $catSection->restoreSession($catSessionData);
                    \common_Logger::d("CAT Session '" . $this->catSession[$catSectionId]->getTestTakerSessionId() . "' for CAT Section '${catSectionId}' restored.");
                } else {
                    // First time the session is required, let's initialize it.
                    $this->isInitialCall = true;
                    // Rebuild the catSection to be able to alter call options
                    $catSection = $this->getCatSection($testSession, $compilationDirectory, $routeItem);
                    $this->catSession[$catSectionId] = $catSection->initSession([], []);
                    $assessmentSection = $routeItem ? $routeItem->getAssessmentSection() : $testSession->getCurrentAssessmentSection();

                    $event = new InitializeAdaptiveSessionEvent(
                        $testSession,
                        $assessmentSection,
                        $this->catSession[$catSectionId]
                    );

                    $this->getServiceManager()->get(EventManager::SERVICE_ID)->trigger($event);
                    $this->persistCatSession($this->catSession[$catSectionId], $testSession, $compilationDirectory, $routeItem);
                    \common_Logger::d("CAT Session '" . $this->catSession[$catSectionId]->getTestTakerSessionId() . "' for CAT Section '${catSectionId}' initialized and persisted.");
                }
            }

            return $this->catSession[$catSectionId];

        } else {
            return false;
        }
    }
public function getCatSession(AssessmentTestSession $testSession, \tao_models_classes_service_StorageDirectory $compilationDirectory, RouteItem $routeItem = null)
    {
        if ($catSection = $this->getCatSection($testSession, $compilationDirectory, $routeItem)) {
            $catSectionId = $catSection->getSectionId();

            if (!isset($this->catSession[$catSectionId])) {
                // No retrieval trial yet in the current execution context.
                $this->catSession = false;

                $catSessionData = $this->getServiceManager()->get(ExtendedStateService::SERVICE_ID)->getCatValue(
                    $testSession->getSessionId(),
                    $catSection->getSectionId(),
                    'cat-session'
                );

                if ($catSessionData) {
                    // We already have something in persistence for the session, let's restore it.
                    $this->catSession[$catSectionId] = $catSection->restoreSession($catSessionData);
                    \common_Logger::d("CAT Session '" . $this->catSession[$catSectionId]->getTestTakerSessionId() . "' for CAT Section '${catSectionId}' restored.");
                } else {
                    // First time the session is required, let's initialize it.
                    $this->isInitialCall = true;
                    // Rebuild the catSection to be able to alter call options
                    $catSection = $this->getCatSection($testSession, $compilationDirectory, $routeItem);
                    $this->catSession[$catSectionId] = $catSection->initSession([], []);
                    $assessmentSection = $routeItem ? $routeItem->getAssessmentSection() : $testSession->getCurrentAssessmentSection();

                    $event = new InitializeAdaptiveSessionEvent(
                        $testSession,
                        $assessmentSection,
                        $this->catSession[$catSectionId]
                    );

                    $this->getServiceManager()->get(EventManager::SERVICE_ID)->trigger($event);
                    $this->persistCatSession($this->catSession[$catSectionId], $testSession, $compilationDirectory, $routeItem);
                    \common_Logger::d("CAT Session '" . $this->catSession[$catSectionId]->getTestTakerSessionId() . "' for CAT Section '${catSectionId}' initialized and persisted.");
                }
            }

            return $this->catSession[$catSectionId];

        } else {
            return false;
        }
    }
Get the current CAT Session Object.

If it catSession from tao is not set, set the $this->isInitialCall to true

@param AssessmentTestSession $testSession
@param \tao_models_classes_service_StorageDirectory $compilationDirectory
@param RouteItem|null $routeItem
@return \oat\libCat\CatSession|false