ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilAssLacCompositeBuilder Class Reference

Class CompositeBuilder. More...

+ Collaboration diagram for ilAssLacCompositeBuilder:

Public Member Functions

 __construct ()
 Construct requirements. More...
 
 create ($nodes)
 

Protected Attributes

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

Private Member Functions

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

Detailed Description

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 10 of file ilAssLacCompositeBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

ilAssLacCompositeBuilder::__construct ( )

Construct requirements.

Definition at line 23 of file ilAssLacCompositeBuilder.php.

24  {
25  include_once 'Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/Factory/ilAssLacOperationManufacturer.php';
26  include_once 'Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/Factory/ilAssLacExpressionManufacturer.php';
27  }

Member Function Documentation

◆ create()

ilAssLacCompositeBuilder::create (   $nodes)
Parameters
array$nodes
Returns
array

Definition at line 34 of file ilAssLacCompositeBuilder.php.

References ilAssLacOperationManufacturer\_getInstance(), and getExpression().

35  {
36  if($nodes['type'] == 'group')
37  {
38  foreach($nodes['nodes'] as $key => $child)
39  {
40  $nodes['nodes'][$key] = $this->create($child);
41  }
42 
43  foreach($this->operators as $next_operator)
44  {
45  do{
46  $index = -1;
47  for($i = 0; $i < count($nodes['nodes']); $i++)
48  {
49  if(!is_object($nodes['nodes'][$i]) && $nodes['nodes'][$i]['type'] == 'operator' && $nodes['nodes'][$i]['value'] == $next_operator)
50  {
51  $index = $i;
52  break;
53  }
54  }
55  if($index >= 0)
56  {
57  $operation_manufacture = ilAssLacOperationManufacturer::_getInstance();
58  $operator = $operation_manufacture->manufacture($nodes['nodes'][$index]['value']);
59 
60  $operator->setNegated($nodes["negated"]);
61  $operator->addNode($this->getExpression($nodes, $index-1));
62  $operator->addNode($this->getExpression($nodes, $index+1));
63 
64  $new_nodes = array_slice($nodes['nodes'], 0, $index - 1);
65  $new_nodes[] = $operator;
66  $nodes['nodes'] = array_merge($new_nodes, array_slice($nodes['nodes'], $index + 2));
67  }
68  }while($index >= 0);
69  }
70  return $nodes['nodes'][0];
71  }
72  return $nodes;
73  }
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 84 of file ilAssLacCompositeBuilder.php.

References ilAssLacExpressionManufacturer\_getInstance().

Referenced by create().

85  {
87 
88  $expression = $node['nodes'][$index];
89  if(!($expression instanceof ilAssLacAbstractComposite))
90  {
91  $expression = $manufacturer->manufacture($node['nodes'][$index]['value']);
92  }
93  return $expression;
94  }
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 18 of file ilAssLacCompositeBuilder.php.


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