ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilAssLacMatchingResultExpression.php
Go to the documentation of this file.
1<?php
2
3include_once "Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/Expressions/ilAssLacAbstractExpression.php";
4include_once "Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/Expressions/ilAssLacSolutionExpressionInterface.php";
5
14{
27 public static $pattern = "/;[0-9]+:[0-9]+;/";
28
32 public static $identifier = ";n:m;";
33
40
47
48 protected function getPattern()
49 {
50 return '/;(\d+):(\d+);/';
51 }
52
60 protected function setMatches($matches)
61 {
62 $this->left_numeric_value = $matches[1][0];
63 $this->right_numeric_value = $matches[2][0];
64 }
65
69 public function getRightNumericValue()
70 {
72 }
73
77 public function getLeftNumericValue()
78 {
80 }
81
86 public function getValue()
87 {
88 return ";" . $this->left_numeric_value. ":" . $this->right_numeric_value . ";";
89 }
90
95 public function getDescription()
96 {
97 return $this->numeric_value . " beantwortet ";
98 }
99
107 public function checkResult($result, $comperator, $index = null)
108 {
109 $solutions = $result->getSolutions();
110 $isTrue = false;
111 foreach($solutions as $solution)
112 {
113 $isTrue = $isTrue || $this->compare($comperator, $solution["key"], $solution["value"]);
114 }
115 return $isTrue;
116 }
117
125 private function compare($comperator, $left, $right)
126 {
127 switch($comperator)
128 {
129 case "=":
130 return $this->getLeftNumericValue() == $left && $this->getRightNumericValue() == $right;
131 break;
132 case "<>":
133 return $this->getLeftNumericValue() != $left || $this->getRightNumericValue() != $right;
134 break;
135 default:
136 return false;
137 }
138 }
139}
$result
Class MatchingResultExpression for the expression ;n:m;.
getDescription()
Get a human readable description of the Composite element.
getPattern()
Get the Pattern to match relevant informations for an Expression.
checkResult($result, $comperator, $index=null)
setMatches($matches)
Sets the result of the parsed value by a specific expression pattern.
getValue()
Get the value of this Expression.