/**
  * Short description of method build
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param  SimpleXMLElement data
  * @return oat\taoQtiItem\model\qti\expression\Expression
  */
 public static function build(SimpleXMLElement $data)
 {
     $returnValue = null;
     $expression = null;
     $expressionName = $data->getName();
     //retrieve the expression attributes
     $attributes = array();
     foreach ($data->attributes() as $key => $value) {
         $attributes[$key] = (string) $value;
     }
     // Create expression function of its type (If specialization has been done for the expression type)
     $expressionClass = 'oat\\taoQtiItem\\model\\qti\\expression\\' . ucfirst($expressionName);
     if (class_exists($expressionClass)) {
         $expression = new $expressionClass($expressionName, $attributes);
     } else {
         $expression = new CommonExpression($expressionName, $attributes);
     }
     // If the expression has a value
     $expressionValue = (string) trim($data);
     if ($expressionValue != '') {
         $expression->setValue($expressionValue);
     }
     // All sub-expressions of an expression are embedded by this expression
     $subExpressions = array();
     foreach ($data->children() as $subExpressionNode) {
         $subExpressions[] = self::build($subExpressionNode);
     }
     $expression->setSubExpressions($subExpressions);
     $returnValue = $expression;
     return $returnValue;
 }
 /**
  * Short description of method getCompositionRules
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @return array
  */
 public function getCompositionRules()
 {
     $subExpressions = array();
     foreach ($this->components as $irp) {
         $subExpressions[] = new CommonExpression('variable', array('identifier' => $irp->getOutcome()->getIdentifier()));
     }
     $sum = new CommonExpression('sum', array());
     $sum->setSubExpressions($subExpressions);
     $summationRule = new SetOutcomeVariable($this->outcomeIdentifier, $sum);
     $returnValue = array($summationRule);
     return (array) $returnValue;
 }