public function prepare($resources, $columns)
    {
        $resultsService = ResultsService::singleton();
        $undefinedStr = __('unknown'); //some data may have not been submitted
        /**
         * @var DeliveryExecution $result
         */
        foreach ($resources as $result) {
            $itemresults = $resultsService->getVariables($result, false);

            foreach ($itemresults as $itemResultUri => $vars) {
                // cache the item information pertaining to a given itemResult (stable over time)
                if (common_cache_FileCache::singleton()->has('itemResultItemCache' . $itemResultUri)) {
                    $object = json_decode(common_cache_FileCache::singleton()->get('itemResultItemCache' . $itemResultUri), true);
                } else {
                    $object = $resultsService->getItemFromItemResult($itemResultUri);
                    if (is_null($object)) {
                        $object = $resultsService->getVariableFromTest($itemResultUri);
                    }
                    if (! is_null($object)) {
                        common_cache_FileCache::singleton()->put(json_encode($object), 'itemResultItemCache' . $itemResultUri);
                    }
                }
                if ($object) {
                    if ($object instanceof core_kernel_classes_Resource) {
                        $contextIdentifier = $object->getUri();
                    } else {
                        $contextIdentifier = $object['uriResource'];
                    }
                } else {
                    $contextIdentifier = $undefinedStr;
                }
                foreach ($vars as $var) {
                    $var = $var[0];
                    // cache the variable data
                    /**
                     * @var \taoResultServer_models_classes_Variable $varData
                     */
                    $varData = $var->variable;
                    
                    if ($varData->getBaseType() === 'file') {
                        $decodedFile = Datatypes::decodeFile($varData->getValue());
                        $varData->setValue($decodedFile['name']);
                    }
                    $variableIdentifier = (string) $varData->getIdentifier();
                    foreach ($columns as $column) {
                        if ($variableIdentifier == $column->getIdentifier() and $contextIdentifier == $column->getContextIdentifier()) {

                            $epoch = $varData->getEpoch();
                            $readableTime = "";
                            if ($epoch != "") {
                                $readableTime = "@" . tao_helpers_Date::displayeDate(tao_helpers_Date::getTimeStamp($epoch), tao_helpers_Date::FORMAT_VERBOSE);
                            }

                            $value = $varData->getValue();

                            // display the duration in seconds with microseconds
                            if ($column->getIdentifier() === 'duration') {
                                $qtiDuration = new QtiDuration($value);
                                $value = $qtiDuration->getSeconds() .'.'. $qtiDuration->getMicroseconds();
                            }

                            $this->cache[get_class($varData)][$result][$column->getContextIdentifier() . $variableIdentifier][(string) $epoch] = array(
                                $value,
                                $readableTime
                            );
                        }
                    }
                }
            }
        }
    }
public function prepare($resources, $columns)
    {
        $resultsService = ResultsService::singleton();
        $undefinedStr = __('unknown'); //some data may have not been submitted
        /**
         * @var DeliveryExecution $result
         */
        foreach ($resources as $result) {
            $itemresults = $resultsService->getVariables($result, false);

            foreach ($itemresults as $itemResultUri => $vars) {
                // cache the item information pertaining to a given itemResult (stable over time)
                if (common_cache_FileCache::singleton()->has('itemResultItemCache' . $itemResultUri)) {
                    $object = json_decode(common_cache_FileCache::singleton()->get('itemResultItemCache' . $itemResultUri), true);
                } else {
                    $object = $resultsService->getItemFromItemResult($itemResultUri);
                    if (is_null($object)) {
                        $object = $resultsService->getVariableFromTest($itemResultUri);
                    }
                    if (! is_null($object)) {
                        common_cache_FileCache::singleton()->put(json_encode($object), 'itemResultItemCache' . $itemResultUri);
                    }
                }
                if ($object) {
                    if ($object instanceof core_kernel_classes_Resource) {
                        $contextIdentifier = $object->getUri();
                    } else {
                        $contextIdentifier = $object['uriResource'];
                    }
                } else {
                    $contextIdentifier = $undefinedStr;
                }
                foreach ($vars as $var) {
                    $var = $var[0];
                    // cache the variable data
                    /**
                     * @var \taoResultServer_models_classes_Variable $varData
                     */
                    $varData = $var->variable;
                    
                    if ($varData->getBaseType() === 'file') {
                        $decodedFile = Datatypes::decodeFile($varData->getValue());
                        $varData->setValue($decodedFile['name']);
                    }
                    $variableIdentifier = (string) $varData->getIdentifier();
                    foreach ($columns as $column) {
                        if ($variableIdentifier == $column->getIdentifier() and $contextIdentifier == $column->getContextIdentifier()) {

                            $epoch = $varData->getEpoch();
                            $readableTime = "";
                            if ($epoch != "") {
                                $readableTime = "@" . tao_helpers_Date::displayeDate(tao_helpers_Date::getTimeStamp($epoch), tao_helpers_Date::FORMAT_VERBOSE);
                            }

                            $value = $varData->getValue();

                            // display the duration in seconds with microseconds
                            if ($column->getIdentifier() === 'duration') {
                                $qtiDuration = new QtiDuration($value);
                                $value = $qtiDuration->getSeconds() .'.'. $qtiDuration->getMicroseconds();
                            }

                            $this->cache[get_class($varData)][$result][$column->getContextIdentifier() . $variableIdentifier][(string) $epoch] = array(
                                $value,
                                $readableTime
                            );
                        }
                    }
                }
            }
        }
    }
