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


PHP Format::isVariableRef方法代码示例

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


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

示例1: setNumberRepeats

 /**
  * Set the numberRepeats attribute.
  *
  * @param integer|string $numberRepeats An integer or a QTI variable reference.
  * @throws \InvalidArgumentException If $numberRepeats is not an integer nor a valid QTI variable reference.
  */
 public function setNumberRepeats($numberRepeats)
 {
     if (is_int($numberRepeats) || gettype($numberRepeats) === 'string' && Format::isVariableRef($numberRepeats)) {
         $this->numberRepeats = $numberRepeats;
     } else {
         $msg = "The numberRepeats argument must be an integer or a variable reference, '" . gettype($numberRepeats) . "' given.";
         throw new InvalidArgumentException($msg);
     }
 }
开发者ID:nagyist,项目名称:qti-sdk,代码行数:15,代码来源:Repeat.php

示例2: setN

 /**
  * Set the n attribute.
  *
  * @param integer|string $n The index to lookup. It must be an integer or a variable reference.
  * @throws \InvalidArgumentException If $n is not an integer nor a variable reference.
  */
 public function setN($n)
 {
     if (is_int($n) || gettype($n) === 'string' && Format::isVariableRef($n)) {
         $this->n = $n;
     } else {
         $msg = "The n attribute must be an integer or a variable reference, '" . gettype($n) . "' given.";
         throw new InvalidArgumentException($msg);
     }
 }
开发者ID:nagyist,项目名称:qti-sdk,代码行数:15,代码来源:Index.php

示例3: unmarshall

 /**
  * Unmarshall a DOMElement object corresponding to a QTI randomFloat element.
  *
  * @param \DOMElement $element A DOMElement object.
  * @return \qtism\data\QtiComponent A RandomFloat object.
  * @throws \qtism\data\storage\xml\marshalling\UnmarshallingException If the mandatory attributes min or max ar missing.
  */
 protected function unmarshall(DOMElement $element)
 {
     // max attribute is mandatory.
     if (($max = static::getDOMElementAttributeAs($element, 'max')) !== null) {
         $max = Format::isVariableRef($max) ? $max : floatval($max);
         $object = new RandomFloat(0.0, $max);
         if (($min = static::getDOMElementAttributeAs($element, 'min')) !== null) {
             $min = Format::isVariableRef($min) ? $min : floatval($min);
             $object->setMin($min);
         }
         return $object;
     } else {
         $msg = "The mandatory attribute 'max' is missing from element '" . $element->localName . "'.";
         throw new UnmarshallingException($msg, $element);
     }
 }
开发者ID:nagyist,项目名称:qti-sdk,代码行数:23,代码来源:RandomFloatMarshaller.php

