当前位置: 首页>>代码示例>>PHP>>正文


PHP QtiComponent::getClass方法代码示例

本文整理汇总了PHP中qtism\data\QtiComponent::getClass方法的典型用法代码示例。如果您正苦于以下问题:PHP QtiComponent::getClass方法的具体用法?PHP QtiComponent::getClass怎么用?PHP QtiComponent::getClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qtism\data\QtiComponent的用法示例。


在下文中一共展示了QtiComponent::getClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createProcessor

 /**
  * Create the OperatorProcessor relevant to the given $expression.
  *
  * @param \qtism\data\expressions\Expression $expression The Operator object you want to get the processor.
  * @param \qtism\runtime\expressions\operators\OperandsCollection $operands The operands to be involved in the Operator object.
  * @return \qtism\runtime\expressions\operators\OperatorProcessor An OperatorProcessor object ready to process $expression.
  * @throws \qtism\runtime\expressions\operators\OperatorProcessingException If the $operands count is not compliant with the Operator object to be processed.
  * @throws \InvalidArgumentException If $expression is not an Operator object.
  * @throws \RuntimeException If no relevant OperatorProcessor is found for the given $expression.
  */
 public function createProcessor(QtiComponent $expression, OperandsCollection $operands = null)
 {
     if ($expression instanceof Operator) {
         if ($expression instanceof CustomOperator) {
             // QTI custom operator. Try to load an autoloaded class by using
             // its class attribute value.
             if ($expression->hasClass() === true) {
                 $className = Utils::customOperatorClassToPhpClass($expression->getClass());
                 if (class_exists($className) === true) {
                     return new $className($expression, $operands);
                 } else {
                     $msg = "No custom operator implementation found for class '" . $expression->getClass() . "'.";
                     throw new RuntimeException($msg);
                 }
             } else {
                 $msg = "Only custom operators with a 'class' attribute value can be processed.";
                 throw new RuntimeException($msg);
             }
         } else {
             // QTI built-in operator.
             $qtiClassName = ucfirst($expression->getQtiClassName());
             $nsPackage = 'qtism\\runtime\\expressions\\operators\\';
             $className = $nsPackage . $qtiClassName . 'Processor';
             if (class_exists($className)) {
                 if (is_null($operands) === true) {
                     $operands = new OperandsCollection();
                 }
                 return new $className($expression, $operands);
             } else {
                 $msg = "No dedicated OperatorProcessor class found for QTI operator '{$qtiClassName}'.";
                 throw new RuntimeException($msg);
             }
         }
     } else {
         $msg = "The OperatorProcessorFactory only accepts to create processors for Operator objects.";
         throw new InvalidArgumentException($msg);
     }
 }
开发者ID:nagyist,项目名称:qti-sdk,代码行数:48,代码来源:OperatorProcessorFactory.php

示例2: marshallChildrenKnown

 /**
  * @see \qtism\data\storage\xml\marshalling\RecursiveMarshaller::marshallChildrenKnown()
  */
 protected function marshallChildrenKnown(QtiComponent $component, array $elements)
 {
     $element = self::getDOMCradle()->createElement($component->getQtiClassName());
     foreach ($elements as $elt) {
         $element->appendChild($elt);
     }
     if ($component instanceof CustomOperator) {
         if ($component->hasClass() === true) {
             self::setDOMElementAttribute($element, 'class', $component->getClass());
         }
         if ($component->hasDefinition() === true) {
             self::setDOMElementAttribute($element, 'definition', $component->getDefinition());
         }
         // Now, we have to extract the LAX content of the custom operator and put it into
         // what we are putting out. (It is possible to have no LAX content at all, it is not mandatory).
         $xml = $component->getXml();
         $operatorElt = $xml->documentElement->cloneNode(true);
         $qtiOperatorElts = self::getChildElementsByTagName($operatorElt, array_merge(self::getOperators(), self::getExpressions()));
         foreach ($qtiOperatorElts as $qtiOperatorElt) {
             $operatorElt->removeChild($qtiOperatorElt);
         }
         Utils::importChildNodes($operatorElt, $element);
         Utils::importAttributes($operatorElt, $element);
     }
     return $element;
 }
开发者ID:nagyist,项目名称:qti-sdk,代码行数:29,代码来源:OperatorMarshaller.php


注:本文中的qtism\data\QtiComponent::getClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。