ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilAssLacNumericResultExpression.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{
26 public static $pattern = '/#-?[0-9\.]+#/';
27
31 public static $identifier = "#n#";
32
38 protected $numeric_value;
39
47 protected function setMatches($matches)
48 {
49 $this->numeric_value = $matches[0][0];
50 }
51
55 public function getNumericValue()
56 {
58 }
59
64 public function getValue()
65 {
66 return "#" . $this->numeric_value . "#";
67 }
68
73 public function getDescription()
74 {
75 return $this->numeric_value . " beantwortet ";
76 }
77
85 public function checkResult($result, $comperator, $index = null)
86 {
87 $isTrue = false;
88 if($index == null)
89 {
90 $values = $result->getUserSolutionsByIdentifier("value");
91
92 foreach($values as $value)
93 {
94 $isTrue = $isTrue || $this->compare($comperator, $value);
95 }
96 }
97 else
98 {
99 $solution = $result->getSolutionForKey($index);
100 $isTrue = $this->compare($comperator, $solution["value"]);
101 }
102
103 return $isTrue;
104 }
105
106 private function compare($comperator, $value)
107 {
108 switch($comperator)
109 {
110 case "<":
111 return $value < $this->getNumericValue();
112 break;
113 case "<=":
114 return $value <= $this->getNumericValue();
115 break;
116 case "=":
117 return $value == $this->getNumericValue();
118 break;
119 case ">=":
120 return $value >= $this->getNumericValue();
121 break;
122 case ">":
123 return $value > $this->getNumericValue();
124 break;
125 case "<>":
126 return $value != $this->getNumericValue();
127 break;
128 default:
129 return false;
130 }
131 }
132}
$result
Class NumericResultExpression for the expression #n#.
getDescription()
Get a human readable description of the Composite element.
getValue()
Get the value of this Expression.
checkResult($result, $comperator, $index=null)
setMatches($matches)
Sets the result of the parsed value by a specific expression pattern.