Converts raw data into a Pair question entity.

@param array        $data
@param PairQuestion $pairQuestion
@param array        $options

@return PairQuestion
188202
public function deserialize($data, PairQuestion $pairQuestion = null, array $options = [])
    {
        if (empty($pairQuestion)) {
            $pairQuestion = new PairQuestion();
        }

        if (!empty($data['penalty']) || 0 === $data['penalty']) {
            $pairQuestion->setPenalty($data['penalty']);
        }
        $this->sipe('random', 'setShuffle', $data, $pairQuestion);

        $this->deserializeItems($pairQuestion, $data['items'], $options);
        $this->deserializeSolutions($pairQuestion, $data['solutions']);

        return $pairQuestion;
    }
1275242
public function encode($data, $options = 0) {
        $json = null;

        if ($data instanceof IArrayable) {
            $json = @json_encode($data->toArray(), $options);
        } else if ($data instanceof IJsonable) {
            $json = $data->toJson($options);
        } else if (is_array($data) || is_object($data)) {
            $json =  @json_encode($data, $options);
        } else {
            throw new InvalidDataTypeException(
                s('Can not convert data of type "%s" to json.', get_type($data))
            );
        }

        if ($json === false) {
            throw new JsonEncodeException(json_last_error_msg(), $data);
        }

        return $json;
    }
77868
public function serialize(BooleanQuestion $question, array $options = [])
    {
        // Serializes choices
        $choices = $this->serializeChoices($question, $options);

        if (in_array(Transfer::SHUFFLE_ANSWERS, $options)) {
            shuffle($choices);
        }

        $serialized = ['choices' => $choices];

        if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) {
            $serialized['solutions'] = $this->serializeSolutions($question);
        }

        return $serialized;
    }
45401
public function provide($data = null, array $options = [])
    {
        if (empty($data) && ! empty($options['entity'])) {
            $data = $options['entity'];
        }

        if ($data instanceof EntityInterface) {
            return $this->provideFromEntity($data, $this->config->getField());
        }

        if ($data instanceof RequestInterface) {
            return $this->provideFromRequest($data, $this->config->getField());
        }

        return $data;
    }
1298344
public function deserializeQuestion(array $itemData, AbstractItem $item = null, array $options = [])
    {
        return $this->getItemSerializer()->deserialize($itemData, $item, $options);
    }
785275
private function serializeSolutions(PairQuestion $pairQuestion)
    {
        // Merge rows and odd items in one array
        return array_merge(
            // Rows
            array_map(function (GridRow $row) {
                $solution = [
                    'ordered' => $row->isOrdered(),
                    'itemIds' => array_map(function (GridItem $item) {
                        return $item->getUuid();
                    }, $row->getItems()),
                    'score' => $row->getScore(),
                ];

                if ($row->getFeedback()) {
                    $solution['feedback'] = $row->getFeedback();
                }

                return $solution;
            }, $pairQuestion->getRows()->toArray()),
            // Odd items
            array_map(function (GridOdd $odd) {
                $solution = [
                    'itemIds' => [$odd->getItem()->getUuid()],
                    'score' => $odd->getScore(),
                ];

                if ($odd->getFeedback()) {
                    $solution['feedback'] = $odd->getFeedback();
                }

                return $solution;
            }, $pairQuestion->getOddItems()->toArray())
        );
    }
1139368
public function  convert($data=false,$options= false){
		if (!$data) {
			return $data;
		};
		if (!isset($data[0])) {
			$data = array($data);
		}
					
		
		
		 		
		$this->scan($data);

	}
234758
public function deserialize($data, $content = null, array $options = [])
    {
        if ('text/html' === $data['type'] || 'text/plain' === $data['type']) {
            // HTML is directly stored in the choice entity
            $content->setData($data['data']);
            $content->setResourceNode(null);
        } else {
            // Other types require a ResourceNode
            $node = $this->resourceContentSerializer->deserialize($content);

            $content->setData('');
            $content->setResourceNode($node);
        }

        return $content;
    }
839199
public function provide($data = null, array $options = [])
    {
        $field = $this->config->getField();
        $table = $this->config->getTable();

        $fieldName = $table->aliasField($field);

        $relatedProperties = $this->_getRelatedProperties($options['fieldDefinitions']->getLimit(), (string)$data);
        if (!empty($relatedProperties['dispFieldVal']) && !empty($relatedProperties['config']['parent']['module'])) {
            $relatedParentProperties = $this->_getRelatedParentProperties($relatedProperties);
            if (!empty($relatedParentProperties['dispFieldVal'])) {
                $relatedProperties['dispFieldVal'] = implode(' ' . $this->_separator . ' ', [
                    $relatedParentProperties['dispFieldVal'],
                    $relatedProperties['dispFieldVal']
                ]);
            }
        }

        $params = [
            'field' => $field,
            'association' => $options['association'],
            'type' => 'select',
            'label' => $options['label'],
            'required' => $options['fieldDefinitions']->getRequired(),
            'value' => $data,
            'relatedProperties' => $relatedProperties,
            'embedded' => !empty($options['emDataTarget']) ? $options['emDataTarget'] : $field,
            'icon' => $this->_getInputIcon($relatedProperties),
            'title' => $this->_getInputHelp($relatedProperties),
            'extraClasses' => (!empty($options['extraClasses']) ? implode(' ', $options['extraClasses']) : ''),
            'attributes' => empty($options['attributes']) ? [] : $options['attributes'],
        ];

        $defaultElement = 'CsvMigrations.FieldHandlers/HasManyFieldHandler/input';
        $element = empty($options['element']) ? $defaultElement : $options['element'];

        return $this->renderElement($element, $params);
    }
