Item's ResponseProcessing.

@param core_kernel_classes_Resource $item The Item you want to apply ResponseProcessing.
@throws \RuntimeException If an error occurs while processing responses or transmitting results
357873
protected function processResponses(core_kernel_classes_Resource $item){

        $jsonPayload = taoQtiCommon_helpers_Utils::readJsonPayload();

        try {
            $qtiXmlFileContent = QtiFile::getQtiFileContent($item);
            $qtiXmlDoc = new XmlDocument();
            $qtiXmlDoc->loadFromString($qtiXmlFileContent);
        }
        catch(StorageException $e) {
            $msg = "An error occurred while loading QTI-XML file at expected location '${qtiXmlFilePath}'.";
            common_Logger::e(($e->getPrevious() !== null) ? $e->getPrevious()->getMessage() : $e->getMessage());
            throw new \RuntimeException($msg, 0, $e);
        }

        $itemSession = new AssessmentItemSession($qtiXmlDoc->getDocumentComponent(), new SessionManager());
        $itemSession->beginItemSession();

        $variables = array();
        $filler = new taoQtiCommon_helpers_PciVariableFiller($qtiXmlDoc->getDocumentComponent());

        // Convert client-side data as QtiSm Runtime Variables.
        foreach ($jsonPayload as $id => $response) {

            try {
                $var  = $filler->fill($id, $response);
                // Do not take into account QTI Files at preview time.
                // Simply delete the created file.
                if (taoQtiCommon_helpers_Utils::isQtiFile($var, false) === true) {
                    $fileManager = new FileSystemFileManager();
                    $fileManager->delete($var->getValue());
                }
                else {
                    $variables[] = $var;
                }
            }
            catch (OutOfRangeException $e) {
                // A variable value could not be converted, ignore it.
                // Developer's note: QTI Pairs with a single identifier (missing second identifier of the pair) are transmitted as an array of length 1,
                // this might cause problem. Such "broken" pairs are simply ignored.
                common_Logger::d("Client-side value for variable '${id}' is ignored due to data malformation.");
            }
            catch (OutOfBoundsException $e) {
                // No such identifier found in item.
                common_Logger::d("The variable with identifier '${id}' is not declared in the item definition.");
            }
        }

        try {
            $itemSession->beginAttempt();
            $itemSession->endAttempt(new State($variables));

            // Return the item session state to the client-side.
            echo json_encode(array('success' => true, 'displayFeedback' => true, 'itemSession' => self::buildOutcomeResponse($itemSession)));
        }
        catch(AssessmentItemSessionException $e) {
            $msg = "An error occurred while processing the responses.";
            throw new \RuntimeException($msg, 0, $e);
        }
        catch(taoQtiCommon_helpers_ResultTransmissionException $e) {
            $msg = "An error occurred while transmitting a result to the target Result Server.";
            throw new \RuntimeException($msg, 0, $e);
        }
    }
920299
public function setItem($key, $item) {
		if (is_array($key)) {
			$key = $this->arrayHashFunction($key);
		}
		
		if (! isset($this->_data[$key])) {
			$this->_map[] = $key;
		}
		
		if (is_object($item)) {
			$modelClass = $this->getModel();
			if (! $item instanceof $modelClass) {
				throw new Exception('Model must be an instance of "' . $modelClass . '"');
			}
			
			$item->setCollection($this);
			
			$this->_data[$key]   = &$item->getDataLinked();
			$this->_models[$key] = $item;
		}
		elseif (is_array($item)) {
			$this->_data[$key] = $item;
		}
		else {
			throw new Exception('Unknown type of item: "' . gettype($item) . '"');
		}
		
		return $this;
	}
947514
protected function normalizeWindowsObject($item, $base)
    {
        $item = \preg_replace('#\s+#', ' ', trim($item), 3);

        if (\count(\explode(' ', $item, 4)) !== 4) {
            throw new RuntimeException("Metadata can't be parsed from item '$item' , not enough parts.");
        }

        list($date, $time, $size, $name) = \explode(' ', $item, 4);
        $path = $base === '' ? $name : $base . $this->separator . $name;

        // Check for the correct date/time format
        $format = \strlen($date) === 8 ? 'm-d-yH:iA' : 'Y-m-dH:i';
        $dt = DateTime::createFromFormat($format, $date . $time);
        $timestamp = $dt ? $dt->getTimestamp() : (int) \strtotime("$date $time");

        if ($size === '<DIR>') {
            $type = 'dir';

            return \compact('type', 'path', 'timestamp');
        }

        $type = 'file';
        $visibility = AdapterInterface::VISIBILITY_PUBLIC;
        $size = (int) $size;

        return \compact('type', 'path', 'visibility', 'size', 'timestamp');
    }
437739
public function add_item(cc_i_item &$item) {
        if (is_null($this->itemlist)) {
            $this->itemlist = array();
        }
        $this->itemlist[$item->identifier] = $item;
    }
