ILIAS  release_7 Revision v7.30-3-g800a261c036
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 24 of file ilAssLacCompositeBuilder.php.

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

Member Function Documentation

◆ create()

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

Definition at line 35 of file ilAssLacCompositeBuilder.php.

36 {
37 if ($nodes['type'] == 'group') {
38 foreach ($nodes['nodes'] as $key => $child) {
39 $nodes['nodes'][$key] = $this->create($child);
40 }
41
42 foreach ($this->operators as $next_operator) {
43 do {
44 $index = -1;
45 for ($i = 0; $i < count($nodes['nodes']); $i++) {
46 if (!is_object($nodes['nodes'][$i]) && $nodes['nodes'][$i]['type'] == 'operator' && $nodes['nodes'][$i]['value'] == $next_operator) {
47 $index = $i;
48 break;
49 }
50 }
51 if ($index >= 0) {
52 $operation_manufacture = ilAssLacOperationManufacturer::_getInstance();
53 $operator = $operation_manufacture->manufacture($nodes['nodes'][$index]['value']);
54
55 $operator->setNegated($nodes["negated"]);
56 $operator->addNode($this->getExpression($nodes, $index - 1));
57 $operator->addNode($this->getExpression($nodes, $index + 1));
58
59 $new_nodes = array_slice($nodes['nodes'], 0, $index - 1);
60 $new_nodes[] = $operator;
61 $nodes['nodes'] = array_merge($new_nodes, array_slice($nodes['nodes'], $index + 2));
62 }
63 } while ($index >= 0);
64 }
65 return $nodes['nodes'][0];
66 }
67 return $nodes;
68 }
getExpression(array $node, $index)
Manufacure an expression from the delivered node and the index.
static _getInstance()
Get an Instance of OperationManufacturer.
$index
Definition: metadata.php:128
$i
Definition: metadata.php:24

References $i, $index, ilAssLacOperationManufacturer\_getInstance(), create(), and getExpression().

Referenced by create().

+ Here is the call graph for this function:
+ Here is the caller 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 79 of file ilAssLacCompositeBuilder.php.

80 {
82
83 $expression = $node['nodes'][$index];
84 if (!($expression instanceof ilAssLacAbstractComposite)) {
85 $expression = $manufacturer->manufacture($node['nodes'][$index]['value']);
86 }
87 return $expression;
88 }
static _getInstance()
Get an Instance of ExpressionManufacturer.

References $index, and ilAssLacExpressionManufacturer\_getInstance().

Referenced by create().

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


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