當前位置: 首頁>>代碼示例>>PHP>>正文


PHP QtiComponent::hasClass方法代碼示例

本文整理匯總了PHP中qtism\data\QtiComponent::hasClass方法的典型用法代碼示例。如果您正苦於以下問題:PHP QtiComponent::hasClass方法的具體用法?PHP QtiComponent::hasClass怎麽用?PHP QtiComponent::hasClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在qtism\data\QtiComponent的用法示例。


在下文中一共展示了QtiComponent::hasClass方法的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::hasClass方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。