459122
private function processForm(Item $item) {

        $created = ($item && null === $item->getId());
        $statusCode = ($created)? Response::HTTP_CREATED : Response::HTTP_NO_CONTENT;
        $method = ($created) ? "POST" : "PUT";

        $form = $this->createForm(new ItemType(), $item, array('method' => $method));
        $form->handleRequest($this->getRequest());

        $view;
        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($item);
            $em->flush();

            $view = $this->view()->setStatusCode($statusCode);

            // HTTP Convention : return HTTP 201 Created + Location of created resource
            if ($created) {
                $view->setLocation(
                    $this->generateUrl('get_item', ['id' => $item->getId()])
                );
            }
        } else {
            $view = $this->view($form, Response::HTTP_BAD_REQUEST);
        }

        return $this->handleView($view);
    }
442129
public function monitor($item)
    {
        if ($item instanceof PoolInterface) {
            $item->addListener(PoolRunEvent::POOL_RUN_ADDED, [$this, 'onPoolRunAdded']);
            $item->addListener(PoolRunEvent::UPDATED, [$this, 'onPoolUpdated']);
            array_map([$this, 'monitor'], $item->getAll());
        }
        if ($item instanceof RunInterface) {
            $item->addListener(RunEvent::STARTED, [$this, 'onRunStarted']);
            $item->addListener(RunEvent::SUCCESSFUL, [$this, 'onRunSuccessful']);
            $item->addListener(RunEvent::FAILED, [$this, 'onRunFailed']);
            $item->addListener(RunEvent::COMPLETED, [$this, 'onRunCompleted']);
        }
    }
188337
public static function run(core_kernel_classes_Resource $item, core_kernel_classes_Property $classProperty)
    {
        $itemProperty = $item->getProperty($classProperty->getUri());
        $labelItemProperty = $itemProperty->getLabel();

        $extractor = new OntologyExtractor();
        $extractor->addColumn($labelItemProperty, ['property' => $classProperty->getUri()]);
        $extractor->setItem($item);
        $extractor->run();
        $data = $extractor->getData();

        return new HashEntry($labelItemProperty, $data[$labelItemProperty]);
    }
575164
public function writeItem($item)
    {
        if ($this->autoDetectHeader && $this->header === null) {
            $this->handleAutoDetectHeaders($item);
        }

        if (is_array($item)) {
            $keys = array_keys($item);
        } elseif ($this->header && is_object($item)) {
            $keys = $this->header;
        } else {
            throw new \InvalidArgumentException(sprintf(
                'Plum\PlumExcel\ExcelWriter currently only supports array items or objects if headers are set using '.
                'the setHeader() method. You have passed an item of type "%s" to writeItem().',
                gettype($item)
            ));
        }

        $column = 0;
        foreach ($keys as $key) {
            $value = Vale::get($item, $key);
            $this->excel->getActiveSheet()->setCellValueByColumnAndRow($column, $this->currentRow, $value);
            ++$column;
        }
        ++$this->currentRow;
    }
1323333
public function _handleItemAfterSync($item, $result)
    {
        $curlError = $this->_checkCurlError($item);

        if (!$curlError) {
            if (isset($result->message) && !isset($result->id)) {
                $item->setImportStatus(\Dotdigitalgroup\Email\Model\Importer::FAILED)
                    ->setMessage($result->message);

                $this->importerResource->save($item);
            } elseif (isset($result->id) && !isset($result->message)) {
                $item->setImportStatus(\Dotdigitalgroup\Email\Model\Importer::IMPORTING)
                    ->setImportId($result->id)
                    ->setImportStarted(time())
                    ->setMessage('');
                $this->importerResource->save($item);
            } else {
                $message = (isset($result->message)) ? $result->message : 'Error unknown';
                $item->setImportStatus(\Dotdigitalgroup\Email\Model\Importer::FAILED)
                    ->setMessage($message);

                //If result id
                if (isset($result->id)) {
                    $item->setImportId($result->id);
                }

                $this->importerResource->save($item);
            }
        }
    }
431365
protected function buildResponseProcessing(DOMElement $data, Item $item){
        $returnValue = null;

        // try template
        try{
            $returnValue = $this->buildTemplateResponseProcessing($data);

            try{
                //warning: require to add interactions to the item to make it work
                $returnValue = TemplatesDriven::takeOverFrom($returnValue, $item);
            }catch(TakeoverFailedException $e){}
        }catch(UnexpectedResponseProcessing $e){

        }

        //try templatedriven
        if(is_null($returnValue)){
            try{
                $returnValue = $this->buildTemplatedrivenResponse($data, $item->getInteractions());
            }catch(UnexpectedResponseProcessing $e){}
        }

        // build custom
        if(is_null($returnValue)){
            try{
                $returnValue = $this->buildCustomResponseProcessing($data);
            }catch(UnexpectedResponseProcessing $e){
                // not a Template
                common_Logger::e('custom response processing failed', array('TAOITEMS', 'QTI'));
            }
        }

        if(is_null($returnValue)){
            common_Logger::w('failed to determine ResponseProcessing');
        }

        return $returnValue;
    }
