public function jsonSerialize()
    {
        $source = $this->getSource();
        $timeLimits = $source->getTimeLimits();
        if(!is_null($timeLimits)){
            $identifier = $source->getIdentifier();

            $maxTime = $timeLimits->getMaxTime();
            $minTime = $timeLimits->getMinTime();
            $maxTimeRemaining = $this->getMaximumRemainingTime();
            $minTimeRemaining = $this->getMinimumRemainingTime();
            if ($maxTimeRemaining !== false || $minTimeRemaining !== false) {

                $label = method_exists($source, 'getTitle') ? $source->getTitle() : $identifier;

                $extraTime = [];
                if (!is_null($this->getTimer()) && $source->getTimeLimits()->hasMaxTime()) {
                    $timer = $this->getTimer();
                    $maxTimeSeconds = $source->getTimeLimits()->getMaxTime()->getSeconds(true);
                    $extraTime = [
                        'total' => $timer->getExtraTime($maxTimeSeconds),
                        'consumed' => $timer->getConsumedExtraTime($identifier, $maxTimeSeconds, $this->timerTarget),
                        'remaining' => $timer->getRemainingExtraTime($identifier, $maxTimeSeconds, $this->timerTarget),
                    ];
                }

                /** @var TimerLabelFormatterService $labelFormatter */
                $labelFormatter = ServiceManager::getServiceManager()->get(TimerLabelFormatterService::SERVICE_ID);
                return [
                    'label'               => $labelFormatter->format($label),
                    'source'              => $identifier,
                    'qtiClassName'        => $source->getQtiClassName(),
                    'extraTime'           => $extraTime,
                    'allowLateSubmission' => $this->allowLateSubmission(),
                    'minTime'             => $this->durationToMs($minTime),
                    'minTimeRemaining'    => $this->durationToMs($minTimeRemaining),
                    'maxTime'             => $this->durationToMs($maxTime),
                    'maxTimeRemaining'    => $this->durationToMs($maxTimeRemaining),
                ];
            }
        }
        return null;
    }
public function jsonSerialize()
    {
        $source = $this->getSource();
        $timeLimits = $source->getTimeLimits();
        if(!is_null($timeLimits)){
            $identifier = $source->getIdentifier();

            $maxTime = $timeLimits->getMaxTime();
            $minTime = $timeLimits->getMinTime();
            $maxTimeRemaining = $this->getMaximumRemainingTime();
            $minTimeRemaining = $this->getMinimumRemainingTime();
            if ($maxTimeRemaining !== false || $minTimeRemaining !== false) {

                $label = method_exists($source, 'getTitle') ? $source->getTitle() : $identifier;

                $extraTime = [];
                if (!is_null($this->getTimer()) && $source->getTimeLimits()->hasMaxTime()) {
                    $timer = $this->getTimer();
                    $maxTimeSeconds = $source->getTimeLimits()->getMaxTime()->getSeconds(true);
                    $extraTime = [
                        'total' => $timer->getExtraTime($maxTimeSeconds),
                        'consumed' => $timer->getConsumedExtraTime($identifier, $maxTimeSeconds, $this->timerTarget),
                        'remaining' => $timer->getRemainingExtraTime($identifier, $maxTimeSeconds, $this->timerTarget),
                    ];
                }

                /** @var TimerLabelFormatterService $labelFormatter */
                $labelFormatter = ServiceManager::getServiceManager()->get(TimerLabelFormatterService::SERVICE_ID);
                return [
                    'label'               => $labelFormatter->format($label),
                    'source'              => $identifier,
                    'qtiClassName'        => $source->getQtiClassName(),
                    'extraTime'           => $extraTime,
                    'allowLateSubmission' => $this->allowLateSubmission(),
                    'minTime'             => $this->durationToMs($minTime),
                    'minTimeRemaining'    => $this->durationToMs($minTimeRemaining),
                    'maxTime'             => $this->durationToMs($maxTime),
                    'maxTimeRemaining'    => $this->durationToMs($maxTimeRemaining),
                ];
            }
        }
        return null;
    }
public function jsonSerialize ( ) { $ source = $ this -> getSource ( ) ; $ timeLimits = $ source -> getTimeLimits ( ) ; if ( ! is_null ( $ timeLimits ) ) { $ identifier = $ source -> getIdentifier ( ) ; $ maxTime = $ timeLimits -> getMaxTime ( ) ; $ minTime = $ timeLimits -> getMinTime ( ) ; $ maxTimeRemaining = $ this -> getMaximumRemainingTime ( ) ; $ minTimeRemaining = $ this -> getMinimumRemainingTime ( ) ; if ( $ maxTimeRemaining !== false || $ minTimeRemaining !== false ) { $ label = method_exists ( $ source , 'getTitle' ) ? $ source -> getTitle ( ) : $ identifier ; $ extraTime = [ ] ; if ( ! is_null ( $ this -> getTimer ( ) ) && $ source -> getTimeLimits ( ) -> hasMaxTime ( ) ) { $ timer = $ this -> getTimer ( ) ; $ maxTimeSeconds = $ source -> getTimeLimits ( ) -> getMaxTime ( ) -> getSeconds ( true ) ; $ extraTime = [ 'total' => $ timer -> getExtraTime ( $ maxTimeSeconds ) , 'consumed' => $ timer -> getConsumedExtraTime ( $ identifier , $ maxTimeSeconds , $ this -> timerTarget ) , 'remaining' => $ timer -> getRemainingExtraTime ( $ identifier , $ maxTimeSeconds , $ this -> timerTarget ) , ] ; } /** @var TimerLabelFormatterService $labelFormatter */ $ labelFormatter = ServiceManager :: getServiceManager ( ) -> get ( TimerLabelFormatterService :: SERVICE_ID ) ; return [ 'label' => $ labelFormatter -> format ( $ label ) , 'source' => $ identifier , 'qtiClassName' => $ source -> getQtiClassName ( ) , 'extraTime' => $ extraTime , 'allowLateSubmission' => $ this -> allowLateSubmission ( ) , 'minTime' => $ this -> durationToMs ( $ minTime ) , 'minTimeRemaining' => $ this -> durationToMs ( $ minTimeRemaining ) , 'maxTime' => $ this -> durationToMs ( $ maxTime ) , 'maxTimeRemaining' => $ this -> durationToMs ( $ maxTimeRemaining ) , ] ; } } return null ; }
Serialize the constraint the expected way by the TestContext and the TestMap
@return array
Serialize the constraint the expected way by the TestContext and the TestMap