ILIAS  trunk Revision v5.2.0beta1-34115-g3a2438be29
ilAssLacCompositeBuilder Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilAssLacCompositeBuilder:

Public Member Functions

 create (array $nodes)
 Creates a composite tree structure from a nodes tree. More...
 

Protected Attributes

 $operators = array('<=','<','=','>=','>','<>','&','|')
 

Private Member Functions

 getExpression (array $node, $index)
 Manufacure an expression from the delivered node and the index. More...
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class CompositeBuilder

Date: 27.03.13 Time: 12:18

Author
Thomas Joußen tjous.nosp@m.sen@.nosp@m.datab.nosp@m.ay.d.nosp@m.e

Definition at line 26 of file ilAssLacCompositeBuilder.php.

Member Function Documentation

◆ create()

ilAssLacCompositeBuilder::create ( array  $nodes)

Creates a composite tree structure from a nodes tree.

May fail on malformed input, e.g. because not all operators could be handled. So ensure only to call this function with well-formed input data or be prepared to handle type exceptions.

Parameters
array$nodesan array structure of parsed nodes as returned by ilAssLacConditionParser::createNodeArray(), with type 'group'.
Returns
ilAssLacAbstractComposite
Exceptions
ilAssLacCompositeBuilderExceptionin some cases of invalid input.
See also
ilAssLacConditionParser::createNodeArray() for details on the expected input structure.

Definition at line 53 of file ilAssLacCompositeBuilder.php.

References $i, ILIAS\LTI\ToolProvider\$key, ilAssLacOperationManufacturer\_getInstance(), and getExpression().

54  {
55  if ($nodes['type'] == 'group') {
56  foreach ($nodes['nodes'] as $key => $child) {
57  if ($child['type'] == 'group') {
58  $nodes['nodes'][$key] = $this->create($child);
59  }
60  }
61 
62  foreach ($this->operators as $next_operator) {
63  do {
64  $index = -1;
65  for ($i = 0; $i < count($nodes['nodes']); $i++) {
66  if (!is_object($nodes['nodes'][$i]) && $nodes['nodes'][$i]['type'] == 'operator' && $nodes['nodes'][$i]['value'] == $next_operator) {
67  $index = $i;
68  break;
69  }
70  }
71  if ($index >= 0) {
72  $operation_manufacture = ilAssLacOperationManufacturer::_getInstance();
73  $operator = $operation_manufacture->manufacture($nodes['nodes'][$index]['value']);
74 
75  $operator->setNegated($nodes["negated"]);
76  $operator->addNode($this->getExpression($nodes, $index - 1));
77  $operator->addNode($this->getExpression($nodes, $index + 1));
78 
79  $new_nodes = array_slice($nodes['nodes'], 0, $index - 1);
80  $new_nodes[] = $operator;
81  $nodes['nodes'] = array_merge($new_nodes, array_slice($nodes['nodes'], $index + 2));
82  }
83  } while ($index >= 0);
84  }
85  return $nodes['nodes'][0];
86  }
88  'need node structure with type group as input'
89  );
90  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
create(array $nodes)
Creates a composite tree structure from a nodes tree.
$i
Definition: saml1-acs.php:28
string $key
Consumer key/client ID value.
Definition: System.php:193
static _getInstance()
Get an Instance of OperationManufacturer.
getExpression(array $node, $index)
Manufacure an expression from the delivered node and the index.
+ Here is the call graph for this function:

◆ getExpression()

ilAssLacCompositeBuilder::getExpression ( array  $node,
  $index 
)
private

Manufacure an expression from the delivered node and the index.

If an expression already exist in the node for
for the delivered index, this function will return the existing expression

Parameters
array$node
int$index
Returns
ilAssLacCompositeInterface

Definition at line 101 of file ilAssLacCompositeBuilder.php.

References ilAssLacExpressionManufacturer\_getInstance().

Referenced by create().

102  {
104 
105  $expression = $node['nodes'][$index];
106  if (!($expression instanceof ilAssLacAbstractComposite)) {
107  $expression = $manufacturer->manufacture($node['nodes'][$index]['value']);
108  }
109  return $expression;
110  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getInstance()
Get an Instance of ExpressionManufacturer.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $operators

ilAssLacCompositeBuilder::$operators = array('<=','<','=','>=','>','<>','&','|')
protected

Definition at line 34 of file ilAssLacCompositeBuilder.php.


The documentation for this class was generated from the following file: