本文整理汇总了PHP中qtism\data\QtiComponent类的典型用法代码示例。如果您正苦于以下问题:PHP QtiComponent类的具体用法?PHP QtiComponent怎么用?PHP QtiComponent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QtiComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: marshallChildrenKnown
/**
* @see \qtism\data\storage\xml\marshalling\RecursiveMarshaller::marshallChildrenKnown()
*/
protected function marshallChildrenKnown(QtiComponent $component, array $elements)
{
$version = $this->getVersion();
$element = self::getDOMCradle()->createElement($component->getQtiClassName());
$this->fillElement($element, $component);
self::setDOMElementAttribute($element, 'identifier', $component->getIdentifier());
self::setDOMElementAttribute($element, 'matchMax', $component->getMatchMax());
if ($component->isFixed() === true) {
self::setDOMElementAttribute($element, 'fixed', true);
}
if ($component->hasTemplateIdentifier() === true && Version::compare($version, '2.1.0', '>=') === true) {
self::setDOMElementAttribute($element, 'templateIdentifier', $component->getTemplateIdentifier());
}
if ($component->getShowHide() !== ShowHide::SHOW && Version::compare($version, '2.1.0', '>=') === true) {
self::setDOMElementAttribute($element, 'showHide', ShowHide::getNameByConstant(ShowHide::HIDE));
}
if ($component->getMatchMin() !== 0 && Version::compare($version, '2.1.0', '>=') === true) {
self::setDOMElementAttribute($element, 'matchMin', $component->getMatchMin());
}
if (Version::compare($version, '2.1.0', '<') === true) {
$matchGroup = $component->getMatchGroup();
if (count($matchGroup) > 0) {
self::setDOMElementAttribute($element, 'matchGroup', implode(' ', $matchGroup->getArrayCopy()));
}
}
foreach ($elements as $e) {
$element->appendChild($e);
}
return $element;
}
示例2: marshall
/**
* Marshall a RandomFloat object into a DOMElement object.
*
* @param \qtism\data\QtiComponent $component A RandomFloat object.
* @return \DOMElement The according DOMElement object.
*/
protected function marshall(QtiComponent $component)
{
$element = static::getDOMCradle()->createElement($component->getQtiClassName());
self::setDOMElementAttribute($element, 'min', $component->getMin());
self::setDOMElementAttribute($element, 'max', $component->getMax());
return $element;
}
示例3: marshall
/**
* Marshall a VariableMapping object into a DOMElement object.
*
* @param \qtism\data\QtiComponent $component A VariableMapping object.
* @return \DOMElement The according DOMElement object.
*/
protected function marshall(QtiComponent $component)
{
$element = static::getDOMCradle()->createElement($component->getQtiClassName());
self::setDOMElementAttribute($element, 'sourceIdentifier', $component->getSource());
self::setDOMElementAttribute($element, 'targetIdentifier', $component->getTarget());
return $element;
}
示例4: marshall
/**
* Marshall a BaseValue object into a DOMElement object.
*
* @param \qtism\data\QtiComponent $component A BaseValue object.
* @return \DOMElement The according DOMElement object.
*/
protected function marshall(QtiComponent $component)
{
$element = static::getDOMCradle()->createElement($component->getQtiClassName());
self::setDOMElementAttribute($element, 'baseType', BaseType::getNameByConstant($component->getBaseType()));
self::setDOMElementValue($element, $component->getValue());
return $element;
}
示例5: marshall
/**
* Marshall a Selection object into a DOMElement object.
*
* @param \qtism\data\QtiComponent $component A Selection object.
* @return \DOMElement The according DOMElement object.
*/
protected function marshall(QtiComponent $component)
{
$element = static::getDOMCradle()->createElement($component->getQtiClassName());
self::setDOMElementAttribute($element, 'select', $component->getSelect());
self::setDOMElementAttribute($element, 'withReplacement', $component->isWithReplacement());
return $element;
}
示例6: marshall
/**
* Marshall a RubricBlock object into a DOMElement object.
*
* @param QtiComponent $component A RubricBlock object.
* @return DOMElement The according DOMElement object.
*/
protected function marshall(QtiComponent $component)
{
$element = static::getDOMCradle()->createElement($component->getQtiClassName());
$arrayViews = array();
foreach ($component->getViews() as $view) {
$key = array_search($view, View::asArray());
// replace '_' by the space char.
$arrayViews[] = strtolower(str_replace("ò", " ", $key));
}
if (count($arrayViews) > 0) {
static::setDOMElementAttribute($element, 'view', implode(" ", $arrayViews));
}
if ($component->getUse() != '') {
static::setDOMElementAttribute($element, 'use', $component->getUse());
}
if ($component->hasXmlBase() === true) {
static::setXmlBase($element, $component->getXmlBase());
}
foreach ($component->getContent() as $block) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($block);
$element->appendChild($marshaller->marshall($block));
}
foreach ($component->getStylesheets() as $stylesheet) {
$stylesheetMarshaller = $this->getMarshallerFactory()->createMarshaller($stylesheet);
$element->appendChild($stylesheetMarshaller->marshall($stylesheet));
}
self::fillElement($element, $component);
return $element;
}
示例7: marshall
/**
* Marshall a RubricBlockRef object to its XML counterpart.
*
* @return DOMElement
*/
public function marshall(QtiComponent $component)
{
$element = self::getDOMCradle()->createElement('rubricBlockRef');
self::setDOMElementAttribute($element, 'identifier', $component->getIdentifier());
self::setDOMElementAttribute($element, 'href', $component->getHref());
return $element;
}
示例8: marshall
/**
* Marshall a PreCondition object into a DOMElement object.
*
* @param QtiComponent $component A PreCondition object.
* @return DOMElement The according DOMElement object.
*/
protected function marshall(QtiComponent $component)
{
$element = static::getDOMCradle()->createElement($component->getQtiClassName());
$marshaller = $this->getMarshallerFactory()->createMarshaller($component->getExpression());
$element->appendChild($marshaller->marshall($component->getExpression()));
return $element;
}
示例9: marshallChildrenKnown
protected function marshallChildrenKnown(QtiComponent $component, array $elements)
{
$element = self::getDOMCradle()->createElement($component->getQtiClassName());
$headers = $component->getHeaders();
if (count($headers) > 0) {
self::setDOMElementAttribute($element, 'headers', implode(" ", $headers->getArrayCopy()));
}
if ($component->hasScope() === true) {
self::setDOMElementAttribute($element, 'scope', TableCellScope::getNameByConstant($component->getScope()));
}
if ($component->hasAbbr() === true) {
self::setDOMElementAttribute($element, 'abbr', $component->getAbbr());
}
if ($component->hasAxis() === true) {
self::setDOMElementAttribute($element, 'axis', $component->getAxis());
}
if ($component->hasRowspan() === true) {
self::setDOMElementAttribute($element, 'rowspan', $component->getRowspan());
}
if ($component->hasColspan() === true) {
self::setDOMElementAttribute($element, 'colspan', $component->getColspan());
}
foreach ($component->getContent() as $c) {
$marshaller = $this->getMarshallerFactory()->createMarshaller($c);
$element->appendChild($marshaller->marshall($c));
}
self::fillElement($element, $component);
return $element;
}
示例10: marshallChildrenKnown
protected function marshallChildrenKnown(QtiComponent $component, array $elements)
{
$element = self::getDOMCradle()->createElement($component->getQtiClassName());
self::fillElement($element, $component);
self::setDOMElementAttribute($element, 'responseIdentifier', $component->getResponseIdentifier());
if ($component->hasPrompt() === true) {
$element->appendChild($this->getMarshallerFactory()->createMarshaller($component->getPrompt())->marshall($component->getPrompt()));
}
if ($component->mustShuffle() !== false) {
self::setDOMElementAttribute($element, 'shuffle', true);
}
if ($component->getMaxAssociations() !== 1) {
self::setDOMElementAttribute($element, 'maxAssociations', $component->getMaxAssociations());
}
if ($component->getMinAssociations() !== 0) {
self::setDOMElementAttribute($element, 'minAssociations', $component->getMinAssociations());
}
if ($component->hasXmlBase() === true) {
self::setXmlBase($element, $component->getXmlBase());
}
foreach ($elements as $e) {
$element->appendChild($e);
}
return $element;
}
示例11: marshall
/**
* Marshall a Weight object into a DOMElement object.
*
* @param QtiComponent $component A Weight object.
* @return DOMElement The according DOMElement object.
*/
protected function marshall(QtiComponent $component)
{
$element = static::getDOMCradle()->createElement($component->getQtiClassName());
self::setDOMElementAttribute($element, 'identifier', $component->getIdentifier());
self::setDOMElementAttribute($element, 'value', $component->getValue());
return $element;
}
示例12: buildContent
public static function buildContent(QtiComponent $component, $content)
{
$reflectionClass = new \ReflectionClass($component);
// TODO: Assumption `setContent` always has content setter on first parameter
$parameterClass = $reflectionClass->getMethod('setContent')->getParameters()[0]->getClass();
$contentType = $parameterClass->getShortName();
try {
/** @var QtiComponentCollection $content */
$content = self::validateContent($content);
if ($contentType === 'InlineCollection') {
return self::buildInlineCollectionContent($content);
} elseif ($contentType === 'BlockCollection') {
return self::buildBlockCollectionContent($content);
} elseif ($contentType === 'BlockStaticCollection') {
return self::buildBlockStaticCollectionContent($content);
} elseif ($contentType === 'FlowCollection') {
return self::buildFlowCollectionContent($content);
} elseif ($contentType === 'ObjectFlowCollection') {
return self::buildFlowCollectionContent($content);
} elseif ($contentType === 'FlowStaticCollection') {
return self::buildFlowStaticCollectionContent($content);
}
throw new MappingException('Invalid content');
} catch (\Exception $e) {
throw new MappingException('Fail mapping `' . $component->getQtiClassName() . '` - ' . $e->getMessage());
}
}
示例13: marshall
/**
* Marshall a TemplateProcessing object into a DOMElement object.
*
* @param \qtism\data\QtiComponent $component A TemplateProcessing object.
* @return \DOMElement The according DOMElement object.
* @throws \qtism\data\storage\xml\marshalling\MarshallingException
*/
protected function marshall(QtiComponent $component)
{
$element = self::getDOMCradle()->createElement('templateProcessing');
foreach ($component->getTemplateRules() as $templateRule) {
$element->appendChild($this->getMarshallerFactory()->createMarshaller($templateRule)->marshall($templateRule));
}
return $element;
}
示例14: marshall
/**
* Marshall an AreaMapEntry object into a DOMElement object.
*
* @param \qtism\data\QtiComponent $component An AreaMapEntry object.
* @return \DOMElement The according DOMElement object.
*/
protected function marshall(QtiComponent $component)
{
$element = static::getDOMCradle()->createElement($component->getQtiClassName());
self::setDOMElementAttribute($element, 'shape', Shape::getNameByConstant($component->getShape()));
self::setDOMElementAttribute($element, 'coords', $component->getCoords());
self::setDOMElementAttribute($element, 'mappedValue', $component->getMappedValue());
return $element;
}
示例15: marshall
/**
* Marshall an InterpolationTableEntry object into a DOMElement object.
*
* @param QtiComponent $component An InterpolationTableEntry object.
* @return DOMElement The according DOMElement object.
*/
protected function marshall(QtiComponent $component)
{
$element = static::getDOMCradle()->createElement($component->getQtiClassName());
self::setDOMElementAttribute($element, 'sourceValue', $component->getSourceValue());
self::setDOMElementAttribute($element, 'targetValue', $component->getTargetValue());
self::setDOMElementAttribute($element, 'includeBoundary', $component->doesIncludeBoundary());
return $element;
}