public function timeout(RunnerServiceContext $context, $scope, $ref, $late = false)
    {
        if ($context instanceof QtiRunnerServiceContext) {
            /* @var TestSession $session */
            $session = $context->getTestSession();
            if ($context->isAdaptive()) {
                \common_Logger::t("Select next item before timeout");
                $context->selectAdaptiveNextItem();
            }
            try {
                $session->closeTimer($ref, $scope);
                if ($late) {
                    if ($scope == 'assessmentTest') {
                        $code = AssessmentTestSessionException::ASSESSMENT_TEST_DURATION_OVERFLOW;
                    } else if ($scope == 'testPart') {
                        $code = AssessmentTestSessionException::TEST_PART_DURATION_OVERFLOW;
                    } else if ($scope == 'assessmentSection') {
                        $code = AssessmentTestSessionException::ASSESSMENT_SECTION_DURATION_OVERFLOW;
                    } else {
                        $code = AssessmentTestSessionException::ASSESSMENT_ITEM_DURATION_OVERFLOW;
                    }
                    throw new AssessmentTestSessionException("Maximum duration of ${scope} '${ref}' not respected.", $code);
                } else {
                    $session->checkTimeLimits(false, true, false);
                }
            } catch (AssessmentTestSessionException $e) {
                $this->onTimeout($context, $e);
            }

        } else {
            throw new \common_exception_InvalidArgumentType(
                'QtiRunnerService',
                'timeout',
                0,
                'oat\taoQtiTest\models\runner\QtiRunnerServiceContext',
                $context
            );
        }

        return true;
    }