protected function unpackTimeLine(&$data)
    {
        $timeLine = new QtiTimeLine();

        // the stored data can be packed or not
        if (isset($data[self::STORAGE_KEY_TIMELINE_POINTS])) {
            // get the reference value used to compress the timestamps
            $epoch = 0;
            if (isset($data[self::STORAGE_KEY_TIMELINE_EPOCH])) {
                $epoch = $data[self::STORAGE_KEY_TIMELINE_EPOCH];
            }

            // rebuild the TimeLine from the list of stored TimePoint
            $tags = $data[self::STORAGE_KEY_TIMELINE_TAGS];
            foreach ($data[self::STORAGE_KEY_TIMELINE_POINTS] as &$dataPoint) {
                $point = new TimePoint($tags, $dataPoint[2] + $epoch, $dataPoint[1], $dataPoint[0]);
                $timeLine->add($point);
            }

            // reassign the tags from the stored index
            $points = $timeLine->getPoints();
            foreach ($data[self::STORAGE_KEY_TIMELINE_INDEX] as $tag => &$list) {
                foreach ($list as $index) {
                    $points[$index]->addTag($tag);
                }
            }
        } else {
            $timeLine->fromArray($data);
        }

        return $timeLine;
    }
protected function unpackTimeLine(&$data)
    {
        $timeLine = new QtiTimeLine();

        // the stored data can be packed or not
        if (isset($data[self::STORAGE_KEY_TIMELINE_POINTS])) {
            // get the reference value used to compress the timestamps
            $epoch = 0;
            if (isset($data[self::STORAGE_KEY_TIMELINE_EPOCH])) {
                $epoch = $data[self::STORAGE_KEY_TIMELINE_EPOCH];
            }

            // rebuild the TimeLine from the list of stored TimePoint
            $tags = $data[self::STORAGE_KEY_TIMELINE_TAGS];
            foreach ($data[self::STORAGE_KEY_TIMELINE_POINTS] as &$dataPoint) {
                $point = new TimePoint($tags, $dataPoint[2] + $epoch, $dataPoint[1], $dataPoint[0]);
                $timeLine->add($point);
            }

            // reassign the tags from the stored index
            $points = $timeLine->getPoints();
            foreach ($data[self::STORAGE_KEY_TIMELINE_INDEX] as $tag => &$list) {
                foreach ($list as $index) {
                    $points[$index]->addTag($tag);
                }
            }
        } else {
            $timeLine->fromArray($data);
        }

        return $timeLine;
    }
protected function unpackTimeLine ( & $ data ) { $ timeLine = new QtiTimeLine ( ) ; // the stored data can be packed or not if ( isset ( $ data [ self :: STORAGE_KEY_TIMELINE_POINTS ] ) ) { // get the reference value used to compress the timestamps $ epoch = 0 ; if ( isset ( $ data [ self :: STORAGE_KEY_TIMELINE_EPOCH ] ) ) { $ epoch = $ data [ self :: STORAGE_KEY_TIMELINE_EPOCH ] ; } // rebuild the TimeLine from the list of stored TimePoint $ tags = $ data [ self :: STORAGE_KEY_TIMELINE_TAGS ] ; foreach ( $ data [ self :: STORAGE_KEY_TIMELINE_POINTS ] as & $ dataPoint ) { $ point = new TimePoint ( $ tags , $ dataPoint [ 2 ] + $ epoch , $ dataPoint [ 1 ] , $ dataPoint [ 0 ] ) ; $ timeLine -> add ( $ point ) ; } // reassign the tags from the stored index $ points = $ timeLine -> getPoints ( ) ; foreach ( $ data [ self :: STORAGE_KEY_TIMELINE_INDEX ] as $ tag => & $ list ) { foreach ( $ list as $ index ) { $ points [ $ index ] -> addTag ( $ tag ) ; } } } else { $ timeLine -> fromArray ( $ data ) ; } return $ timeLine ; }
Unpack a dataset to a workable TimeLine
@param array $data
@return TimeLine
Unpack a dataset to a workable TimeLine