public function prepare ( $ resources , $ columns ) { $ resultsService = ResultsService :: singleton ( ) ; $ undefinedStr = __ ( 'unknown' ) ; //some data may have not been submitted /**
         * @var DeliveryExecution $result
         */ foreach ( $ resources as $ result ) { $ itemresults = $ resultsService -> getVariables ( $ result , false ) ; foreach ( $ itemresults as $ itemResultUri => $ vars ) { // cache the item information pertaining to a given itemResult (stable over time) if ( common_cache_FileCache :: singleton ( ) -> has ( 'itemResultItemCache' . $ itemResultUri ) ) { $ object = json_decode ( common_cache_FileCache :: singleton ( ) -> get ( 'itemResultItemCache' . $ itemResultUri ) , true ) ; } else { $ object = $ resultsService -> getItemFromItemResult ( $ itemResultUri ) ; if ( is_null ( $ object ) ) { $ object = $ resultsService -> getVariableFromTest ( $ itemResultUri ) ; } if ( ! is_null ( $ object ) ) { common_cache_FileCache :: singleton ( ) -> put ( json_encode ( $ object ) , 'itemResultItemCache' . $ itemResultUri ) ; } } if ( $ object ) { if ( $ object instanceof core_kernel_classes_Resource ) { $ contextIdentifier = $ object -> getUri ( ) ; } else { $ contextIdentifier = $ object [ 'uriResource' ] ; } } else { $ contextIdentifier = $ undefinedStr ; } foreach ( $ vars as $ var ) { $ var = $ var [ 0 ] ; // cache the variable data /**
                     * @var \taoResultServer_models_classes_Variable $varData
                     */ $ varData = $ var -> variable ; if ( $ varData -> getBaseType ( ) === 'file' ) { $ decodedFile = Datatypes :: decodeFile ( $ varData -> getValue ( ) ) ; $ varData -> setValue ( $ decodedFile [ 'name' ] ) ; } $ variableIdentifier = ( string ) $ varData -> getIdentifier ( ) ; foreach ( $ columns as $ column ) { if ( $ variableIdentifier == $ column -> getIdentifier ( ) and $ contextIdentifier == $ column -> getContextIdentifier ( ) ) { $ epoch = $ varData -> getEpoch ( ) ; $ readableTime = "" ; if ( $ epoch != "" ) { $ readableTime = "@" . tao_helpers_Date :: displayeDate ( tao_helpers_Date :: getTimeStamp ( $ epoch ) , tao_helpers_Date :: FORMAT_VERBOSE ) ; } $ value = $ varData -> getValue ( ) ; // display the duration in seconds with microseconds if ( $ column -> getIdentifier ( ) === 'duration' ) { $ qtiDuration = new QtiDuration ( $ value ) ; $ value = $ qtiDuration -> getSeconds ( ) . '.' . $ qtiDuration -> getMicroseconds ( ) ; } $ this -> cache [ get_class ( $ varData ) ] [ $ result ] [ $ column -> getContextIdentifier ( ) . $ variableIdentifier ] [ ( string ) $ epoch ] = array ( $ value , $ readableTime ) ; } } } } } }
Short description of method prepare

@access public
@author Joel Bout, <joel.bout@tudor.lu>
@param array resources results
@param array columns variables
@return mixed
@throws \common_Exception
Short description of method prepare