455599
public function serialize(Item $question, array $options = [])
    {
        // Serialize specific data for the item type
        $serialized = $this->serializeQuestionType($question, $options);

        if (1 === preg_match('#^application\/x\.[^/]+\+json$#', $question->getMimeType())) {
            $canEdit = $this->tokenStorage->getToken() && $this->tokenStorage->getToken()->getUser() instanceof User ?
                $this->container->get('ujm_exo.manager.item')->canEdit($question, $this->tokenStorage->getToken()->getUser()) :
                false;
            // Adds minimal information
            $serialized = array_merge($serialized, [
                'id' => $question->getUuid(),
                'autoId' => $question->getId(),
                'type' => $question->getMimeType(),
                'content' => $question->getContent(),
                'title' => $question->getTitle(),
                'meta' => $this->serializeMetadata($question, $options),
                'score' => json_decode($question->getScoreRule(), true),
                'rights' => ['edit' => $canEdit],
            ]);

            // Adds full definition of the item
            if (!in_array(Transfer::MINIMAL, $options)) {
                $serialized = array_merge($serialized, [
                    'description' => $question->getDescription(),
                    'hints' => $this->serializeHints($question, $options),
                    'objects' => $this->serializeObjects($question),
                    'resources' => $this->serializeResources($question),
                    'tags' => $this->serializeTags($question),
                ]);

                // Adds item feedback
                if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) {
                    $serialized['feedback'] = $question->getFeedback();
                }
            }
        } else {
            $serialized = array_merge($serialized, [
                'id' => $question->getUuid(),
                'type' => $question->getMimeType(),
                'title' => $question->getTitle(),
                'meta' => $this->serializeMetadata($question, $options),
            ]);

            // Adds full definition of the item
            if (!in_array(Transfer::MINIMAL, $options)) {
                $serialized = array_merge($serialized, [
                    'description' => $question->getDescription(),
                    'tags' => $this->serializeTags($question),
                ]);
            }
        }

        return $serialized;
    }
766477
public function provide($data = null, array $options = [])
    {
        $valueLabels = [
            0 => '0',
            1 => '1',
        ];

        if (empty($options['valueLabels'])) {
            $options['valueLabels'] = $valueLabels;
        }

        if (!is_array($options['valueLabels'])) {
            throw new InvalidArgumentException("valueLabels option is not an array");
        }

        if (count($options['valueLabels']) < 2) {
            throw new InvalidArgumentException("valueLabels option has insufficient items");
        }

        $result = $data ? $options['valueLabels'][1] : $options['valueLabels'][0];
        $result = (string)$result;

        return $result;
    }
979131
public function provide($data = null, array $options = [])
    {
        if (empty($options['entity'])) {
            return null;
        }

        $table = $this->config->getTable();

        // return null in cases where no table or a dummy table was provided by the config class
        try {
            $primaryKey = $table->getPrimaryKey();
        } catch (Exception $e) {
            return null;
        }

        if (! is_string($primaryKey)) {
            throw new UnsupportedPrimaryKeyException();
        }

        if ($options['entity'] instanceof EntityInterface) {
            return $options['entity']->get($primaryKey);
        }

        if ($options['entity'] instanceof ServerRequest) {
            return $options['entity']->getData($primaryKey);
        }

        return null;
    }
1113258
public function body($data = null, $options = []) {
		$default = ['buffer' => null];
		$options += $default;
		$this->body = array_merge((array) $this->body, (array) $data);
		$body = join("\r\n", $this->body);
		return ($options['buffer']) ? str_split($body, $options['buffer']) : $body;
	}
238335
public function deserialize($data, $object, array $options = [])
    {
        $properties = $this->getSerializableProperties($object, [self::INCLUDE_MANY_TO_ONE]);
        //update the mapObjectToEntity method instead of doing this
        $data = json_decode(json_encode($data));

        return $this->mapObjectToEntity(
            $properties,
            $this->resolveData($properties, $data, get_class($object)),
            $object
        );
    }
602439
public function attachmentData($data, $name, array $options = [])
    {
        $attachment = $this->createAttachmentViaData($data, $name);

        return $this->prepareAttachment($attachment, $options);
    }
1289174
public function validateAfterSchema($answerData, array $options = [])
    {
        /** @var MatchQuestion $question */
        $question = !empty($options[Validation::QUESTION]) ? $options[Validation::QUESTION] : null;
        if (empty($question)) {
            throw new \LogicException('Answer validation : Cannot perform additional validation without question.');
        }

        $errors = [];

        $proposalIds = array_map(function (Proposal $proposal) {
            return $proposal->getUuid();
        }, $question->getProposals()->toArray());

        $labelIds = array_map(function (Label $label) {
            return $label->getUuid();
        }, $question->getLabels()->toArray());

        foreach ($answerData as $answer) {
            if (!in_array($answer['itemId'], $proposalIds)) {
                $errors[] = [
                    'path' => '/itemId',
                    'message' => 'Answer `itemId` must reference an item from `items`',
                ];
            }

            if (!in_array($answer['setId'], $labelIds)) {
                $errors[] = [
                    'path' => '/setId',
                    'message' => 'Answer `setId` must reference an item from `sets`',
                ];
            }
        }

        return $errors;
    }
311533
public function insert(array $data, array $options = []) {
		return $this->getAdapter()->insert(
			$this->getTableName(),
			$data,
			$options
		);
	}