71 include_once
'Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/Factory/ilAssLacExpressionManufacturer.php';
72 include_once
'Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/Factory/ilAssLacOperationManufacturer.php';
73 include_once
"Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/ilAssLacCompositeBuilder.php";
94 return $compositeBuilder->create($nodes);
107 $this->expressions = $manufacturer->match($this->condition);
120 $this->operators = $manufacturer->match($this->condition);
133 $this->condition = preg_replace($manufacturer->getPattern(),
'n', $this->condition);
135 $this->condition = preg_replace($manufacturer->getPattern(),
'o', $this->condition);
136 $this->condition = preg_replace(
"/no/",
"n o", $this->condition);
137 $this->condition = preg_replace(
"/on/",
"o n", $this->condition);
139 for (
$i = 0;
$i < strlen($this->condition);
$i++) {
148 $num_brackets_open = substr_count($this->condition,
"(");
149 $num_brackets_close = substr_count($this->condition,
")");
151 if ($num_brackets_open > $num_brackets_close) {
154 if ($num_brackets_open < $num_brackets_close) {
183 $expected = array(
"n",
"(",
"!");
187 while ($this->index < strlen($this->condition)) {
189 if (trim($this->condition[$this->index]) !=
"" && in_array($this->condition[$this->index], $expected)) {
190 if ($this->condition[$this->index] ==
')') {
192 } elseif ($this->condition[$this->index] ==
'n') {
193 $group[] = array(
'type' =>
'expression',
'value' => array_shift($this->expressions));
194 $expected = array(
"o",
")");
195 } elseif ($this->condition[$this->index] ==
'o') {
196 $group[] = array(
'type' =>
'operator',
'value' => array_shift($this->operators));
197 $expected = array(
"n",
"(",
"!");
198 } elseif ($this->condition[$this->index] ==
'(') {
201 $group[] = array(
'type' =>
"group",
"negated" => $negation,
'nodes' => $elements);
203 $expected = array(
"o",
")");
204 } elseif ($this->condition[$this->index] ==
"!") {
207 } elseif (trim($this->condition[$this->index]) !=
"") {
215 return array(
'type' =>
'group',
"negated" => $negation,
'nodes' => $group);
231 $start = strpos($this->condition,
"n",
$index + 1);
234 if ($start !==
false) {
235 $end = strpos($this->condition,
"n", $start + 1);
238 if ($start !==
false && $end !==
false) {
239 $this->condition = substr_replace($this->condition,
"(n o n)", $start, $end - $start + 1);
250 $next_bracket = strpos($this->condition,
"(",
$index + 1);
251 $next_expression = strpos($this->condition,
"n",
$index + 1);
253 return $next_bracket !==
false && $next_bracket < $next_expression;
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
createNodeArray()
Creates an array representing all Nodes in a condition based on the fetched expressions and operators...
cannonicalizeCondition()
Cannonicalize the condition into a more general form.
fetchExpressions()
Matches all expressions in the current condition and assign these to the class attribute ConditionPar...
isNegationSurroundedByBrackets($index)
fetchOperators()
Matches all operators in the current condition and assign these to the class attribute ConditionParse...
__construct()
Construct requirements.
parse($condition)
Parses the delivered condition and creates a composite tree Structure.
surroundNegationExpression($index)
static _getInstance()
Get an Instance of ExpressionManufacturer.
static _getInstance()
Get an Instance of OperationManufacturer.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples