ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilAssLacStringResultExpression.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
15{
27 public static $pattern = "/~.*?~/";
28
32 public static $identifier = "~TEXT~";
33
39 protected $text;
40
45 public function getPattern()
46 {
47 return '/~(.*)~/';
48 }
49
57 protected function setMatches($matches)
58 {
59 $this->text = $matches[1][0];
60 }
61
65 public function getText()
66 {
67 return $this->text;
68 }
69
74 public function getValue()
75 {
76 return "~" . $this->text . '~';
77 }
78
83 public function getDescription()
84 {
85 return $this->text . " beantwortet ";
86 }
87
95 public function checkResult($result, $comperator, $index = null)
96 {
97 $isTrue = false;
98 if($index == null)
99 {
100 $values = $result->getUserSolutionsByIdentifier("value");
101
102 foreach($values as $value)
103 {
104 $isTrue = $isTrue || $this->compare($comperator, $value);
105 }
106 }
107 else
108 {
109 $solution = $result->getSolutionForKey($index);
110 $isTrue = $this->compare($comperator, $solution["value"]);
111 }
112
113 return $isTrue;
114 }
115
122 private function compare($comperator, $value)
123 {
124 switch($comperator)
125 {
126 case "=":
127 return $this->getText() == $value;
128 break;
129 case "<>":
130 return $this->getText() != $value;
131 break;
132 default:
133 return false;
134 }
135 }
136}
$result
Class StringResultExpression for the expression ~TEXT~.
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.
getDescription()
Get a human readable description of the Composite element.
getPattern()
Get the Pattern to match relevant informations for an Expression.