3 require_once
"Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/Exception/ilAssLacMissingBracket.php";
4 require_once
"Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/Exception/ilAssLacConditionParserException.php";
57 include_once
'Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/Factory/ilAssLacExpressionManufacturer.php';
58 include_once
'Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/Factory/ilAssLacOperationManufacturer.php';
59 include_once
"Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/ilAssLacCompositeBuilder.php";
78 return $compositeBuilder->create($nodes);
90 $this->expressions = $manufacturer->match($this->condition);
102 $this->operators = $manufacturer->match($this->condition);
114 $this->condition = preg_replace($manufacturer->getPattern(),
'n',
$this->condition);
116 $this->condition = preg_replace($manufacturer->getPattern(),
'o',
$this->condition);
117 $this->condition = preg_replace(
"/no/",
"n o", $this->condition);
118 $this->condition = preg_replace(
"/on/",
"o n", $this->condition);
120 for($i = 0; $i < strlen($this->condition); $i++)
131 $num_brackets_open = substr_count($this->condition,
"(");
132 $num_brackets_close = substr_count($this->condition,
")");
134 if($num_brackets_open > $num_brackets_close)
138 if($num_brackets_open < $num_brackets_close)
168 $expected =
array(
"n",
"(",
"!");
172 while($this->index < strlen($this->condition))
175 if(trim($this->condition[$this->index]) !=
"" && in_array($this->condition[$this->index], $expected))
177 if ($this->condition[$this->index] ==
')')
181 else if ($this->condition[$this->index] ==
'n')
183 $group[] =
array(
'type' =>
'expression',
'value' => array_shift($this->expressions));
184 $expected =
array(
"o",
")");
186 else if ($this->condition[$this->index] ==
'o')
188 $group[] =
array(
'type' =>
'operator',
'value' => array_shift($this->operators));
189 $expected =
array(
"n",
"(",
"!");
191 else if ($this->condition[$this->index] ==
'(')
195 $group[] =
array(
'type' =>
"group",
"negated" => $negation,
'nodes' => $elements);
197 $expected =
array(
"o",
")");
199 else if($this->condition[$this->index] ==
"!")
204 elseif(trim($this->condition[$this->index]) !=
"")
215 return array(
'type' =>
'group',
"negated" => $negation,
'nodes' => $group);
236 $end = strpos($this->condition,
"n",
$start + 1);
239 if(
$start !==
false && $end !==
false)
241 $this->condition = substr_replace($this->condition,
"(n o n)",
$start, $end -
$start + 1);
252 $next_bracket = strpos($this->condition,
"(",
$index+1);
253 $next_expression = strpos($this->condition,
"n",
$index+1);
255 return $next_bracket !==
false & $next_bracket < $next_expression;
cannonicalizeCondition()
Cannonicalize the condition into a more general form.
Class ConditionParserException.
createNodeArray()
Creates an array representing all Nodes in a condition based on the fetched expressions and operators...
static _getInstance()
Get an Instance of ExpressionManufacturer.
isNegationSurroundedByBrackets($index)
fetchOperators()
Matches all operators in the current condition and assign these to the class attribute ConditionParse...
fetchExpressions()
Matches all expressions in the current condition and assign these to the class attribute ConditionPar...
surroundNegationExpression($index)
Create styles array
The data for the language used.
static _getInstance()
Get an Instance of OperationManufacturer.
parse($condition)
Parses the delivered condition and creates a composite tree Structure.
__construct()
Construct requirements.