3 require_once
"Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/Exception/ilAssLacMissingBracket.php";
4 require_once
"Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/Exception/ilAssLacConditionParserException.php";
59 include_once
'Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/Factory/ilAssLacExpressionManufacturer.php';
60 include_once
'Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/Factory/ilAssLacOperationManufacturer.php';
61 include_once
"Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/ilAssLacCompositeBuilder.php";
81 return $compositeBuilder->create(
$nodes);
94 $this->expressions = $manufacturer->match($this->condition);
107 $this->operators = $manufacturer->match($this->condition);
120 $this->condition = preg_replace($manufacturer->getPattern(),
'n',
$this->condition);
122 $this->condition = preg_replace($manufacturer->getPattern(),
'o',
$this->condition);
123 $this->condition = preg_replace(
"/no/",
"n o", $this->condition);
124 $this->condition = preg_replace(
"/on/",
"o n", $this->condition);
126 for (
$i = 0;
$i < strlen($this->condition);
$i++) {
135 $num_brackets_open = substr_count($this->condition,
"(");
136 $num_brackets_close = substr_count($this->condition,
")");
138 if ($num_brackets_open > $num_brackets_close) {
141 if ($num_brackets_open < $num_brackets_close) {
170 $expected = array(
"n",
"(",
"!");
174 while ($this->index < strlen($this->condition)) {
176 if (trim($this->condition[$this->index]) !=
"" && in_array($this->condition[$this->index], $expected)) {
177 if ($this->condition[$this->index] ==
')') {
179 } elseif ($this->condition[$this->index] ==
'n') {
180 $group[] = array(
'type' =>
'expression',
'value' => array_shift($this->expressions));
181 $expected = array(
"o",
")");
182 } elseif ($this->condition[$this->index] ==
'o') {
183 $group[] = array(
'type' =>
'operator',
'value' => array_shift($this->operators));
184 $expected = array(
"n",
"(",
"!");
185 } elseif ($this->condition[$this->index] ==
'(') {
188 $group[] = array(
'type' =>
"group",
"negated" => $negation,
'nodes' => $elements);
190 $expected = array(
"o",
")");
191 } elseif ($this->condition[$this->index] ==
"!") {
194 } elseif (trim($this->condition[$this->index]) !=
"") {
202 return array(
'type' =>
'group',
"negated" => $negation,
'nodes' => $group);
222 $end = strpos($this->condition,
"n",
$start + 1);
226 $this->condition = substr_replace($this->condition,
"(n o n)",
$start,
$end -
$start + 1);
237 $next_bracket = strpos($this->condition,
"(",
$index + 1);
238 $next_expression = strpos($this->condition,
"n",
$index + 1);
240 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)
static _getInstance()
Get an Instance of OperationManufacturer.
parse($condition)
Parses the delivered condition and creates a composite tree Structure.
__construct()
Construct requirements.