示例4: unmarshallChildrenKnown

 /**
  * Unmarshall a QTI roundTo operator element into a RoundTo object.
  *
  * @param DOMElement The roundTo element to unmarshall.
  * @param QtiComponentCollection A collection containing the child Expression objects composing the Operator.
  * @return QtiComponent A RoundTo object.
  * @throws UnmarshallingException
  */
 protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children)
 {
     if (($figures = static::getDOMElementAttributeAs($element, 'figures', 'string')) !== null) {
         if (!Format::isVariableRef($figures)) {
             $figures = intval($figures);
         }
         $object = new RoundTo($children, $figures);
         if (($roundingMode = static::getDOMElementAttributeAs($element, 'roundingMode')) !== null) {
             $object->setRoundingMode(RoundingMode::getConstantByName($roundingMode));
         }
         return $object;
     } else {
         $msg = "The mandatory attribute 'figures' is missing from element '" . $element->localName . "'.";
         throw new UnmarshallingException($msg, $element);
     }
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:24,代码来源:RoundToMarshaller.php

示例5: unmarshall

 /**
  * Unmarshall a DOMElement object corresponding to a QTI randomInteger element.
  * 
  * @param DOMElement $element A DOMElement object.
  * @return QtiComponent A RandomInteger object.
  * @throws UnmarshallingException If the mandatory attributes 'min' or 'max' are missing from $element.
  */
 protected function unmarshall(DOMElement $element)
 {
     if (($max = static::getDOMElementAttributeAs($element, 'max', 'string')) !== null) {
         $max = Format::isVariableRef($max) ? $max : intval($max);
         $object = new RandomInteger(0, $max);
         if (($step = static::getDOMElementAttributeAs($element, 'step')) !== null) {
             $object->setStep(abs(intval($step)));
         }
         if (($min = static::getDOMElementAttributeAs($element, 'min')) !== null) {
             $min = Format::isVariableRef($min) ? $min : intval($min);
             $object->setMin($min);
         }
         return $object;
     } else {
         $msg = "The mandatory attribute 'max' is missing from element '" . $element->localName . "'.";
         throw new UnmarshallingException($msg, $element);
     }
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:25,代码来源:RandomIntegerMarshaller.php

示例6: setMax

 /**
  * Set the value of the max attribute.
  *
  * @param integer $max
  * @throws \InvalidArgumentException
  */
 public function setMax($max)
 {
     if (is_int($max) || Format::isVariableRef($max)) {
         $this->max = $max;
     } else {
         $msg = "'Max' must be an integer, '" . gettype($max) . "' given.";
         throw new InvalidArgumentException($msg);
     }
 }
开发者ID:nagyist,项目名称:qti-sdk,代码行数:15,代码来源:RandomInteger.php

示例7: setIndex

 /**
  * Set the index to use when displaying a variable of ordered cardinality. Give a negative integer
  * if there is no index indicated.
  * 
  * @param integer|string $index An integer or variable reference.
  * @throws InvalidArgumentException If $index is not an integer nor a variable reference.
  */
 public function setIndex($index)
 {
     if (is_int($index) === true || Format::isVariableRef($index) === true) {
         $this->index = $index;
     } else {
         $msg = "The 'index' argument must be an integer or a variable reference, '" . $index . "' given.";
         throw new InvalidArgumentException($msg);
     }
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:16,代码来源:PrintedVariable.php

示例8: setFigures

 /**
  * Set the number of figures to round to.
  * 
  * @param integer|string $figures An integer value or a variable reference.
  * @throws InvalidArgumentException If $figures is not an integer nor a variable reference.
  */
 public function setFigures($figures)
 {
     if (is_int($figures) || gettype($figures) === 'string' && Format::isVariableRef($figures)) {
         $this->figures = $figures;
     } else {
         $msg = "The figures argument must be an integer or a variable reference, '" . $figures . "' given.";
         throw new InvalidArgumentException($msg);
     }
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:15,代码来源:EqualRounded.php

示例9: testInvalidVariableRefFormat

 /**
  * @dataProvider invalidVariableRefFormatProvider
  */
 public function testInvalidVariableRefFormat($string)
 {
     $this->assertFalse(Format::isVariableRef($string));
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:7,代码来源:FormatTest.php

示例10: setMax

 /**
  * Set the max attribute.
  *
  * @param number|string $max A numeric value or a variableRef.
  * @throws \InvalidArgumentException If $max is not a numeric value nor a variableRef.
  */
 public function setMax($max)
 {
     if (is_numeric($max) || Format::isVariableRef($max)) {
         $this->max = $max;
     } else {
         $msg = "'Max must be a numeric value or a variableRef, '" . gettype($max) . "' given.";
         throw new InvalidArgumentException($msg);
     }
 }
开发者ID:nagyist,项目名称:qti-sdk,代码行数:15,代码来源:RandomFloat.php

示例11: setMax

 /**
  * Set the max attribute.
  *
  * @param string|integer $max An integer or a variable reference.
  * @throws \InvalidArgumentException If $max is not an integer nor a variable reference.
  */
 public function setMax($max)
 {
     if (is_int($max) || gettype($max) === 'string' && Format::isVariableRef($max)) {
         $this->max = $max;
     } else {
         $msg = "The max attribute must be an integer or a variable reference, '" . $max . "' given.";
         throw new InvalidArgumentException($msg);
     }
 }
开发者ID:nagyist,项目名称:qti-sdk,代码行数:15,代码来源:AnyN.php


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