1128741
public void setItem(java.util.Collection<EndpointResponse> item) {
        if (item == null) {
            this.item = null;
            return;
        }

        this.item = new java.util.ArrayList<EndpointResponse>(item);
    }
63337
public function getItemModel(core_kernel_classes_Resource $item)
    {
        $returnValue = null;

        $itemModel = $item->getOnePropertyValue($this->itemModelProperty);
        if ($itemModel instanceof core_kernel_classes_Resource) {
            $returnValue = $itemModel;
        }

        return $returnValue;
    }
1173332
protected function prepareItem($item)
    {
        if (!isset($item["type"])) {
            return $item;
        }

        if (isset($item["children"])) {
            $item["children"] = $this->prepareItems($item["children"]);
        }

        switch ($item['type']) {
            case 'select':
                if (isset($item['sql'])) {
                    $connectionName = isset($item['connection']) ? $item['connection'] : 'default';
                    $sql            = $item['sql'];
                    $options        = isset($item["options"]) ? $item["options"] : array();

                    unset($item['sql']);
                    unset($item['connection']);
                    /** @var Connection $connection */
                    $connection = $this->container->get("doctrine.dbal.{$connectionName}_connection");
                    $all        = $connection->fetchAll($sql);
                    foreach ($all as $option) {
                        $options[] = array(reset($option), end($option));
                    }
                    $item["options"] = $options;
                }

                if (isset($item['service'])) {
                    $serviceInfo = $item['service'];
                    $serviceName = isset($serviceInfo['serviceName']) ? $serviceInfo['serviceName'] : 'default';
                    $method      = isset($serviceInfo['method']) ? $serviceInfo['method'] : 'get';
                    $args        = isset($serviceInfo['args']) ? $item['args'] : '';
                    $service     = $this->container->get($serviceName);
                    $options     = $service->$method($args);

                    $item['options'] = $options;
                }

                if (isset($item['dataStore'])) {
                    $dataStoreInfo = $item['dataStore'];
                    $dataStore     = $this->container->get('data.source')->get($dataStoreInfo["id"]);
                    $options       = array();
                    foreach ($dataStore->search() as $dataItem) {
                        $options[ $dataItem->getId() ] = $dataItem->getAttribute($dataStoreInfo["text"]);
                    }
                    if (isset($item['dataStore']['popupItems'])) {
                        $item['dataStore']['popupItems'] = $this->prepareItems($item['dataStore']['popupItems']);
                    }
                    $item['options'] = $options;
                }
                break;
        }
        return $item;
    }
966024
public function itemCreate(Item $item)
    {
        $response = $this->getGuzzleClient()
            ->post(
                '/items',
                array_merge($this->setQuery(), $this->setBody($item))
            );

        return $this->serializer->deserialize(
            $response->getBody()->getContents(),
            Item::class,
            'json'
        );
    }
549162
public void setItem(java.util.Collection<ApplicationResponse> item) {
        if (item == null) {
            this.item = null;
            return;
        }

        this.item = new java.util.ArrayList<ApplicationResponse>(item);
    }
1119646
private function parseItem(Item $item)
    {
        // Get and format an item
        $tmp = $this->getFormattedItem($item);

        // Get related data
        $relationships = $this->getRelationships($item);

        // Closure function to internally parse related includes
        $parseRelationships = function($key, Item $item, array $relationships = []) {
            $related = $this->getFormattedItem($item);

            if (!in_array($related, $this->relationships)) {
                $this->relationships[] = $related;
            }

            unset($related['attributes']);
            unset($related['links']);
            $relationships[$key]['data'][] = $related;

            return $relationships;
        };

        // Loop data to create includes response data
        foreach ($relationships as $key => $value) {
            if ($value instanceof Collection) {
                foreach ($value->getData() as $include_value) {
                    $relationships = $parseRelationships($key, new Item($include_value, $value->getTransformer()), $relationships);
                }
            } else if ($value instanceof Item) {
                $relationships = $parseRelationships($key, $value, $relationships);
            }
        }

        // Pass the relationships data into the item
        $tmp['relationships'] = $relationships;

        // Set the response data
        if (is_array($this->data)) {
            $this->data[] = $tmp;
        } else {
            $this->data = $tmp;
        }

        return $this;
    }
1183231
public function add($item)
    {
        foreach ($this->_requiredInterfaces as $interface) {
            if (!$item instanceof $interface) {
                throw new RuntimeException(
                    sprintf('Item "%s" should implement "%s" interface', get_class($item), $interface)
                );
            }
        }
        
        $this->_items[spl_object_hash($item)] = $item;
        return $this;
    }